[PATCH] D143394: [RISCV] Add performMULcombine to perform strength-reduction

Philipp Tomsich via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 6 06:24:03 PST 2023


philipp.tomsich created this revision.
philipp.tomsich added a reviewer: craig.topper.
Herald added subscribers: luke, VincentWu, vkmr, frasercrmck, evandro, luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, shiva0217, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, hiraditya, arichardson.
Herald added a project: All.
philipp.tomsich requested review of this revision.
Herald added subscribers: llvm-commits, pcwang-thead, eopXD, MaskRay.
Herald added a project: LLVM.

The RISC-V backend thus far does not provide strength-reduction, which
causes a long (but not complete) list of 3-instruction patterns listed
to utilize the shift-and-add instruction from Zba and XTHeadBa in
strength-reduction.

This adds the logic to perform strength-reduction through the DAG
combine for ISD::MUL.  Initially, we wire this up for XTheadBa only,
until this has had some time to settle and get real-world test
exposure.

The following strength-reductions strategies are currently supported:

- XTheadBa
  - C = (n + 1)           // th.addsl
  - C = (n + 1)k          // th.addsl, slli
  - C = (n + 1)(m + 1)    // th.addsl, th.addsl
  - C = (n + 1)(m + 1)k   // th.addsl, th.addsl, slli
  - C = ((n + 1)m + 1)    // th.addsl, th.addsl
  - C = ((n + 1)m + 1)k   // th.addslm th.addsl, slli
- base ISA
  - C being 2 set-bits    // slli, slli, add

  			       (possibly slli, th.addsl)

Even though the slli+slli+add sequence would we supported without
XTheadBa, this currently is gated to avoid having to update a large
number of test cases (i.e., anything that has a multiplication with a
constant where only 2 bits are set) in this commit.

With the strength reduction now being performed in performMUL combine,
we drop the (now redundant) patterns from RISCVInstrInfoXTHead.td.

Depends on D143029 <https://reviews.llvm.org/D143029>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D143394

Files:
  llvm/lib/Target/RISCV/RISCVISelLowering.cpp
  llvm/lib/Target/RISCV/RISCVInstrInfoXTHead.td

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D143394.495107.patch
Type: text/x-patch
Size: 9474 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230206/33c4e9df/attachment.bin>


More information about the llvm-commits mailing list