[PATCH] D144610: [InstCombine] Add transforms for `(icmp (xor X, Y), X)`

Noah Goldstein via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 22 17:20:47 PST 2023


goldstein.w.n created this revision.
Herald added a subscriber: 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.

There are a variety of cases we can simplify either saving
instructions are creating sequences that are easier to optimize
elsewhere.

`icmp (X | Y) u<= X` --> `(X | Y) == X`

- https://alive2.llvm.org/ce/z/qnbbPv

`icmp (X | Y) u> X` --> `(X | Y) != X`

- https://alive2.llvm.org/ce/z/fvLqg3

`icmp (X | noundef Y) eq/ne X` --> `(X & noundef Y) eq/ne noundef Y`

- https://alive2.llvm.org/ce/z/cXM8DR
- https://alive2.llvm.org/ce/z/eocLw2

`icmp (X | MinInt) s> X` --> `false`

- https://alive2.llvm.org/ce/z/mpd-Yj

`icmp (X | MinInt) s<= X` --> `true`

- https://alive2.llvm.org/ce/z/E4aynv

`icmp (X | MinInt) s>= X` --> `X s< 0`

- https://alive2.llvm.org/ce/z/ThZkSV

`icmp (X | MinInt) s< X` --> `X s>= 0`

- https://alive2.llvm.org/ce/z/sNx2VB

`icmp (X | Pos_Y) s> X` --> `(X | Pos_Y) != X`

- https://alive2.llvm.org/ce/z/n-XM6N

`icmp (X | Pos_Y) s<= X` --> `(X | Pos_Y) == X`

- https://alive2.llvm.org/ce/z/1FQZM-


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D144610

Files:
  llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
  llvm/test/Transforms/InstCombine/icmp-of-or-x.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D144610.499680.patch
Type: text/x-patch
Size: 9027 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230223/9e34adca/attachment.bin>


More information about the llvm-commits mailing list