[llvm] [RISCV] Fold LI 1 / SLLI into BSETI during i64 materialization (PR #142348)
Piotr Fusik via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 2 01:55:00 PDT 2025
================
@@ -353,6 +353,13 @@ InstSeq generateInstSeq(int64_t Val, const MCSubtargetInfo &STI) {
} while (Hi != 0);
Res = TmpSeq;
}
+
+ // Fold LI 1 + SLLI into BSETI.
+ if (Res[0].getOpcode() == RISCV::ADDI && Res[0].getImm() == 1 &&
+ Res[1].getOpcode() == RISCV::SLLI) {
+ Res.erase(Res.begin()); // Remove ADDI.
+ Res.front() = Inst(RISCV::BSETI, Res.front().getImm()); // Patch SLLI.
----------------
pfusik wrote:
Another option would be to add `setOpcode()`.
https://github.com/llvm/llvm-project/pull/142348
More information about the llvm-commits
mailing list