[PATCH] D128080: [SDAG] convert sub from (Pow2-1) constant into xor

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 17 11:38:34 PDT 2022


spatel created this revision.
spatel added reviewers: deadalnix, RKSimon, dmgreen.
Herald added subscribers: jsji, kosarev, ecnelises, kerbowa, pengfei, jrtc27, fedor.sergeev, hiraditya, jvesely, nemanjai, mcrosier, jyknight.
Herald added a project: All.
spatel requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

An xor with constant should have equivalent perf as sub-from-constant on any target (or better perf in the case that the sub constant is harder to materialize and use).

This is translated from an existing fold in InstCombine, but the pattern can show up in codegen as shown in a variety of test diffs.

Alive2 proof:
https://alive2.llvm.org/ce/z/8CgggY

This might help remove some diffs from D127115 <https://reviews.llvm.org/D127115>. We don't see test diffs on basic x86 examples because this fold already exists somewhere later in that target's codegen, but that may be too late to combine with other transforms.


https://reviews.llvm.org/D128080

Files:
  llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
  llvm/test/CodeGen/AArch64/sub1.ll
  llvm/test/CodeGen/AMDGPU/ds-sub-offset.ll
  llvm/test/CodeGen/AMDGPU/setcc-multiple-use.ll
  llvm/test/CodeGen/ARM/intrinsics-overflow.ll
  llvm/test/CodeGen/ARM/usub_sat.ll
  llvm/test/CodeGen/ARM/usub_sat_plus.ll
  llvm/test/CodeGen/PowerPC/select_const.ll
  llvm/test/CodeGen/SPARC/64bit.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D128080.437984.patch
Type: text/x-patch
Size: 8077 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220617/8eb21b62/attachment.bin>


More information about the llvm-commits mailing list