[llvm] c345198 - [RISCV] Add a command line option to disable cost per use for compressed registers. (#83320)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 28 15:06:24 PST 2024
Author: Craig Topper
Date: 2024-02-28T15:06:20-08:00
New Revision: c345198c7a68cb76e82dbc04d0e91476cb0edc70
URL: https://github.com/llvm/llvm-project/commit/c345198c7a68cb76e82dbc04d0e91476cb0edc70
DIFF: https://github.com/llvm/llvm-project/commit/c345198c7a68cb76e82dbc04d0e91476cb0edc70.diff
LOG: [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.
Added:
Modified:
llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp b/llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp
index 9d1f01dffaaf47..a68674b221d38e 100644
--- a/llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp
+++ b/llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp
@@ -30,6 +30,8 @@
using namespace llvm;
+static cl::opt<bool> DisableCostPerUse("riscv-disable-cost-per-use",
+ cl::init(false), cl::Hidden);
static cl::opt<bool>
DisableRegAllocHints("riscv-disable-regalloc-hints", cl::Hidden,
cl::init(false),
@@ -712,7 +714,10 @@ void RISCVRegisterInfo::getOffsetOpcodes(const StackOffset &Offset,
unsigned
RISCVRegisterInfo::getRegisterCostTableIndex(const MachineFunction &MF) const {
- return MF.getSubtarget<RISCVSubtarget>().hasStdExtCOrZca() ? 1 : 0;
+ return MF.getSubtarget<RISCVSubtarget>().hasStdExtCOrZca() &&
+ !DisableCostPerUse
+ ? 1
+ : 0;
}
// Add two address hints to improve chances of being able to use a compressed
More information about the llvm-commits
mailing list