[PATCH] D134310: [InstCombine] don't canonicalize shl+sub to mul+add

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 20 13:39:16 PDT 2022


spatel created this revision.
spatel added reviewers: nikic, RKSimon, craig.topper.
Herald added subscribers: kosarev, StephenFan, lebedev.ri, kerbowa, hiraditya, jvesely, mcrosier.
Herald added a reviewer: lebedev.ri.
Herald added a project: All.
spatel requested review of this revision.
Herald added subscribers: llvm-commits, pcwang-thead.
Herald added a project: LLVM.

This stops Negator from transforming:
C1 <https://reviews.llvm.org/C1> - shl X, C2 --> mul X, (1<<C2) + C1 <https://reviews.llvm.org/C1>
...in the general case. There does not seem to be any analysis benefit to using mul in IR, and there's definitely downside in codegen (particularly when the multiply has to be expanded).

If C1 <https://reviews.llvm.org/C1> is 0, then there's a stronger argument that the single mul is a better canonicalization than negate-of-shl, but we may want to remove that too.

This was noted as a potential conflict for D133667 <https://reviews.llvm.org/D133667>.


https://reviews.llvm.org/D134310

Files:
  llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp
  llvm/test/CodeGen/AMDGPU/reqd-work-group-size.ll
  llvm/test/Transforms/InstCombine/mul-inseltpoison.ll
  llvm/test/Transforms/InstCombine/mul.ll
  llvm/test/Transforms/InstCombine/shl-bo.ll
  llvm/test/Transforms/InstCombine/shl-sub.ll
  llvm/test/Transforms/InstCombine/sub-of-negatible-inseltpoison.ll
  llvm/test/Transforms/InstCombine/sub-of-negatible.ll
  llvm/test/Transforms/InstCombine/sub.ll
  llvm/test/Transforms/LoopVectorize/AArch64/sve-vector-reverse.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D134310.461672.patch
Type: text/x-patch
Size: 21760 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220920/6be27ce8/attachment.bin>


More information about the llvm-commits mailing list