diff options
author | Owen Anderson <resistor@mac.com> | 2010-09-08 23:10:07 +0000 |
---|---|---|
committer | Owen Anderson <resistor@mac.com> | 2010-09-08 23:10:07 +0000 |
commit | 4975447d94bc5a3fcfdd3fd530e77163d4dab11e (patch) | |
tree | 302d6650be2016088a5da0518a2b319d7c973ac5 /lib/Transforms/Scalar/LoopUnrollPass.cpp | |
parent | a88d8577e696e35bf72bbc2e5ab1f7e2002b8cc4 (diff) |
Relax the "don't unroll loops containing calls" rule. Instead, when a loop contains a call, lower the
unrolling threshold to the optimize-for-size threshold. Basically, for loops containing calls, unrolling
can still be profitable as long as the loop is REALLY small.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@113439 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/LoopUnrollPass.cpp')
-rw-r--r-- | lib/Transforms/Scalar/LoopUnrollPass.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/Transforms/Scalar/LoopUnrollPass.cpp b/lib/Transforms/Scalar/LoopUnrollPass.cpp index f20f7dc5d6..f0a661cb69 100644 --- a/lib/Transforms/Scalar/LoopUnrollPass.cpp +++ b/lib/Transforms/Scalar/LoopUnrollPass.cpp @@ -132,8 +132,10 @@ bool LoopUnroll::runOnLoop(Loop *L, LPPassManager &LPM) { unsigned LoopSize = ApproximateLoopSize(L, NumCalls); DEBUG(dbgs() << " Loop Size = " << LoopSize << "\n"); if (NumCalls != 0) { - DEBUG(dbgs() << " Not unrolling loop with function calls.\n"); - return false; + // Even for a loop that contains calls, it can still be profitable to + // unroll if the loop is really, REALLY small. + DEBUG(dbgs() <<" Using lower threshold for loop with function calls.\n"); + CurrentThreshold = OptSizeUnrollThreshold; } uint64_t Size = (uint64_t)LoopSize*Count; if (TripCount != 1 && Size > CurrentThreshold) { |