[PATCH] D134415: [InstCombine] Improve fold icmp of truncated left shift
Sanjay Patel via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 28 06:09:19 PDT 2022
spatel added inline comments.
================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp:1561
+ if (C1->isPowerOf2()) {
+ // (trunc (2**C1 << Y) to iN) == 0 -> Y u> N - C1 + 1
+ // (trunc (2**C1 << Y) to iN) != 0 -> Y u<= N - C1 + 1
----------------
That looks correct, but I'd prefer that this comment matches what the code and the alive proof actually do, so I'd change it to something like this:
```
// (trunc (2**C1 << Y) to iN) == 0 -> Y u> ctlz(trunc(C1))
```
================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp:1569-1570
+ }
+ // (trunc (2**C1 << Y) to iN) == 2**C --> Y == C - C1
+ // (trunc (2**C1 << Y) to iN) != 2**C --> Y != C - C1
+ if (C.isPowerOf2() && C.uge(*C1))
----------------
Add an Alive2 proof for this pattern to the patch description?
================
Comment at: llvm/test/Transforms/InstCombine/icmp-trunc.ll:409
; TODO: A > 4
----------------
Remove TODO.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D134415/new/
https://reviews.llvm.org/D134415
More information about the llvm-commits
mailing list