[PATCH] D148404: [ValueTracking] Apply the isKnownNonZero techniques in `ashr`/`lshl` to `shl` and vice-versa
Noah Goldstein via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 14 17:22:33 PDT 2023
goldstein.w.n created this revision.
goldstein.w.n added reviewers: majnemer, spatel, nikic.
Herald added subscribers: StephenFan, hiraditya.
Herald added a project: All.
goldstein.w.n requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
For all shifts we can apply the same two optimizations.
1. `ShiftOp(KnownVal.One, Max(KnownCnt)) != 0` -> result is non-zero
2. If already known `Val != 0` and we only shift out zeros (based on `Max(KnownCnt)`) -> result is non-zero
The former exists for `shl` and the latter (for constant `Cnt`) exists
for `ashr`/`lshr`.
This patch improves the latter to use `Max(KnownCnt)` instead of
relying on a constant shift `Cnt` and applies both techniques for all
shift ops.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D148404
Files:
llvm/lib/Analysis/ValueTracking.cpp
llvm/test/Analysis/ValueTracking/known-non-zero.ll
llvm/test/Transforms/InstCombine/ctpop-pow2.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D148404.513822.patch
Type: text/x-patch
Size: 7405 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230415/ec42fc6f/attachment.bin>
More information about the llvm-commits
mailing list