[llvm] [AMDGPU] Prefer lower total register usage in regions with spilling (PR #71882)

Jeffrey Byrnes via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 6 15:49:04 PST 2023


================
@@ -18,6 +18,26 @@
 using namespace llvm;
 
 #define DEBUG_TYPE "machine-scheduler"
+namespace {
+
+struct ExcessVGPRWeightParser : public cl::parser<unsigned> {
+  ExcessVGPRWeightParser(cl::Option &O) : cl::parser<unsigned>(O) {}
+
+  bool parse(cl::Option &O, StringRef ArgName, StringRef Arg, unsigned &Value) {
+    if (Arg.getAsInteger(0, Value) || Value > 2048 || Value < 0)
+      return O.error("'" + Arg + "' value must be in the range [0, 2048]!");
+
+    return false;
+  }
+};
+
+} // end anonymous namespace
+
+static cl::opt<unsigned, false, ExcessVGPRWeightParser> ExcessVGPRWeight(
+    "amdgpu-excess-vgpr-weight", cl::init(32), cl::Hidden,
----------------
jrbyrnes wrote:

Thanks again for the thoughts @vpykhtin  -- I've let it default to `ST.getWavefrontSize()` , the rationale being that spilling a VGPR is equivalent to spilling WavefrontSize SGPRs, but this is a simple heuristic -- thus it is a configurable parameter.

https://github.com/llvm/llvm-project/pull/71882


More information about the llvm-commits mailing list