diff options
| author | Zia Ansari <zia.ansari@intel.com> | 2016-04-04 19:24:46 +0000 |
|---|---|---|
| committer | Zia Ansari <zia.ansari@intel.com> | 2016-04-04 19:24:46 +0000 |
| commit | a82a58a4e54a5233d90d08c7e78e94282d74c3f0 (patch) | |
| tree | c25883a205f93fb1f0da474a89949e290cb1680f /llvm/lib/Transforms | |
| parent | 28ed95f45e3b2ddb3d4d4501269791972a2b9767 (diff) | |
| download | bcm5719-llvm-a82a58a4e54a5233d90d08c7e78e94282d74c3f0.tar.gz bcm5719-llvm-a82a58a4e54a5233d90d08c7e78e94282d74c3f0.zip | |
Enable unroll for constant bound loops when TripCount is not modulo of unroll factor, reducing it to maximum power-of-2 that satisfies threshold limit.
Commit for Evgeny Stupachenko (evstupac@gmail.com)
Differential Revision: http://reviews.llvm.org/D18290
llvm-svn: 265337
Diffstat (limited to 'llvm/lib/Transforms')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp b/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp index c3761dcf4e8..fa6214f89f0 100644 --- a/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp +++ b/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp @@ -639,6 +639,16 @@ static bool tryToUnrollLoop(Loop *L, DominatorTree &DT, LoopInfo *LI, Count = (std::max(UP.PartialThreshold, 3u) - 2) / (LoopSize - 2); while (Count != 0 && TripCount % Count != 0) Count--; + if (Count <= 1) { + // If there is no Count that is modulo of TripCount, set Count to + // largest power-of-two factor that satisfies the threshold limit. + Count = (std::max(UP.PartialThreshold, 3u) - 2) / (LoopSize - 2); + UnrolledSize = (LoopSize - 2) * Count + 2; + while (Count != 0 && UnrolledSize > UP.PartialThreshold) { + Count >>= 1; + UnrolledSize = (LoopSize - 2) * Count + 2; + } + } } } else if (Unrolling == Runtime) { if (!AllowRuntime && !CountSetExplicitly) { |

