[PATCH] D133399: [DAGCombiner] Fold (mul (sra X, BW-1), Y) -> (neg (and (sra X, BW-1), Y))

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 6 23:07:30 PDT 2022


craig.topper created this revision.
craig.topper added reviewers: spatel, RKSimon, efriedma.
Herald added subscribers: kosarev, StephenFan, frasercrmck, ecnelises, kerbowa, luismarques, apazos, sameer.abuasal, pengfei, s.egerton, dmgreen, Jim, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, hiraditya, jvesely, nemanjai.
Herald added a project: All.
craig.topper requested review of this revision.
Herald added subscribers: pcwang-thead, MaskRay.
Herald added a project: LLVM.

(sra X, BW-1) is either 0 or -1. So the multiply is a conditional
negate of Y.

This pattern shows up when type legalizing wide multiplies involving
a sign extended value.

Fixes PR57549.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D133399

Files:
  llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
  llvm/test/CodeGen/AArch64/umulo-128-legalisation-lowering.ll
  llvm/test/CodeGen/AMDGPU/mad_64_32.ll
  llvm/test/CodeGen/PowerPC/pr45448.ll
  llvm/test/CodeGen/RISCV/mul.ll
  llvm/test/CodeGen/RISCV/xaluo.ll
  llvm/test/CodeGen/Thumb2/mve-vmull-splat.ll
  llvm/test/CodeGen/X86/extmul128.ll
  llvm/test/CodeGen/X86/muloti.ll
  llvm/test/CodeGen/X86/smul_fix_sat.ll
  llvm/test/CodeGen/X86/smulo-128-legalisation-lowering.ll
  llvm/test/CodeGen/X86/vec_smulo.ll
  llvm/test/CodeGen/X86/xmulo.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D133399.458361.patch
Type: text/x-patch
Size: 202464 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220907/cc669a01/attachment-0001.bin>


More information about the llvm-commits mailing list