[PATCH] D145002: [DAGCombiner] Make `(zext (sgt X, -1))` -> `(srl (not X), N-1)` work if typeof(zext)!=typeof(X)

Noah Goldstein via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 28 13:20:23 PST 2023


goldstein.w.n created this revision.
Herald added subscribers: luke, frasercrmck, ecnelises, luismarques, apazos, sameer.abuasal, pengfei, s.egerton, Jim, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, hiraditya, nemanjai.
Herald added a project: All.
goldstein.w.n requested review of this revision.
Herald added subscribers: llvm-commits, pcwang-thead, MaskRay.
Herald added a project: LLVM.

`(srl (not X), N-1)` is either 0/1, so any `zext` can be combined to
this.

To avoid the transformation when the result of the `setcc` is being
used directly, only allow mismatch if the `zext` type is larger than
`i8`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D145002

Files:
  llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
  llvm/test/CodeGen/AArch64/arm64-icmp-opt.ll
  llvm/test/CodeGen/PowerPC/fp-strict-fcmp.ll
  llvm/test/CodeGen/PowerPC/setcc-logic.ll
  llvm/test/CodeGen/PowerPC/signbit-shift.ll
  llvm/test/CodeGen/RISCV/select-constant-xor.ll
  llvm/test/CodeGen/RISCV/selectcc-to-shiftand.ll
  llvm/test/CodeGen/X86/icmp-opt.ll
  llvm/test/CodeGen/X86/select-constant-xor.ll
  llvm/test/CodeGen/X86/select.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D145002.501280.patch
Type: text/x-patch
Size: 14278 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230228/608b548d/attachment.bin>


More information about the llvm-commits mailing list