[PATCH] D145426: [InstCombine] Add transforms `(icmp spred (and X, Y), X)` if `X` or `Y` are known signed/unsigned

Noah Goldstein via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 6 14:17:03 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.

Several transforms:

1. If known `Y < 0`:
  - slt -> ult: https://alive2.llvm.org/ce/z/unpsxu
  - sle -> ule: https://alive2.llvm.org/ce/z/a5cpmr
  - sgt -> ugt: https://alive2.llvm.org/ce/z/qgsgya
  - sge -> uge: https://alive2.llvm.org/ce/z/ek_3ls
2. If known `Y > 0`:
  - `(X & PosY) s> X --> X s< 0`
    - https://alive2.llvm.org/ce/z/drewij
  - `(X & PosY) s> X --> X s< 0`
    - https://alive2.llvm.org/ce/z/9arL3D
3. If known `X < 0`:
  - `(NegX & Y) s> NegX --> Y s>= 0`
    - https://alive2.llvm.org/ce/z/ApkaEh
  - `(NegX & Y) s<= NegX --> Y s< 0`
    - https://alive2.llvm.org/ce/z/oRnfHp


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D145426

Files:
  llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
  llvm/test/Transforms/InstCombine/canonicalize-constant-low-bit-mask-and-icmp-sge-to-icmp-sle.ll
  llvm/test/Transforms/InstCombine/canonicalize-constant-low-bit-mask-and-icmp-sgt-to-icmp-sgt.ll
  llvm/test/Transforms/InstCombine/canonicalize-constant-low-bit-mask-and-icmp-sle-to-icmp-sle.ll
  llvm/test/Transforms/InstCombine/canonicalize-constant-low-bit-mask-and-icmp-slt-to-icmp-sgt.ll
  llvm/test/Transforms/InstCombine/icmp-of-and-x.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D145426.502804.patch
Type: text/x-patch
Size: 8541 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230306/3a805e79/attachment.bin>


More information about the llvm-commits mailing list