Fix typo: should have been testing that X was odd, not V.
authorDuncan Sands <baldrick@free.fr>
Sat, 29 Jan 2011 13:27:00 +0000 (13:27 +0000)
committerDuncan Sands <baldrick@free.fr>
Sat, 29 Jan 2011 13:27:00 +0000 (13:27 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124533 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/ValueTracking.cpp
test/Transforms/InstSimplify/2011-01-18-Compare.ll

index aa7769ea545b7e162a8e3800f245e61edbc36280..72b3f03a93aacefdcbd3f174d135e2aec28193a9 100644 (file)
@@ -715,16 +715,16 @@ bool llvm::isKnownNonZero(Value *V, const TargetData *TD, unsigned Depth) {
   if (isa<SExtInst>(V) || isa<ZExtInst>(V))
     return isKnownNonZero(cast<Instruction>(V)->getOperand(0), TD, Depth);
 
-  // shl X, A != 0 if X is odd.  Note that the value of the shift is undefined
+  // shl X, Y != 0 if X is odd.  Note that the value of the shift is undefined
   // if the lowest bit is shifted off the end.
   if (BitWidth && match(V, m_Shl(m_Value(X), m_Value(Y)))) {
     APInt KnownZero(BitWidth, 0);
     APInt KnownOne(BitWidth, 0);
-    ComputeMaskedBits(V, APInt(BitWidth, 1), KnownZero, KnownOne, TD, Depth);
+    ComputeMaskedBits(X, APInt(BitWidth, 1), KnownZero, KnownOne, TD, Depth);
     if (KnownOne[0])
       return true;
   }
-  // shr X, A != 0 if X is negative.  Note that the value of the shift is not
+  // shr X, Y != 0 if X is negative.  Note that the value of the shift is not
   // defined if the sign bit is shifted off the end.
   else if (match(V, m_Shr(m_Value(X), m_Value(Y)))) {
     bool XKnownNonNegative, XKnownNegative;
index c905c443d2e1543ba960c9ba818a0ad8f351694b..ed358443d6384c7f8bf45c4759770fb4b084a610 100644 (file)
@@ -108,3 +108,27 @@ define i1 @or(i32 %x) {
   ret i1 %c
 ; CHECK: ret i1 false
 }
+
+define i1 @shl(i32 %x) {
+; CHECK: @shl
+  %s = shl i32 1, %x
+  %c = icmp eq i32 %s, 0
+  ret i1 %c
+; CHECK: ret i1 false
+}
+
+define i1 @lshr(i32 %x) {
+; CHECK: @lshr
+  %s = lshr i32 -1, %x
+  %c = icmp eq i32 %s, 0
+  ret i1 %c
+; CHECK: ret i1 false
+}
+
+define i1 @ashr(i32 %x) {
+; CHECK: @ashr
+  %s = ashr i32 -1, %x
+  %c = icmp eq i32 %s, 0
+  ret i1 %c
+; CHECK: ret i1 false
+}