From 1cabe54fab4a3cc0d2752bd3cf4fffde8be1883e Mon Sep 17 00:00:00 2001 From: Andrew Trick Date: Sat, 23 Jul 2011 00:33:05 +0000 Subject: Move trip count discovery outside of the generic LoopUnroll helper. This removes its dependence on canonical induction variables. llvm-svn: 135829 --- llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp') diff --git a/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp b/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp index 38259f0f249..6d7901f88c6 100644 --- a/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp +++ b/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp @@ -137,9 +137,14 @@ bool LoopUnroll::runOnLoop(Loop *L, LPPassManager &LPM) { // Find trip count unsigned TripCount = L->getSmallConstantTripCount(); - unsigned Count = CurrentCount; + + // Find trip multiple if count is not available + unsigned TripMultiple = 1; + if (TripCount == 0) + TripMultiple = L->getSmallConstantTripMultiple(); // Automatically select an unroll count. + unsigned Count = CurrentCount; if (Count == 0) { // Conservative heuristic: if we know the trip count, see if we can // completely unroll (subject to the threshold, checked below); otherwise @@ -183,7 +188,7 @@ bool LoopUnroll::runOnLoop(Loop *L, LPPassManager &LPM) { // Unroll the loop. Function *F = L->getHeader()->getParent(); - if (!UnrollLoop(L, Count, LI, &LPM)) + if (!UnrollLoop(L, Count, TripCount, TripMultiple, LI, &LPM)) return false; // FIXME: Reconstruct dom info, because it is not preserved properly. -- cgit v1.2.3