[llvm] [RISCV] Add short forward branch support for `lb`, `lbu`, `lh`, `lhu`, `lw`, `lwu` and `ld` (PR #170829)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 5 09:01:02 PST 2025
- Previous message: [llvm] [RISCV] Add short forward branch support for `lb`, `lbu`, `lh`, `lhu`, `lw`, `lwu` and `ld` (PR #170829)
- Next message: [llvm] [RISCV] Add short forward branch support for `lb`, `lbu`, `lh`, `lhu`, `lw`, `lwu` and `ld` (PR #170829)
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
================
@@ -897,6 +897,80 @@ MachineInstr *RISCVInstrInfo::foldMemoryOperandImpl(
.addImm(0);
}
+unsigned getLoadPredicatedOpcode(unsigned Opcode) {
+ switch (Opcode) {
+ case RISCV::LB:
+ return RISCV::PseudoCCLB;
+ case RISCV::LBU:
+ return RISCV::PseudoCCLBU;
+ case RISCV::LH:
+ return RISCV::PseudoCCLH;
+ case RISCV::LHU:
+ return RISCV::PseudoCCLHU;
+ case RISCV::LW:
+ return RISCV::PseudoCCLW;
+ case RISCV::LWU:
+ return RISCV::PseudoCCLWU;
+ case RISCV::LD:
+ return RISCV::PseudoCCLD;
+ default:
+ return 0;
+ }
+}
+
+MachineInstr *RISCVInstrInfo::foldMemoryOperandImpl(
+ MachineFunction &MF, MachineInstr &MI, ArrayRef<unsigned> Ops,
+ MachineBasicBlock::iterator InsertPt, MachineInstr &LoadMI,
+ LiveIntervals *LIS) const {
+ // For now, only handle RISCV::PseudoCCMOVGPR.
+ if (MI.getOpcode() != RISCV::PseudoCCMOVGPR)
+ return nullptr;
+
+ if (!STI.hasShortForwardBranchILoad() ||
+ (LoadMI.getOpcode() != RISCV::LB && LoadMI.getOpcode() != RISCV::LBU &&
----------------
topperc wrote:
Can we move the call to `getLoadPredicatedOpcode` earlier and the return value of 0 to detect unsupported cases? Then we don't need to list all 7 opcodes in two places.
https://github.com/llvm/llvm-project/pull/170829
- Previous message: [llvm] [RISCV] Add short forward branch support for `lb`, `lbu`, `lh`, `lhu`, `lw`, `lwu` and `ld` (PR #170829)
- Next message: [llvm] [RISCV] Add short forward branch support for `lb`, `lbu`, `lh`, `lhu`, `lw`, `lwu` and `ld` (PR #170829)
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the llvm-commits
mailing list