aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp
diff options
context:
space:
mode:
authorPhilip Reames <listmail@philipreames.com>2021-06-03 14:03:21 -0700
committerPhilip Reames <listmail@philipreames.com>2021-06-03 14:09:16 -0700
commit5c0d1b2f902aa6a9cf47cc7e42c5b83bb2217cf9 (patch)
treee6dbf11aab64ae51210b67eb4d9a69f00dd1b49c /llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp
parentf8f7002828ec66cd6261d3e00312e9b1f4b59b79 (diff)
downloadllvm-5c0d1b2f902aa6a9cf47cc7e42c5b83bb2217cf9.zip
llvm-5c0d1b2f902aa6a9cf47cc7e42c5b83bb2217cf9.tar.gz
llvm-5c0d1b2f902aa6a9cf47cc7e42c5b83bb2217cf9.tar.bz2
[LoopUnroll] Eliminate PreserveCondBr parameter and fix a bug in the process
This builds on D103584. The change eliminates the coupling between unroll heuristic and implementation w.r.t. knowing when the passed in trip count is an exact trip count or a max trip count. In theory the new code is slightly less powerful (since it relies on exact computable trip counts), but in practice, it appears to cover all the same cases. It can also be extended if needed. The test change shows what appears to be a bug in the existing code around the interaction of peeling and unrolling. The original loop only ran 8 iterations. The previous output had the loop peeled by 2, and then an exact unroll of 8. This meant the loop ran a total of 10 iterations which appears to have been a miscompile. Differential Revision: https://reviews.llvm.org/D103620
Diffstat (limited to 'llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp3
1 files changed, 1 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp b/llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp
index cc85fb6..767b072 100644
--- a/llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp
+++ b/llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp
@@ -986,8 +986,7 @@ bool llvm::UnrollRuntimeLoopRemainder(
UnrollLoop(remainderLoop,
{/*Count*/ Count - 1, /*TripCount*/ Count - 1,
/*Force*/ false, /*AllowRuntime*/ false,
- /*AllowExpensiveTripCount*/ false, /*PreserveCondBr*/ true,
- /*TripMultiple*/ 1,
+ /*AllowExpensiveTripCount*/ false, /*TripMultiple*/ 1,
/*PeelCount*/ 0, /*UnrollRemainder*/ false, ForgetAllSCEV},
LI, SE, DT, AC, TTI, /*ORE*/ nullptr, PreserveLCSSA);
}