[llvm-commits] [llvm] r170128 - in /llvm/trunk: lib/Transforms/InstCombine/InstCombineCompares.cpp test/Transforms/InstCombine/icmp.ll

NAKAMURA Takumi geek4civic at gmail.com
Thu Dec 13 06:28:16 PST 2012


Author: chapuni
Date: Thu Dec 13 08:28:16 2012
New Revision: 170128

URL: http://llvm.org/viewvc/llvm-project?rev=170128&view=rev
Log:
Revert r170020, "Simplify negated bit test", for now.

This assumes (1 << n) is always not zero. Consider n is greater than word size.
Although I know it is undefined, this transforms undefined behavior hidden.

This led clang unexpected behavior with some failures. I will investigate to fix undefined shl in clang.

Modified:
    llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp
    llvm/trunk/test/Transforms/InstCombine/icmp.ll

Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp?rev=170128&r1=170127&r2=170128&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp Thu Dec 13 08:28:16 2012
@@ -2034,15 +2034,6 @@
                                                CI->countTrailingZeros()));
       }
 
-      // Turn x&~y == 0 into x&y != 0 if x is a power of 2.
-      Value *X = 0, *Y = 0;
-      if (match(Op0, m_And(m_Value(X), m_Not(m_Value(Y)))) &&
-          match(Op1, m_Zero()) && isKnownToBeAPowerOfTwo(X, TD)) {
-        return new ICmpInst(ICmpInst::ICMP_NE,
-                            Builder->CreateAnd(X, Y),
-                            Op1);
-      }
-
       break;
     }
     case ICmpInst::ICMP_NE: {
@@ -2080,15 +2071,6 @@
                                                CI->countTrailingZeros()));
       }
 
-      // Turn x&~y != 0 into x&y == 0 if x is a power of 2.
-      Value *X = 0, *Y = 0;
-      if (match(Op0, m_And(m_Value(X), m_Not(m_Value(Y)))) &&
-          match(Op1, m_Zero()) && isKnownToBeAPowerOfTwo(X, TD)) {
-        return new ICmpInst(ICmpInst::ICMP_EQ,
-                            Builder->CreateAnd(X, Y),
-                            Op1);
-      }
-
       break;
     }
     case ICmpInst::ICMP_ULT:

Modified: llvm/trunk/test/Transforms/InstCombine/icmp.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/icmp.ll?rev=170128&r1=170127&r2=170128&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/icmp.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/icmp.ll Thu Dec 13 08:28:16 2012
@@ -677,29 +677,3 @@
 ; CHECK-NEXT: ret i1 true
   ret i1 %cmp
 }
-
-define i1 @test67(i32 %A, i32 %B) {
-  %neg = xor i32 %A, -1
-  %shl = shl i32 1, %B
-  %and = and i32 %shl, %neg
-  %cmp = icmp ne i32 %and, 0
-; CHECK: @test67
-; CHECK-NEXT: %shl = shl i32 1, %B
-; CHECK-NEXT: %1 = and i32 %shl, %A
-; CHECK-NEXT: %cmp = icmp eq i32 %1, 0
-; CHECK-NEXT: ret i1 %cmp
-  ret i1 %cmp
-}
-
-define i1 @test68(i32 %A, i32 %B) {
-  %neg = xor i32 %A, -1
-  %shl = shl i32 1, %B
-  %and = and i32 %shl, %neg
-  %cmp = icmp eq i32 %and, 0
-; CHECK: @test68
-; CHECK-NEXT: %shl = shl i32 1, %B
-; CHECK-NEXT: %1 = and i32 %shl, %A
-; CHECK-NEXT: %cmp = icmp ne i32 %1, 0
-; CHECK-NEXT: ret i1 %cmp
-  ret i1 %cmp
-}





More information about the llvm-commits mailing list