[PATCH] D147410: [RISCV] Optimize multiplication with immediates

Ben Shi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 2 02:51:46 PDT 2023


benshi001 added inline comments.


================
Comment at: llvm/lib/Target/RISCV/RISCVISelLowering.cpp:14854
-      if (HasExtMOrZmmul && VT.getSizeInBits() >= Subtarget.getXLen())
-        return false;
       // Break the MUL to two SLLI instructions and an ADD/SUB, if Imm needs
----------------
The reason why there is regression in the case `the sub target has the M extension and the data size >= XLen`, is that the immediate is used twice for `i64` mul on rv32.

If we change the restriction from `VT.getSizeInBits() >= Subtarget.getXLen()` to `ConstNode->hasOneUse()`, then the regression introduced by the above situation can be avoided, but other chances of optimization can be enabled.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147410/new/

https://reviews.llvm.org/D147410



More information about the llvm-commits mailing list