]> granicus.if.org Git - llvm/commit
Merging r293345:
authorHans Wennborg <hans@hanshq.net>
Thu, 2 Feb 2017 22:19:34 +0000 (22:19 +0000)
committerHans Wennborg <hans@hanshq.net>
Thu, 2 Feb 2017 22:19:34 +0000 (22:19 +0000)
commit6a630d742074be775ca242c52071f5dcc5538b5b
tree6ea71d5fc6d1fb94498bf37c1a94379406352884
parent4c02744674eefe1d06247de20e68ab00ab75c061
Merging r293345:
------------------------------------------------------------------------
r293345 | spatel | 2017-01-27 15:26:27 -0800 (Fri, 27 Jan 2017) | 19 lines

[InstCombine] move icmp transforms that might be recognized as min/max and inf-loop (PR31751)

This is a minimal patch to avoid the infinite loop in:
https://llvm.org/bugs/show_bug.cgi?id=31751

But the general problem is bigger: we're not canonicalizing all of the min/max forms reported
by value tracking's matchSelectPattern(), and we don't define min/max consistently. Some code
uses matchSelectPattern(), other code uses matchers like m_Umax, and others have their own
inline definitions which may be subtly different from any of the above.

The reason that the test cases in this patch need a cast op to trigger is because we don't
(yet) canonicalize all min/max forms based on matchSelectPattern() in
canonicalizeMinMaxWithConstant(), but we do make min/max+cast transforms based on
matchSelectPattern() in visitSelectInst().

The location of the icmp transforms that trigger the inf-loop seems arbitrary at best, so
I'm moving those behind the min/max fence in visitICmpInst() as the quick fix.

------------------------------------------------------------------------

git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_40@293947 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/InstCombine/InstCombineCompares.cpp
test/Transforms/InstCombine/minmax-fold.ll