aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2010-09-27 22:58:54 +0000
committerOwen Anderson <resistor@mac.com>2010-09-27 22:58:54 +0000
commitd214609466113d31d76d5addb0f151eb7eab2ea9 (patch)
treecd69e9d89ed4c8207c8c739f902f4925eb3912d8 /lib/Transforms
parent9f9d21646c876bcc3ca886a9b2b917d4cc4da4ad (diff)
downloadexternal_llvm-d214609466113d31d76d5addb0f151eb7eab2ea9.zip
external_llvm-d214609466113d31d76d5addb0f151eb7eab2ea9.tar.gz
external_llvm-d214609466113d31d76d5addb0f151eb7eab2ea9.tar.bz2
Weight loop unrolling counts by nesting depth. Unrolling deeply nested loops tends to cause high
register pressure and thus excess spills, which we don't currently recover from well. This should be re-evaluated in the future if our ability to generate good spills/splits improves. Partial fix for <rdar://problem/7635585>. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@114919 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r--lib/Transforms/Scalar/LoopUnrollPass.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/Transforms/Scalar/LoopUnrollPass.cpp b/lib/Transforms/Scalar/LoopUnrollPass.cpp
index 7da2b52..99a38b1 100644
--- a/lib/Transforms/Scalar/LoopUnrollPass.cpp
+++ b/lib/Transforms/Scalar/LoopUnrollPass.cpp
@@ -158,7 +158,12 @@ bool LoopUnroll::runOnLoop(Loop *L, LPPassManager &LPM) {
DEBUG(dbgs() << " Not unrolling loop with inlinable calls.\n");
return false;
}
- uint64_t Size = (uint64_t)LoopSize*Count;
+
+ // NOTE: We multiply by the loop depth because unrolling inner loops of
+ // very deep nests tends to result in high register pressure, which we don't
+ // currently recover from very well. When and if the register allocator/
+ // spiller improves to compensate, this should be re-evaluated.
+ uint64_t Size = (uint64_t)LoopSize*Count*L->getLoopDepth();
if (TripCount != 1 && Size > CurrentThreshold) {
DEBUG(dbgs() << " Too large to fully unroll with count: " << Count
<< " because size: " << Size << ">" << CurrentThreshold << "\n");