summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorJakob Stoklund Olesen <stoklund@2pi.dk>2010-02-18 21:33:05 +0000
committerJakob Stoklund Olesen <stoklund@2pi.dk>2010-02-18 21:33:05 +0000
commitc953acbd7f611dbbdcbdf8d1b98db9834ae8dfd6 (patch)
treef17a6a2dd2641986d73e1c5668dae8f9f1ec1502 /llvm/lib
parent334ce7c1c4075fc3579ab1e3b9e76296b0da53ed (diff)
downloadbcm5719-llvm-c953acbd7f611dbbdcbdf8d1b98db9834ae8dfd6.tar.gz
bcm5719-llvm-c953acbd7f611dbbdcbdf8d1b98db9834ae8dfd6.zip
Always normalize spill weights, also for intervals created by spilling.
Moderate the weight given to very small intervals. The spill weight given to new intervals created when spilling was not normalized in the same way as the original spill weights calculated by CalcSpillWeights. That meant that restored registers would tend to hang around because they had a much higher spill weight that unspilled registers. This improves the runtime of a few tests by up to 10%, and there are no significant regressions. llvm-svn: 96613
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/CodeGen/CalcSpillWeights.cpp5
-rw-r--r--llvm/lib/CodeGen/LiveIntervalAnalysis.cpp9
2 files changed, 10 insertions, 4 deletions
diff --git a/llvm/lib/CodeGen/CalcSpillWeights.cpp b/llvm/lib/CodeGen/CalcSpillWeights.cpp
index 2bedd042434..a328d0e556e 100644
--- a/llvm/lib/CodeGen/CalcSpillWeights.cpp
+++ b/llvm/lib/CodeGen/CalcSpillWeights.cpp
@@ -131,10 +131,7 @@ bool CalculateSpillWeights::runOnMachineFunction(MachineFunction &fn) {
if (Hint.first || Hint.second)
li.weight *= 1.01F;
- // 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 /= lis->getApproximateInstructionCount(li) * SlotIndex::NUM;
+ lis->normalizeSpillWeight(li);
}
}
diff --git a/llvm/lib/CodeGen/LiveIntervalAnalysis.cpp b/llvm/lib/CodeGen/LiveIntervalAnalysis.cpp
index f6bf4339403..0b38ffb9703 100644
--- a/llvm/lib/CodeGen/LiveIntervalAnalysis.cpp
+++ b/llvm/lib/CodeGen/LiveIntervalAnalysis.cpp
@@ -1562,6 +1562,12 @@ LiveIntervals::handleSpilledImpDefs(const LiveInterval &li, VirtRegMap &vrm,
}
}
+void
+LiveIntervals::normalizeSpillWeights(std::vector<LiveInterval*> &NewLIs) {
+ for (unsigned i = 0, e = NewLIs.size(); i != e; ++i)
+ normalizeSpillWeight(*NewLIs[i]);
+}
+
std::vector<LiveInterval*> LiveIntervals::
addIntervalsForSpillsFast(const LiveInterval &li,
const MachineLoopInfo *loopInfo,
@@ -1739,6 +1745,7 @@ addIntervalsForSpills(const LiveInterval &li,
}
handleSpilledImpDefs(li, vrm, rc, NewLIs);
+ normalizeSpillWeights(NewLIs);
return NewLIs;
}
@@ -1814,6 +1821,7 @@ addIntervalsForSpills(const LiveInterval &li,
// Insert spills / restores if we are splitting.
if (!TrySplit) {
handleSpilledImpDefs(li, vrm, rc, NewLIs);
+ normalizeSpillWeights(NewLIs);
return NewLIs;
}
@@ -1973,6 +1981,7 @@ addIntervalsForSpills(const LiveInterval &li,
}
handleSpilledImpDefs(li, vrm, rc, RetNewLIs);
+ normalizeSpillWeights(RetNewLIs);
return RetNewLIs;
}
OpenPOWER on IntegriCloud