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

Noah Goldstein via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 3 15:55:16 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) 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/D145280

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: D145280.502284.patch
Type: text/x-patch
Size: 7552 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230303/86692c51/attachment.bin>


More information about the llvm-commits mailing list