[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 17:19:56 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:
> sanjoy wrote:
> > 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?
> It is undef but I don't think ComputeNumSignBits it allowed to assign known bits to undef values.
I see what you mean. I'm a bit embarrassed now that it took me this long. :)
https://reviews.llvm.org/D30311
More information about the llvm-commits
mailing list