Fix a compile-time regression introduced by my heuristic-changing patch. I forgot
authorOwen Anderson <resistor@mac.com>
Wed, 23 Jul 2008 19:47:27 +0000 (19:47 +0000)
committerOwen Anderson <resistor@mac.com>
Wed, 23 Jul 2008 19:47:27 +0000 (19:47 +0000)
to multiply the instruction count by a constant factor in a few places, which
caused the register allocator to require many more iterations.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53959 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/LiveIntervalAnalysis.cpp
lib/CodeGen/RegAllocLinearScan.cpp
lib/CodeGen/SimpleRegisterCoalescing.cpp
lib/CodeGen/SimpleRegisterCoalescing.h

index 295a1615b69d3c59a1683eba1a71900227ecd4dc..5e0a075a55552850ea2badb1f485b61144bf15e1 100644 (file)
@@ -1793,7 +1793,7 @@ addIntervalsForSpills(const LiveInterval &li,
   for (unsigned i = 0, e = NewLIs.size(); i != e; ++i) {
     LiveInterval *LI = NewLIs[i];
     if (!LI->empty()) {
-      LI->weight /= getApproximateInstructionCount(*LI);
+      LI->weight /= InstrSlots::NUM * getApproximateInstructionCount(*LI);
       if (!AddedKill.count(LI)) {
         LiveRange *LR = &LI->ranges[LI->ranges.size()-1];
         unsigned LastUseIdx = getBaseIndex(LR->end);
index 4df172d40c7f61abb3b7fb75fbb36de85fd24d5f..ad830b25352bf3f4639ff10e325b66230f874401 100644 (file)
@@ -852,7 +852,7 @@ void RALinScan::assignRegOrStackSlotAtInterval(LiveInterval* cur)
     // All registers must have inf weight. Just grab one!
     minReg = BestPhysReg ? BestPhysReg : *RC->allocation_order_begin(*mf_);
     if (cur->weight == HUGE_VALF ||
-        li_->getApproximateInstructionCount(*cur) == 1)
+        li_->getApproximateInstructionCount(*cur) == 0)
       // Spill a physical register around defs and uses.
       li_->spillPhysRegAroundRegDefsUses(*cur, minReg, *vrm_);
   }
index 29e634b477d16db1fa211ebfe2199cfc79c1da97..68be3e111fb209d125fe5034bfe9483751709acc 100644 (file)
@@ -2196,7 +2196,7 @@ bool SimpleRegisterCoalescing::runOnMachineFunction(MachineFunction &fn) {
       // Divide the weight of the interval by its size.  This encourages 
       // spilling of intervals that are large and have few uses, and
       // discourages spilling of small intervals with many uses.
-      LI.weight /= li_->getApproximateInstructionCount(LI);
+      LI.weight /= li_->getApproximateInstructionCount(LI) * InstrSlots::NUM;
     }
   }
 
index de16fa15356a8e89fd4cb6b4b3a4272d56326f69..bb21515a3546e1406ed39964138e8ee689d682e7 100644 (file)
@@ -126,7 +126,8 @@ namespace llvm {
     unsigned getRepIntervalSize(unsigned Reg) {
       if (!li_->hasInterval(Reg))
         return 0;
-      return li_->getApproximateInstructionCount(li_->getInterval(Reg));
+      return li_->getApproximateInstructionCount(li_->getInterval(Reg)) *
+             LiveIntervals::InstrSlots::NUM;
     }
 
     /// print - Implement the dump method.