[llvm] [RegAllocEvictAdvisor] Add minimum weight ratio heuristic. (PR #98109)
Mikhail Gudim via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 8 20:47:04 PDT 2024
https://github.com/mgudim created https://github.com/llvm/llvm-project/pull/98109
Do not evict a live range if eviction will break existing hint without satisfying a new one and the ratio of weights is not big enough.
>From 7d90710ec3e99c332673e087d568407bd214ae4a Mon Sep 17 00:00:00 2001
From: Mikhail Gudim <mgudim at gmail.com>
Date: Mon, 8 Jul 2024 23:40:14 -0400
Subject: [PATCH] [RegAllocEvictAdvisor] Add minimum weight ratio heuristic.
Do not evict a live range if eviction will break existing hint without
satisfying a new one and the ratio of weights is not big enough.
---
llvm/lib/CodeGen/RegAllocEvictionAdvisor.cpp | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/llvm/lib/CodeGen/RegAllocEvictionAdvisor.cpp b/llvm/lib/CodeGen/RegAllocEvictionAdvisor.cpp
index a1dccc4d59723..8d916cb6f0823 100644
--- a/llvm/lib/CodeGen/RegAllocEvictionAdvisor.cpp
+++ b/llvm/lib/CodeGen/RegAllocEvictionAdvisor.cpp
@@ -44,6 +44,12 @@ static cl::opt<bool> EnableLocalReassignment(
"may be compile time intensive"),
cl::init(false));
+static cl::opt<float> MinWeightRatioNeededToEvictHint(
+ "min-weight-ratio-needed-to-evict-hint", cl::Hidden,
+ cl::desc("The minimum ration of weights needed in order for the live range with bigger weight to evict the other live range which"
+ "satisfies a hint),
+ cl::init(7.5));
+
namespace llvm {
cl::opt<unsigned> EvictInterferenceCutoff(
"regalloc-eviction-max-interference-cutoff", cl::Hidden,
@@ -157,6 +163,10 @@ bool DefaultEvictionAdvisor::shouldEvict(const LiveInterval &A, bool IsHint,
return true;
if (A.weight() > B.weight()) {
+ float WeightRatio = A.weight() / B.weight();
+ if (CanSplit && !IsHint && BreaksHint &&
+ (WeightRatio < MinWeightRatioNeededToEvictHint))
+ return false;
LLVM_DEBUG(dbgs() << "should evict: " << B << " w= " << B.weight() << '\n');
return true;
}
More information about the llvm-commits
mailing list