[llvm] 706b790 - Greedy: Merge VirtRegMap queries into one use (NFC) (#160485)

via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 2 07:06:58 PDT 2025


Author: Matt Arsenault
Date: 2025-10-02T14:06:54Z
New Revision: 706b79002e21b571888db7f275bf5ed00e7cce41

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

LOG: Greedy: Merge VirtRegMap queries into one use (NFC) (#160485)

Added: 
    

Modified: 
    llvm/lib/CodeGen/RegAllocGreedy.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/RegAllocGreedy.cpp b/llvm/lib/CodeGen/RegAllocGreedy.cpp
index 24fe838e4b7d8..f0f313050cf92 100644
--- a/llvm/lib/CodeGen/RegAllocGreedy.cpp
+++ b/llvm/lib/CodeGen/RegAllocGreedy.cpp
@@ -2498,8 +2498,10 @@ void RAGreedy::tryHintRecoloring(const LiveInterval &VirtReg) {
   do {
     Reg = RecoloringCandidates.pop_back_val();
 
+    MCRegister CurrPhys = VRM->getPhys(Reg);
+
     // This may be a skipped register.
-    if (!VRM->hasPhys(Reg)) {
+    if (!CurrPhys) {
       assert(!shouldAllocateRegister(Reg) &&
              "We have an unallocated variable which should have been handled");
       continue;
@@ -2508,7 +2510,6 @@ void RAGreedy::tryHintRecoloring(const LiveInterval &VirtReg) {
     // Get the live interval mapped with this virtual register to be able
     // to check for the interference with the new color.
     LiveInterval &LI = LIS->getInterval(Reg);
-    MCRegister CurrPhys = VRM->getPhys(Reg);
     // Check that the new color matches the register class constraints and
     // that it is free for this live range.
     if (CurrPhys != PhysReg && (!MRI->getRegClass(Reg)->contains(PhysReg) ||


        


More information about the llvm-commits mailing list