[llvm] Regalloc: Add operator >= to EvictionCost (PR #160070)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 22 03:50:52 PDT 2025


https://github.com/arsenm created https://github.com/llvm/llvm-project/pull/160070

Make the actual use context less ugly.

>From 27759036f55483532df3370074a1fcd2714e65e7 Mon Sep 17 00:00:00 2001
From: Matt Arsenault <Matthew.Arsenault at amd.com>
Date: Mon, 22 Sep 2025 19:49:20 +0900
Subject: [PATCH] Regalloc: Add operator >= to EvictionCost

Make the actual use context less ugly.
---
 llvm/include/llvm/CodeGen/RegAllocEvictionAdvisor.h | 2 ++
 llvm/lib/CodeGen/RegAllocEvictionAdvisor.cpp        | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/llvm/include/llvm/CodeGen/RegAllocEvictionAdvisor.h b/llvm/include/llvm/CodeGen/RegAllocEvictionAdvisor.h
index e4f0932c3edc8..1020c5f97dd31 100644
--- a/llvm/include/llvm/CodeGen/RegAllocEvictionAdvisor.h
+++ b/llvm/include/llvm/CodeGen/RegAllocEvictionAdvisor.h
@@ -91,6 +91,8 @@ struct EvictionCost {
     return std::tie(BrokenHints, MaxWeight) <
            std::tie(O.BrokenHints, O.MaxWeight);
   }
+
+  bool operator>=(const EvictionCost &O) const { return !(*this < O); }
 };
 
 /// Interface to the eviction advisor, which is responsible for making a
diff --git a/llvm/lib/CodeGen/RegAllocEvictionAdvisor.cpp b/llvm/lib/CodeGen/RegAllocEvictionAdvisor.cpp
index 9b23a6aac629a..0d44ddc428570 100644
--- a/llvm/lib/CodeGen/RegAllocEvictionAdvisor.cpp
+++ b/llvm/lib/CodeGen/RegAllocEvictionAdvisor.cpp
@@ -308,7 +308,7 @@ bool DefaultEvictionAdvisor::canEvictInterferenceBasedOnCost(
       Cost.BrokenHints += BreaksHint;
       Cost.MaxWeight = std::max(Cost.MaxWeight, Intf->weight());
       // Abort if this would be too expensive.
-      if (!(Cost < MaxCost))
+      if (Cost >= MaxCost)
         return false;
       if (Urgent)
         continue;



More information about the llvm-commits mailing list