A few more cases of missing masking in ComputeMaskedBits; found by inspection.
authorEli Friedman <eli.friedman@gmail.com>
Mon, 5 Mar 2012 23:22:40 +0000 (23:22 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Mon, 5 Mar 2012 23:22:40 +0000 (23:22 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152070 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/ValueTracking.cpp

index b35e2074acbc04a3432c870814ecf08ae2dafbd0..745e5fe99cc610ff82f23c5d321f7fafac542829 100644 (file)
@@ -723,17 +723,17 @@ void llvm::ComputeMaskedBits(Value *V, const APInt &Mask,
         // If this call is undefined for 0, the result will be less than 2^n.
         if (II->getArgOperand(1) == ConstantInt::getTrue(II->getContext()))
           LowBits -= 1;
-        KnownZero = APInt::getHighBitsSet(BitWidth, BitWidth - LowBits);
+        KnownZero = Mask & APInt::getHighBitsSet(BitWidth, BitWidth - LowBits);
         break;
       }
       case Intrinsic::ctpop: {
         unsigned LowBits = Log2_32(BitWidth)+1;
-        KnownZero = APInt::getHighBitsSet(BitWidth, BitWidth - LowBits);
+        KnownZero = Mask & APInt::getHighBitsSet(BitWidth, BitWidth - LowBits);
         break;
       }
       case Intrinsic::x86_sse42_crc32_64_8:
       case Intrinsic::x86_sse42_crc32_64_64:
-        KnownZero = APInt::getHighBitsSet(64, 32);
+        KnownZero = Mask & APInt::getHighBitsSet(64, 32);
         break;
       }
     }