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

via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 22 04:25:38 PDT 2025


Author: Matt Arsenault
Date: 2025-09-22T20:25:34+09:00
New Revision: c077822b5213fb4329ea3a6e70373fbbebcd3f71

URL: https://github.com/llvm/llvm-project/commit/c077822b5213fb4329ea3a6e70373fbbebcd3f71
DIFF: https://github.com/llvm/llvm-project/commit/c077822b5213fb4329ea3a6e70373fbbebcd3f71.diff

LOG: Regalloc: Add operator >= to EvictionCost (#160070)

Make the actual use context less ugly.

Added: 
    

Modified: 
    llvm/include/llvm/CodeGen/RegAllocEvictionAdvisor.h
    llvm/lib/CodeGen/RegAllocEvictionAdvisor.cpp

Removed: 
    


################################################################################
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