[llvm] [RISCV] Add sink-and-fold support for RISC-V. (PR #67602)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 2 12:16:49 PDT 2023
================
@@ -1907,6 +1907,76 @@ bool RISCVInstrInfo::verifyInstruction(const MachineInstr &MI,
return true;
}
+bool RISCVInstrInfo::canFoldIntoAddrMode(const MachineInstr &MemI, Register Reg,
+ const MachineInstr &AddrI,
+ ExtAddrMode &AM) const {
+ switch (MemI.getOpcode()) {
+ default:
+ return false;
+ case RISCV::LB:
+ case RISCV::LBU:
+ case RISCV::LH:
+ case RISCV::LHU:
+ case RISCV::LW:
+ case RISCV::LWU:
+ case RISCV::LD:
+ case RISCV::FLH:
+ case RISCV::FLW:
+ case RISCV::FLD:
+ case RISCV::SB:
+ case RISCV::SH:
+ case RISCV::SW:
+ case RISCV::SD:
+ case RISCV::FSH:
+ case RISCV::FSW:
+ case RISCV::FSD:
+ break;
+ }
+
+ // Check the fold operand is not the loaded/stored value.
+ const MachineOperand &BaseRegOp = MemI.getOperand(0);
----------------
topperc wrote:
I don't think we need the isReg check since the value operand should always be a register. So I got rid of the variable.
https://github.com/llvm/llvm-project/pull/67602
More information about the llvm-commits
mailing list