[PATCH] D105796: [RISCV] Optimize multiplication in the zba extension with SH*ADD

Ben Shi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 12 00:37:02 PDT 2021


benshi001 created this revision.
benshi001 added reviewers: craig.topper, asb, luismarques, LevyHsu.
Herald added subscribers: vkmr, frasercrmck, evandro, 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, hiraditya.
benshi001 requested review of this revision.
Herald added subscribers: llvm-commits, MaskRay.
Herald added a project: LLVM.

This patch makes two changes:

1. Do the following optimization: (mul x, power_of_2+2) -> (SH1ADD x, (SLLI x, bits)) (mul x, power_of_2+4) -> (SH2ADD x, (SLLI x, bits)) (mul x, power_of_2+8) -> (SH3ADD x, (SLLI x, bits))

2. Refactor the implementation of previous optimization: Ry + Rx * 18  => (SH1ADD (SH3ADD Rx, Rx), Ry) Ry + Rx * 20  => (SH2ADD (SH2ADD Rx, Rx), Ry) Ry + Rx * 24  => (SH3ADD (SH1ADD Rx, Rx), Ry) Ry + Rx * 36  => (SH2ADD (SH3ADD Rx, Rx), Ry) Ry + Rx * 40  => (SH3ADD (SH2ADD Rx, Rx), Ry) Ry + Rx * 72  => (SH3ADD (SH3ADD Rx, Rx), Ry)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105796

Files:
  llvm/lib/Target/RISCV/RISCVISelLowering.cpp
  llvm/lib/Target/RISCV/RISCVInstrInfoB.td
  llvm/test/CodeGen/RISCV/rv32zba.ll
  llvm/test/CodeGen/RISCV/rv64zba.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D105796.357848.patch
Type: text/x-patch
Size: 8999 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210712/8475876a/attachment.bin>


More information about the llvm-commits mailing list