[PATCH] D106745: [DAG] DAGCombiner::useDivRem - recognise sub(X,mul(div(X,Y),Y)) as a rem(X,Y)

Simon Pilgrim via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Jul 24 06:18:31 PDT 2021


RKSimon created this revision.
RKSimon added reviewers: spatel, craig.topper, lebedev.ri.
Herald added subscribers: ecnelises, pengfei, hiraditya.
RKSimon requested review of this revision.
Herald added a project: LLVM.

Attempt to match a sub(X,mul(div(X,Y),Y)) pattern as srem/urem as a last chance to merge into a divrem instruction.

For reference, the DivRemPairs pass explicitly won't merge cases when the sub/mul and div are in the same block:

  // If the target supports div+rem and the instructions are in the same block
  // already, there's nothing to do. The backend should handle this. If the
  // target does not support div+rem, then we will decompose the rem.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106745

Files:
  llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
  llvm/test/CodeGen/X86/div-rem-pair-recomposition-signed.ll
  llvm/test/CodeGen/X86/div-rem-pair-recomposition-unsigned.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D106745.361451.patch
Type: text/x-patch
Size: 15970 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210724/07ef48fc/attachment.bin>


More information about the llvm-commits mailing list