[llvm-commits] [llvm] r41740 - in /llvm/trunk: lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/2007-09-05-EqualGEP.ll

Nick Lewycky nicholas at mxc.ca
Wed Sep 5 18:10:22 PDT 2007


Author: nicholas
Date: Wed Sep  5 20:10:22 2007
New Revision: 41740

URL: http://llvm.org/viewvc/llvm-project?rev=41740&view=rev
Log:
When the two operands of an icmp are equal, there are five possible predicates
that would make the icmp true. Fixes PR1637.

Added:
    llvm/trunk/test/Transforms/InstCombine/2007-09-05-EqualGEP.ll
Modified:
    llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=41740&r1=41739&r2=41740&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Wed Sep  5 20:10:22 2007
@@ -4563,7 +4563,9 @@
       if (NumDifferences == 0)   // SAME GEP?
         return ReplaceInstUsesWith(I, // No comparison is needed here.
                                    ConstantInt::get(Type::Int1Ty, 
-                                                    Cond == ICmpInst::ICMP_EQ));
+                                                    Cond == ICmpInst::ICMP_EQ ||
+                     Cond == ICmpInst::ICMP_ULE || Cond == ICmpInst::ICMP_UGE ||
+                     Cond == ICmpInst::ICMP_SLE || Cond == ICmpInst::ICMP_SGE));
       else if (NumDifferences == 1) {
         Value *LHSV = GEPLHS->getOperand(DiffOperand);
         Value *RHSV = GEPRHS->getOperand(DiffOperand);

Added: llvm/trunk/test/Transforms/InstCombine/2007-09-05-EqualGEP.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/2007-09-05-EqualGEP.ll?rev=41740&view=auto

==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/2007-09-05-EqualGEP.ll (added)
+++ llvm/trunk/test/Transforms/InstCombine/2007-09-05-EqualGEP.ll Wed Sep  5 20:10:22 2007
@@ -0,0 +1,10 @@
+; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep {ret i1 true}
+; PR1637
+
+define i1 @f(i8* %arr) {
+        %X = getelementptr i8* %arr, i32 1
+        %Y = getelementptr i8* %arr, i32 1
+        %test = icmp uge i8* %X, %Y
+        ret i1 %test
+}
+





More information about the llvm-commits mailing list