[PATCH] D157309: [ValueTracking] Do more thorough non-zero check in `isKnownToBePowerOfTwo` when `OrZero` is no set.
Noah Goldstein via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 9 10:01:20 PDT 2023
goldstein.w.n added inline comments.
================
Comment at: llvm/lib/Analysis/ValueTracking.cpp:2049
case Instruction::Shl:
- if (OrZero || Q.IIQ.hasNoUnsignedWrap(I) || Q.IIQ.hasNoSignedWrap(I))
- return isKnownToBeAPowerOfTwo(I->getOperand(0), OrZero, Depth, Q);
----------------
nikic wrote:
> Would it make sense to preserve the flag checks? I think isKnownNonZero will be able to prove the same result, but in a more roundabout way (it can't just check the flags, it will also have to prove non-zero operands etc).
I think for `shl` you are right, `IPSCCP` will propagate `nuw` in all the cases I think `isKnownNonZero` helps here.
For `lshr` however the equivilent logic is missing. I take it you would prefer fixing this with a patch to `IPSCCP`?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D157309/new/
https://reviews.llvm.org/D157309
More information about the llvm-commits
mailing list