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 | 8084dbaf8e32b41f306adcdfba3e4c2a8c05f056 (patch) | |
tree | 5be906c777c01937a7f9b86169dc266ee4431e99 /llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp | |
parent | 311adf3d5b1789ac159b4545eb1bbae7fd37e030 (diff) | |
download | bcm5719-llvm-8084dbaf8e32b41f306adcdfba3e4c2a8c05f056.tar.gz bcm5719-llvm-8084dbaf8e32b41f306adcdfba3e4c2a8c05f056.zip |
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.
llvm-svn: 113439
Diffstat (limited to 'llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp')
-rw-r--r-- | llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp b/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp index f20f7dc5d6d..f0a661cb699 100644 --- a/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp +++ b/llvm/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) { |