[PATCH] D30311: [ValueTracking] Don't do an unchecked shift in ComputeNumSignBits

Sanjoy Das via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 23 14:37:40 PST 2017


sanjoy added inline comments.


================
Comment at: lib/Analysis/ValueTracking.cpp:2209
     if (match(U->getOperand(1), m_APInt(ShAmt))) {
-      Tmp += ShAmt->getZExtValue();
+      Tmp += ShAmt->getLimitedValue(TyBits);
       if (Tmp > TyBits) Tmp = TyBits;
----------------
majnemer wrote:
> Shouldn't we treat this in the same way we treat Instruction::Shl?
You mean return `1` for undefined shifts?  I don't see a good reason why we should do that (both here and in `shl`) -- `ashr` ing more than the bitwidth is `undef` anyway, so why not be maximally aggressive?


https://reviews.llvm.org/D30311





More information about the llvm-commits mailing list