[llvm] [RegAllocEvictAdvisor] Add minimum weight ratio heuristic. (PR #98109)

Mikhail Gudim via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 4 09:14:48 PDT 2026


https://github.com/mgudim updated https://github.com/llvm/llvm-project/pull/98109

>From ae308f479ed010393d9e3ce1370b7707c8d57988 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 1/5] [RegAllocEvictAdvisor][NFC] 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. The
heuristic is disabled by default.
---
 llvm/lib/CodeGen/RegAllocEvictionAdvisor.cpp | 19 +++++-
 llvm/test/CodeGen/RISCV/min-weight-ratio.mir | 72 ++++++++++++++++++++
 2 files changed, 89 insertions(+), 2 deletions(-)
 create mode 100644 llvm/test/CodeGen/RISCV/min-weight-ratio.mir

diff --git a/llvm/lib/CodeGen/RegAllocEvictionAdvisor.cpp b/llvm/lib/CodeGen/RegAllocEvictionAdvisor.cpp
index 7734d66f6b42c..d496c5e4b8a4f 100644
--- a/llvm/lib/CodeGen/RegAllocEvictionAdvisor.cpp
+++ b/llvm/lib/CodeGen/RegAllocEvictionAdvisor.cpp
@@ -46,6 +46,13 @@ 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 ratio of weights needed in order for the live range "
+             "with bigger weight to evict the other live range which"
+             "satisfies a hint"),
+    cl::init(1.0));
+
 namespace llvm {
 cl::opt<unsigned> EvictInterferenceCutoff(
     "regalloc-eviction-max-interference-cutoff", cl::Hidden,
@@ -226,8 +233,16 @@ bool DefaultEvictionAdvisor::shouldEvict(const LiveInterval &A, bool IsHint,
   if (CanSplit && IsHint && !BreaksHint)
     return true;
 
-  if (A.weight() > B.weight()) {
-    LLVM_DEBUG(dbgs() << "should evict: " << B << '\n');
+  float AWeight = A.weight();
+  float BWeight = B.weight();
+  if (AWeight > BWeight) {
+    float WeightRatio = BWeight == 0.0 ? std::numeric_limits<float>::infinity()
+                                       : AWeight / BWeight;
+    if (CanSplit && !IsHint && BreaksHint &&
+        (WeightRatio < MinWeightRatioNeededToEvictHint)) {
+      return false;
+    }
+    LLVM_DEBUG(dbgs() << "should evict: " << B << " w= " << BWeight << '\n');
     return true;
   }
   return false;
diff --git a/llvm/test/CodeGen/RISCV/min-weight-ratio.mir b/llvm/test/CodeGen/RISCV/min-weight-ratio.mir
new file mode 100644
index 0000000000000..d3813dcb1a5e3
--- /dev/null
+++ b/llvm/test/CodeGen/RISCV/min-weight-ratio.mir
@@ -0,0 +1,72 @@
+# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 5
+# RUN: llc %s -mtriple=riscv64 -run-pass=greedy,virtregrewriter \
+# RUN: -min-weight-ratio-needed-to-evict-hint=7.5 -o - | FileCheck %s
+
+# Due to the minimum weight heuristic (see the explanation of `MinWeightRatioNeededToEvictHint`) we are able to get rid of ALL the copies in the code below. When heuristic is disabled (`-min-weight-ratio-needed-to-evict-hint=1.0`) we end up with 3 copies.
+
+--- |
+  define i64 @caller(i64 %x) {
+  entry:
+    %add_ = add i64 %x, 1
+    call void @foo()
+    ret i64 %add_
+  }
+
+  declare void @foo()
+
+...
+---
+name:            caller
+alignment:       2
+tracksRegLiveness: true
+body:             |
+  bb.0.entry:
+    liveins: $x10, $x1, $x8, $x9, $x18, $x19, $x20, $x21, $x22, $x23, $x24, $x25, $x26, $x27
+
+    ; CHECK-LABEL: name: caller
+    ; CHECK: liveins: $x1, $x8, $x9, $x10, $x18, $x19, $x20, $x21, $x22, $x23, $x24, $x25, $x26, $x27
+    ; CHECK-NEXT: {{  $}}
+    ; CHECK-NEXT: SD $x1, %stack.0, 0 :: (store (s64) into %stack.0)
+    ; CHECK-NEXT: renamable $x10 = ADDI killed renamable $x10, 1
+    ; CHECK-NEXT: SD killed renamable $x10, %stack.1, 0 :: (store (s64) into %stack.1)
+    ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def dead $x2, implicit $x2
+    ; CHECK-NEXT: PseudoCALL target-flags(riscv-call) @foo, csr_ilp32d_lp64d, implicit-def dead $x1, implicit-def $x2
+    ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def dead $x2, implicit $x2
+    ; CHECK-NEXT: $x10 = LD %stack.1, 0 :: (load (s64) from %stack.1)
+    ; CHECK-NEXT: $x1 = LD %stack.0, 0 :: (load (s64) from %stack.0)
+    ; CHECK-NEXT: PseudoRET implicit $x10, implicit $x1, implicit $x8, implicit $x9, implicit $x18, implicit $x19, implicit $x20, implicit $x21, implicit $x22, implicit $x23, implicit $x24, implicit $x25, implicit $x26, implicit $x27
+    %14:gpr = COPY $x27
+    %13:gpr = COPY $x26
+    %12:gpr = COPY $x25
+    %11:gpr = COPY $x24
+    %10:gpr = COPY $x23
+    %9:gpr = COPY $x22
+    %8:gpr = COPY $x21
+    %7:gpr = COPY $x20
+    %6:gpr = COPY $x19
+    %5:gpr = COPY $x18
+    %4:gprc_and_sr07 = COPY $x9
+    %3:gprc_and_sr07 = COPY $x8
+    %2:gpr = COPY $x1
+    %0:gpr = COPY $x10
+    %1:gpr = ADDI %0, 1
+    ADJCALLSTACKDOWN 0, 0, implicit-def dead $x2, implicit $x2
+    PseudoCALL target-flags(riscv-call) @foo, csr_ilp32d_lp64d, implicit-def dead $x1, implicit-def $x2
+    ADJCALLSTACKUP 0, 0, implicit-def dead $x2, implicit $x2
+    $x10 = COPY %1
+    $x1 = COPY %2
+    $x8 = COPY %3
+    $x9 = COPY %4
+    $x18 = COPY %5
+    $x19 = COPY %6
+    $x20 = COPY %7
+    $x21 = COPY %8
+    $x22 = COPY %9
+    $x23 = COPY %10
+    $x24 = COPY %11
+    $x25 = COPY %12
+    $x26 = COPY %13
+    $x27 = COPY %14
+    PseudoRET implicit $x10, implicit $x1, implicit $x8, implicit $x9, implicit $x18, implicit $x19, implicit $x20, implicit $x21, implicit $x22, implicit $x23, implicit $x24, implicit $x25, implicit $x26, implicit $x27
+
+...

>From ac67a96a42eb74fbb90db8287efb43b187fd4407 Mon Sep 17 00:00:00 2001
From: Mikhail Gudim <mgudim at qti.qualcomm.com>
Date: Mon, 25 May 2026 11:00:46 -0700
Subject: [PATCH 2/5] [CodeGen] Improve heuristic for eviction decisions.

Currently, the `DefaultEvictionAdvisor::shouldEvict` makes the decision
to evict based on `weight`. The higher the use-def frequency of a live
range, the harder it should be to evict a live range, since it is more
"complex". Conversely, the bigger the size of a live range, the easier
it should be to evict, since the eviction would free up a register for a
longer duration. The `weight` combines the two numbers into one by
dividing use-def frequency by the size.

Turns our that a better way to combine the two exists. When one live range
has a significantly higher use-def frequence, we should just ignore the
sizes. If use-def frequencies are comparable, we should evict only if
the size of evictee is much larger that the size of evictor.
---
 llvm/lib/CodeGen/RegAllocEvictionAdvisor.cpp | 45 ++++++++++++--------
 1 file changed, 28 insertions(+), 17 deletions(-)

diff --git a/llvm/lib/CodeGen/RegAllocEvictionAdvisor.cpp b/llvm/lib/CodeGen/RegAllocEvictionAdvisor.cpp
index d496c5e4b8a4f..33909d126c5d8 100644
--- a/llvm/lib/CodeGen/RegAllocEvictionAdvisor.cpp
+++ b/llvm/lib/CodeGen/RegAllocEvictionAdvisor.cpp
@@ -46,12 +46,15 @@ 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 ratio of weights needed in order for the live range "
-             "with bigger weight to evict the other live range which"
-             "satisfies a hint"),
-    cl::init(1.0));
+static cl::opt<float> MinUseDefFreqRatioToIgnoreSize(
+    "min-use-def-freq-ratio-to-ignore-size", cl::Hidden,
+    cl::desc("if live range A wants to evict live range B and A's use-def frequency divided by B's use-def frequency is outside of the range `(1 / MinUseDefFreqRatioToIgnoreSize,  MinUseDefFreqRatioToIgnoreSize)` ignore the sizes of A dn B when making the eviction decision."),
+    cl::init(5.0));
+
+static cl::opt<float> MinSizeRatioNeededToEvict(
+    "min-size-ratio-needed-to-evict", cl::Hidden,
+    cl::desc("if live range A wants to evict live range B and A's use-def frequency divided by B's use-def frequency is in the renge `[1 / MinUseDefFreqRatioToIgnoreSize,  MinUseDefFreqRatioToIgnoreSize]` then evict B only if size of A divided by the size of B is smaller than `MinSizeRatioNeededToEvict`"),
+    cl::init(0.1));
 
 namespace llvm {
 cl::opt<unsigned> EvictInterferenceCutoff(
@@ -233,18 +236,24 @@ bool DefaultEvictionAdvisor::shouldEvict(const LiveInterval &A, bool IsHint,
   if (CanSplit && IsHint && !BreaksHint)
     return true;
 
-  float AWeight = A.weight();
-  float BWeight = B.weight();
-  if (AWeight > BWeight) {
-    float WeightRatio = BWeight == 0.0 ? std::numeric_limits<float>::infinity()
-                                       : AWeight / BWeight;
-    if (CanSplit && !IsHint && BreaksHint &&
-        (WeightRatio < MinWeightRatioNeededToEvictHint)) {
-      return false;
-    }
-    LLVM_DEBUG(dbgs() << "should evict: " << B << " w= " << BWeight << '\n');
+  const unsigned SizeOffset = 25 * SlotIndex::InstrDist;
+  float AUseDefFreq = A.weight() * (A.getSize() + SizeOffset);
+  float BUseDefFreq = B.weight() * (B.getSize() + SizeOffset);
+  if (BUseDefFreq == 0.0f)
+    return true;
+  float FreqRatio = AUseDefFreq / BUseDefFreq;
+  if (FreqRatio > MinUseDefFreqRatioToIgnoreSize)
+    return true;
+  if (FreqRatio < 1.0f / MinUseDefFreqRatioToIgnoreSize)
+    return false;
+  // use-def frequencies are comparable. Evict B only if
+  // its size is much larger, so eviction can provide some register pressure relief.
+  int ASize = A.getSize();
+  int BSize = B.getSize();
+  if (BSize == 0)
+    return false;
+  if ((float) ASize / (float) BSize < MinSizeRatioNeededToEvict)
     return true;
-  }
   return false;
 }
 
@@ -337,6 +346,8 @@ bool DefaultEvictionAdvisor::canEvictInterferenceBasedOnCost(
       // Apply the eviction policy for non-urgent evictions.
       if (!shouldEvict(VirtReg, IsHint, *Intf, BreaksHint))
         return false;
+      LLVM_DEBUG(dbgs() << "should evict: " << *Intf << " w= " << Intf->weight() << '\n');
+
       // If !MaxCost.isMax(), then we're just looking for a cheap register.
       // Evicting another local live range in this case could lead to suboptimal
       // coloring.

>From 35bfbeeb0b8a5f796ac12658b519d515f08fdf3b Mon Sep 17 00:00:00 2001
From: Mikhail Gudim <mgudim at qti.qualcomm.com>
Date: Mon, 1 Jun 2026 11:22:47 -0700
Subject: [PATCH 3/5] set default `MinSizeRatioNeededToEvict` to 0.05

---
 llvm/lib/CodeGen/RegAllocEvictionAdvisor.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/lib/CodeGen/RegAllocEvictionAdvisor.cpp b/llvm/lib/CodeGen/RegAllocEvictionAdvisor.cpp
index 33909d126c5d8..f3ccaf09517d5 100644
--- a/llvm/lib/CodeGen/RegAllocEvictionAdvisor.cpp
+++ b/llvm/lib/CodeGen/RegAllocEvictionAdvisor.cpp
@@ -54,7 +54,7 @@ static cl::opt<float> MinUseDefFreqRatioToIgnoreSize(
 static cl::opt<float> MinSizeRatioNeededToEvict(
     "min-size-ratio-needed-to-evict", cl::Hidden,
     cl::desc("if live range A wants to evict live range B and A's use-def frequency divided by B's use-def frequency is in the renge `[1 / MinUseDefFreqRatioToIgnoreSize,  MinUseDefFreqRatioToIgnoreSize]` then evict B only if size of A divided by the size of B is smaller than `MinSizeRatioNeededToEvict`"),
-    cl::init(0.1));
+    cl::init(0.05));
 
 namespace llvm {
 cl::opt<unsigned> EvictInterferenceCutoff(

>From 39d5867bba6faf100a5246ac5a5c612940f35728 Mon Sep 17 00:00:00 2001
From: Mikhail Gudim <mgudim at qti.qualcomm.com>
Date: Mon, 1 Jun 2026 12:01:50 -0700
Subject: [PATCH 4/5] format, remove test

---
 llvm/lib/CodeGen/RegAllocEvictionAdvisor.cpp | 21 ++++--
 llvm/test/CodeGen/RISCV/min-weight-ratio.mir | 72 --------------------
 2 files changed, 16 insertions(+), 77 deletions(-)
 delete mode 100644 llvm/test/CodeGen/RISCV/min-weight-ratio.mir

diff --git a/llvm/lib/CodeGen/RegAllocEvictionAdvisor.cpp b/llvm/lib/CodeGen/RegAllocEvictionAdvisor.cpp
index f3ccaf09517d5..3879d802672a1 100644
--- a/llvm/lib/CodeGen/RegAllocEvictionAdvisor.cpp
+++ b/llvm/lib/CodeGen/RegAllocEvictionAdvisor.cpp
@@ -48,12 +48,21 @@ static cl::opt<bool> EnableLocalReassignment(
 
 static cl::opt<float> MinUseDefFreqRatioToIgnoreSize(
     "min-use-def-freq-ratio-to-ignore-size", cl::Hidden,
-    cl::desc("if live range A wants to evict live range B and A's use-def frequency divided by B's use-def frequency is outside of the range `(1 / MinUseDefFreqRatioToIgnoreSize,  MinUseDefFreqRatioToIgnoreSize)` ignore the sizes of A dn B when making the eviction decision."),
+    cl::desc(
+        "if live range A wants to evict live range B and A's use-def frequency "
+        "divided by B's use-def frequency is outside of the range `(1 / "
+        "MinUseDefFreqRatioToIgnoreSize,  MinUseDefFreqRatioToIgnoreSize)` "
+        "ignore the sizes of A dn B when making the eviction decision."),
     cl::init(5.0));
 
 static cl::opt<float> MinSizeRatioNeededToEvict(
     "min-size-ratio-needed-to-evict", cl::Hidden,
-    cl::desc("if live range A wants to evict live range B and A's use-def frequency divided by B's use-def frequency is in the renge `[1 / MinUseDefFreqRatioToIgnoreSize,  MinUseDefFreqRatioToIgnoreSize]` then evict B only if size of A divided by the size of B is smaller than `MinSizeRatioNeededToEvict`"),
+    cl::desc(
+        "if live range A wants to evict live range B and A's use-def frequency "
+        "divided by B's use-def frequency is in the renge `[1 / "
+        "MinUseDefFreqRatioToIgnoreSize,  MinUseDefFreqRatioToIgnoreSize]` "
+        "then evict B only if size of A divided by the size of B is smaller "
+        "than `MinSizeRatioNeededToEvict`"),
     cl::init(0.05));
 
 namespace llvm {
@@ -247,12 +256,13 @@ bool DefaultEvictionAdvisor::shouldEvict(const LiveInterval &A, bool IsHint,
   if (FreqRatio < 1.0f / MinUseDefFreqRatioToIgnoreSize)
     return false;
   // use-def frequencies are comparable. Evict B only if
-  // its size is much larger, so eviction can provide some register pressure relief.
+  // its size is much larger, so eviction can provide some register pressure
+  // relief.
   int ASize = A.getSize();
   int BSize = B.getSize();
   if (BSize == 0)
     return false;
-  if ((float) ASize / (float) BSize < MinSizeRatioNeededToEvict)
+  if ((float)ASize / (float)BSize < MinSizeRatioNeededToEvict)
     return true;
   return false;
 }
@@ -346,7 +356,8 @@ bool DefaultEvictionAdvisor::canEvictInterferenceBasedOnCost(
       // Apply the eviction policy for non-urgent evictions.
       if (!shouldEvict(VirtReg, IsHint, *Intf, BreaksHint))
         return false;
-      LLVM_DEBUG(dbgs() << "should evict: " << *Intf << " w= " << Intf->weight() << '\n');
+      LLVM_DEBUG(dbgs() << "should evict: " << *Intf << " w= " << Intf->weight()
+                        << '\n');
 
       // If !MaxCost.isMax(), then we're just looking for a cheap register.
       // Evicting another local live range in this case could lead to suboptimal
diff --git a/llvm/test/CodeGen/RISCV/min-weight-ratio.mir b/llvm/test/CodeGen/RISCV/min-weight-ratio.mir
deleted file mode 100644
index d3813dcb1a5e3..0000000000000
--- a/llvm/test/CodeGen/RISCV/min-weight-ratio.mir
+++ /dev/null
@@ -1,72 +0,0 @@
-# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 5
-# RUN: llc %s -mtriple=riscv64 -run-pass=greedy,virtregrewriter \
-# RUN: -min-weight-ratio-needed-to-evict-hint=7.5 -o - | FileCheck %s
-
-# Due to the minimum weight heuristic (see the explanation of `MinWeightRatioNeededToEvictHint`) we are able to get rid of ALL the copies in the code below. When heuristic is disabled (`-min-weight-ratio-needed-to-evict-hint=1.0`) we end up with 3 copies.
-
---- |
-  define i64 @caller(i64 %x) {
-  entry:
-    %add_ = add i64 %x, 1
-    call void @foo()
-    ret i64 %add_
-  }
-
-  declare void @foo()
-
-...
----
-name:            caller
-alignment:       2
-tracksRegLiveness: true
-body:             |
-  bb.0.entry:
-    liveins: $x10, $x1, $x8, $x9, $x18, $x19, $x20, $x21, $x22, $x23, $x24, $x25, $x26, $x27
-
-    ; CHECK-LABEL: name: caller
-    ; CHECK: liveins: $x1, $x8, $x9, $x10, $x18, $x19, $x20, $x21, $x22, $x23, $x24, $x25, $x26, $x27
-    ; CHECK-NEXT: {{  $}}
-    ; CHECK-NEXT: SD $x1, %stack.0, 0 :: (store (s64) into %stack.0)
-    ; CHECK-NEXT: renamable $x10 = ADDI killed renamable $x10, 1
-    ; CHECK-NEXT: SD killed renamable $x10, %stack.1, 0 :: (store (s64) into %stack.1)
-    ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def dead $x2, implicit $x2
-    ; CHECK-NEXT: PseudoCALL target-flags(riscv-call) @foo, csr_ilp32d_lp64d, implicit-def dead $x1, implicit-def $x2
-    ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def dead $x2, implicit $x2
-    ; CHECK-NEXT: $x10 = LD %stack.1, 0 :: (load (s64) from %stack.1)
-    ; CHECK-NEXT: $x1 = LD %stack.0, 0 :: (load (s64) from %stack.0)
-    ; CHECK-NEXT: PseudoRET implicit $x10, implicit $x1, implicit $x8, implicit $x9, implicit $x18, implicit $x19, implicit $x20, implicit $x21, implicit $x22, implicit $x23, implicit $x24, implicit $x25, implicit $x26, implicit $x27
-    %14:gpr = COPY $x27
-    %13:gpr = COPY $x26
-    %12:gpr = COPY $x25
-    %11:gpr = COPY $x24
-    %10:gpr = COPY $x23
-    %9:gpr = COPY $x22
-    %8:gpr = COPY $x21
-    %7:gpr = COPY $x20
-    %6:gpr = COPY $x19
-    %5:gpr = COPY $x18
-    %4:gprc_and_sr07 = COPY $x9
-    %3:gprc_and_sr07 = COPY $x8
-    %2:gpr = COPY $x1
-    %0:gpr = COPY $x10
-    %1:gpr = ADDI %0, 1
-    ADJCALLSTACKDOWN 0, 0, implicit-def dead $x2, implicit $x2
-    PseudoCALL target-flags(riscv-call) @foo, csr_ilp32d_lp64d, implicit-def dead $x1, implicit-def $x2
-    ADJCALLSTACKUP 0, 0, implicit-def dead $x2, implicit $x2
-    $x10 = COPY %1
-    $x1 = COPY %2
-    $x8 = COPY %3
-    $x9 = COPY %4
-    $x18 = COPY %5
-    $x19 = COPY %6
-    $x20 = COPY %7
-    $x21 = COPY %8
-    $x22 = COPY %9
-    $x23 = COPY %10
-    $x24 = COPY %11
-    $x25 = COPY %12
-    $x26 = COPY %13
-    $x27 = COPY %14
-    PseudoRET implicit $x10, implicit $x1, implicit $x8, implicit $x9, implicit $x18, implicit $x19, implicit $x20, implicit $x21, implicit $x22, implicit $x23, implicit $x24, implicit $x25, implicit $x26, implicit $x27
-
-...

>From 42d9d8a862126d7ff795d4b1bf8e310d11479042 Mon Sep 17 00:00:00 2001
From: Mikhail Gudim <mgudim at qti.qualcomm.com>
Date: Thu, 4 Jun 2026 09:10:55 -0700
Subject: [PATCH 5/5] Only enable the new heuristic if the flag is passed.

This avoids modifying many codegen tests.
---
 llvm/lib/CodeGen/RegAllocEvictionAdvisor.cpp | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/llvm/lib/CodeGen/RegAllocEvictionAdvisor.cpp b/llvm/lib/CodeGen/RegAllocEvictionAdvisor.cpp
index 3879d802672a1..147b76c5f7b4c 100644
--- a/llvm/lib/CodeGen/RegAllocEvictionAdvisor.cpp
+++ b/llvm/lib/CodeGen/RegAllocEvictionAdvisor.cpp
@@ -46,6 +46,11 @@ static cl::opt<bool> EnableLocalReassignment(
              "may be compile time intensive"),
     cl::init(false));
 
+static cl::opt<bool> EvictBasedOnSimpleWeightComp(
+    "evict-based-on-simple-weight-comp", cl::Hidden,
+    cl::desc("Make eviction decisions based on simple weight comparisson"),
+    cl::init(true));
+
 static cl::opt<float> MinUseDefFreqRatioToIgnoreSize(
     "min-use-def-freq-ratio-to-ignore-size", cl::Hidden,
     cl::desc(
@@ -245,6 +250,13 @@ bool DefaultEvictionAdvisor::shouldEvict(const LiveInterval &A, bool IsHint,
   if (CanSplit && IsHint && !BreaksHint)
     return true;
 
+  if (EvictBasedOnSimpleWeightComp) {
+    if (A.weight() > B.weight()) {
+      return true;
+    }
+    return false;
+  }
+
   const unsigned SizeOffset = 25 * SlotIndex::InstrDist;
   float AUseDefFreq = A.weight() * (A.getSize() + SizeOffset);
   float BUseDefFreq = B.weight() * (B.getSize() + SizeOffset);



More information about the llvm-commits mailing list