[PATCH] D144608: [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:28 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.

`(X ^ Y_NonZero) u>= X` --> `(X ^ Y_NonZero) u> X`

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

`(X ^ Y_NonZero) u<= X` --> `(X ^ Y_NonZero) u< X`

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

`(X ^ Y_NonZero) s>= X` --> `(X ^ Y_NonZero) s> X`

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

`(X ^ Y_NonZero) s<= X` --> `(X ^ Y_NonZero) s< X    `

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

`(X ^ Y) u> X` --> `X & MSB(Y) == 0`

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

`(X ^ Y) u< X` --> `X & MSB(Y) != 0`

- https://alive2.llvm.org/ce/z/5s9SWj

`(X ^ Pos_Y) s> X` --> `X & MSB(Pow2_Y) == 0`

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

`(X ^ Pos_Y) s< X` --> `X & MSB(Pow2_Y) != 0`

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

`(X ^ Neg_Y) s> X` --> `X s< 0`

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

`(X ^ Neg_Y) s< X` --> `X s>= 0`

- https://alive2.llvm.org/ce/z/36iZDw


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D144608

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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D144608.499678.patch
Type: text/x-patch
Size: 9968 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230223/6c6de4c7/attachment-0001.bin>


More information about the llvm-commits mailing list