Add extra CHECK to make sure that 'or' instruction was replaced.
authorJakub Staszak <kubastaszak@gmail.com>
Mon, 31 Dec 2012 18:26:42 +0000 (18:26 +0000)
committerJakub Staszak <kubastaszak@gmail.com>
Mon, 31 Dec 2012 18:26:42 +0000 (18:26 +0000)
Also add an assert to avoid confusion in the code where is known that C1 <= C2.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171310 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
test/Transforms/InstCombine/icmp.ll

index ab75318eaaa891501c13205997c62c9620eab148..fac035e7ef89eb301dc52403f57c639be6726ba6 100644 (file)
@@ -1528,6 +1528,8 @@ Value *InstCombiner::FoldOrOfICmps(ICmpInst *LHS, ICmpInst *RHS) {
       if (LHS->getOperand(0) == RHS->getOperand(0)) {
         // if LHSCst and RHSCst differ only by one bit:
         // (A == C1 || A == C2) -> (A & ~(C1 ^ C2)) == C1
+        assert(LHSCst->getValue().ule(LHSCst->getValue()));
+
         APInt Xor = LHSCst->getValue() ^ RHSCst->getValue();
         if (Xor.isPowerOf2()) {
           Value *NegCst = Builder->getInt(~Xor);
index 5102a9cb6a1acd49fe28ce6aa9f9dceab61fa8de..8fb6144c3f1a4a8684e9486f81fa4bfb873f64b1 100644 (file)
@@ -699,6 +699,7 @@ define i1 @test68(i32 %x) nounwind uwtable {
 ; CHECK: @test69
 ; CHECK: %1 = and i32 %c, -33
 ; CHECK: %2 = icmp eq i32 %1, 65
+; CHECK: ret i1 %2
 define i1 @test69(i32 %c) nounwind uwtable {
   %1 = icmp eq i32 %c, 97
   %2 = icmp eq i32 %c, 65