[PATCH] D54365: RegAllocFast: Remove early selection loop, the spill calculation will report cost 0 anyway for free regs

Matthias Braun via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 9 16:31:24 PST 2018


MatzeB created this revision.
MatzeB added reviewers: qcolombet, wmi, kparzysz, myatsina, javed.absar, arsenm.
Herald added subscribers: wdng, mcrosier.

The 2nd loop calculates spill costs but reports free registers as cost 0 anyway, so there is little benefit from having a separate early loop.

SUrprisingly this is not NFC, as many register are marked regDisabled so the first loop often picks up later registers unnecessarily instead of the first one available in the allocation order...


Repository:
  rL LLVM

https://reviews.llvm.org/D54365

Files:
  lib/CodeGen/RegAllocFast.cpp


Index: lib/CodeGen/RegAllocFast.cpp
===================================================================
--- lib/CodeGen/RegAllocFast.cpp
+++ lib/CodeGen/RegAllocFast.cpp
@@ -583,17 +583,9 @@
     }
   }
 
-  // First try to find a completely free register.
-  ArrayRef<MCPhysReg> AllocationOrder = RegClassInfo.getOrder(&RC);
-  for (MCPhysReg PhysReg : AllocationOrder) {
-    if (PhysRegState[PhysReg] == regFree && !isRegUsedInInstr(PhysReg)) {
-      assignVirtToPhysReg(LR, PhysReg);
-      return;
-    }
-  }
-
   MCPhysReg BestReg = 0;
   unsigned BestCost = spillImpossible;
+  ArrayRef<MCPhysReg> AllocationOrder = RegClassInfo.getOrder(&RC);
   for (MCPhysReg PhysReg : AllocationOrder) {
     LLVM_DEBUG(dbgs() << "\tRegister: " << printReg(PhysReg, TRI) << ' ');
     unsigned Cost = calcSpillCost(PhysReg);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54365.173470.patch
Type: text/x-patch
Size: 821 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181110/cb8dec55/attachment.bin>


More information about the llvm-commits mailing list