summaryrefslogtreecommitdiff
path: root/lib/Transforms/Scalar/LoopUnrollPass.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Transforms/Scalar/LoopUnrollPass.cpp')
-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 7da2b52da5..99a38b1ed0 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");