We can cover more cases by directly checking if the result is
known-nonzero for common patterns when they are missing OrZero.
This patch add isKnownNonZero checks for shl, lshr, and, and mul.
Paths
| Differential D157309
[ValueTracking] Do more thorough non-zero check in `isKnownToBePowerOfTwo` when `OrZero` is no set. AbandonedPublic Authored by goldstein.w.n on Aug 7 2023, 10:49 AM.
Details Summary We can cover more cases by directly checking if the result is This patch add isKnownNonZero checks for shl, lshr, and, and mul.
Diff Detail
Unit TestsFailed
Event TimelineComment Actions Please land the remainder of the patch stack first.
goldstein.w.n removed a parent revision: D157308: [ValueTracking] Add support for `mul` in `isKnownToBeAPowerOfTwo`.Aug 9 2023, 11:32 AM goldstein.w.n removed a child revision: D157310: [ValueTracking] In `isKnownToBeAPowerOfTwo` an `i1` value is always true if `OrZero` is set. goldstein.w.n added a parent revision: D157313: [ValueTracking] Check likely to be canonicalized constant operands first in ; NFC. goldstein.w.n added inline comments. goldstein.w.n removed a parent revision: D157313: [ValueTracking] Check likely to be canonicalized constant operands first in ; NFC. Comment Actionsmoving to gh. This revision was landed with ongoing or failed builds.Oct 12 2023, 2:05 PM
Revision Contents
Diff 548705 llvm/lib/Analysis/ValueTracking.cpp
llvm/test/Analysis/ValueTracking/known-power-of-two.ll
llvm/test/Transforms/InstSimplify/ctpop-pow2.ll
|
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).