Skip to content

Commit c345198

Browse files
authored
[RISCV] Add a command line option to disable cost per use for compressed registers. (#83320)
I've seen cases where the cost per use increase the number of spills. Disabling improves the codegen for #79918. I propose adding this option to allow easier experimentation.
1 parent e7a303e commit c345198

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030

3131
using namespace llvm;
3232

33+
static cl::opt<bool> DisableCostPerUse("riscv-disable-cost-per-use",
34+
cl::init(false), cl::Hidden);
3335
static cl::opt<bool>
3436
DisableRegAllocHints("riscv-disable-regalloc-hints", cl::Hidden,
3537
cl::init(false),
@@ -712,7 +714,10 @@ void RISCVRegisterInfo::getOffsetOpcodes(const StackOffset &Offset,
712714

713715
unsigned
714716
RISCVRegisterInfo::getRegisterCostTableIndex(const MachineFunction &MF) const {
715-
return MF.getSubtarget<RISCVSubtarget>().hasStdExtCOrZca() ? 1 : 0;
717+
return MF.getSubtarget<RISCVSubtarget>().hasStdExtCOrZca() &&
718+
!DisableCostPerUse
719+
? 1
720+
: 0;
716721
}
717722

718723
// Add two address hints to improve chances of being able to use a compressed

0 commit comments

Comments
 (0)