[PATCH] D154004: [InstCombine] Canonicalize `(icmp eq/ne (and x, C), x)` -> `(icmp eq/ne (and x, ~C), 0)`
Noah Goldstein via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 29 01:36:54 PDT 2023
goldstein.w.n added a comment.
In D154004#4458568 <https://reviews.llvm.org/D154004#4458568>, @nikic wrote:
> LGTM. Note that there is a conjugate `or` fold (same but with -1 instead of 0) that should be implemented for symmetry as well.
Or better yet `(icmp eq/ne (or x, C), x)` -> `(icmp eq/ne (and x, C), C)`: https://alive2.llvm.org/ce/z/m2R2jo
Then we get to reuse `C` instead of creating a new constant (and `and` is typically the easiest to analyze).
Works generically as well (I actually have it implemented in: D144610 <https://reviews.llvm.org/D144610>).
If you think this is enough motivation for D144610 <https://reviews.llvm.org/D144610> I can rebase the series, otherwise I'll just implement here along side the current `and` code. LMK.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D154004/new/
https://reviews.llvm.org/D154004
More information about the llvm-commits
mailing list