[llvm-branch-commits] [llvm-branch] r259390 - Merging r259375:

Hans Wennborg via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Feb 1 11:18:10 PST 2016


Author: hans
Date: Mon Feb  1 13:18:10 2016
New Revision: 259390

URL: http://llvm.org/viewvc/llvm-project?rev=259390&view=rev
Log:
Merging r259375:
------------------------------------------------------------------------
r259375 | majnemer | 2016-02-01 09:37:56 -0800 (Mon, 01 Feb 2016) | 6 lines

[InstCombine] Don't transform (X+INT_MAX)>=(Y+INT_MAX) -> (X<=Y)

This miscompile came about because we tried to use a transform which was
only appropriate for xor operators when addition was present.

This fixes PR26407.
------------------------------------------------------------------------

Modified:
    llvm/branches/release_38/   (props changed)
    llvm/branches/release_38/lib/Transforms/InstCombine/InstCombineCompares.cpp
    llvm/branches/release_38/test/Transforms/InstCombine/icmp.ll

Propchange: llvm/branches/release_38/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Feb  1 13:18:10 2016
@@ -1,3 +1,3 @@
 /llvm/branches/Apple/Pertwee:110850,110961
 /llvm/branches/type-system-rewrite:133420-134817
-/llvm/trunk:155241,257645,257648,257730,257775,257791,257875,257886,257902,257905,257925,257929-257930,257940,257942,257977,257979,257997,258168,258184,258207,258221,258273,258325,258406,258416,258428,258436,258471,258690,258729,258891,258971,259228,259236
+/llvm/trunk:155241,257645,257648,257730,257775,257791,257875,257886,257902,257905,257925,257929-257930,257940,257942,257977,257979,257997,258168,258184,258207,258221,258273,258325,258406,258416,258428,258436,258471,258690,258729,258891,258971,259228,259236,259375

Modified: llvm/branches/release_38/lib/Transforms/InstCombine/InstCombineCompares.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_38/lib/Transforms/InstCombine/InstCombineCompares.cpp?rev=259390&r1=259389&r2=259390&view=diff
==============================================================================
--- llvm/branches/release_38/lib/Transforms/InstCombine/InstCombineCompares.cpp (original)
+++ llvm/branches/release_38/lib/Transforms/InstCombine/InstCombineCompares.cpp Mon Feb  1 13:18:10 2016
@@ -3560,7 +3560,7 @@ Instruction *InstCombiner::visitICmpInst
                                 BO1->getOperand(0));
           }
 
-          if (CI->isMaxValue(true)) {
+          if (BO0->getOpcode() == Instruction::Xor && CI->isMaxValue(true)) {
             ICmpInst::Predicate Pred = I.isSigned()
                                            ? I.getUnsignedPredicate()
                                            : I.getSignedPredicate();

Modified: llvm/branches/release_38/test/Transforms/InstCombine/icmp.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_38/test/Transforms/InstCombine/icmp.ll?rev=259390&r1=259389&r2=259390&view=diff
==============================================================================
--- llvm/branches/release_38/test/Transforms/InstCombine/icmp.ll (original)
+++ llvm/branches/release_38/test/Transforms/InstCombine/icmp.ll Mon Feb  1 13:18:10 2016
@@ -1672,3 +1672,15 @@ define i1 @cmp_slt_rhs_inc(float %x, i32
   %cmp = icmp slt i32 %conv, %inc
   ret i1 %cmp
 }
+
+; CHECK-LABEL: @PR26407
+; CHECK-NEXT: %[[addx:.*]] = add i32 %x, 2147483647
+; CHECK-NEXT: %[[addy:.*]] = add i32 %y, 2147483647
+; CHECK-NEXT: %[[cmp:.*]] = icmp uge i32 %[[addx]], %[[addy]]
+; CHECK-NEXT: ret i1 %[[cmp]]
+define i1 @PR26407(i32 %x, i32 %y) {
+  %addx = add i32 %x, 2147483647
+  %addy = add i32 %y, 2147483647
+  %cmp = icmp uge i32 %addx, %addy
+  ret i1 %cmp
+}




More information about the llvm-branch-commits mailing list