aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/LoopUnroll.cpp
diff options
context:
space:
mode:
authorPhilip Reames <listmail@philipreames.com>2021-06-03 14:14:59 -0700
committerPhilip Reames <listmail@philipreames.com>2021-06-03 14:14:59 -0700
commitcddcc4cff5052bc8a2311fea83f54b0caa1cbb4c (patch)
treed81694c051af94116fa2a5794c5c01b499412d9f /llvm/lib/Transforms/Utils/LoopUnroll.cpp
parent5c0d1b2f902aa6a9cf47cc7e42c5b83bb2217cf9 (diff)
downloadllvm-cddcc4cff5052bc8a2311fea83f54b0caa1cbb4c.zip
llvm-cddcc4cff5052bc8a2311fea83f54b0caa1cbb4c.tar.gz
llvm-cddcc4cff5052bc8a2311fea83f54b0caa1cbb4c.tar.bz2
A couple style tweaks on top of 5c0d1b2f9 [nfc]
Diffstat (limited to 'llvm/lib/Transforms/Utils/LoopUnroll.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/LoopUnroll.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Utils/LoopUnroll.cpp b/llvm/lib/Transforms/Utils/LoopUnroll.cpp
index fa0a514..76036dc 100644
--- a/llvm/lib/Transforms/Utils/LoopUnroll.cpp
+++ b/llvm/lib/Transforms/Utils/LoopUnroll.cpp
@@ -411,6 +411,10 @@ LoopUnrollResult llvm::UnrollLoop(Loop *L, UnrollLoopOptions ULO, LoopInfo *LI,
dbgs() << " No single exiting block\n";
});
+ // Warning: ExactTripCount is the exact trip count for the block ending in
+ // ExitingBI, not neccessarily an exact exit count *for the loop*. The
+ // distinction comes when we have an exiting latch, but the loop exits
+ // through another exit first.
const unsigned ExactTripCount = ExitingBI ?
SE->getSmallConstantTripCount(L,ExitingBI->getParent()) : 0;
const bool ExactUnroll = (ExactTripCount && ExactTripCount == ULO.Count);
@@ -762,13 +766,13 @@ LoopUnrollResult llvm::UnrollLoop(Loop *L, UnrollLoopOptions ULO, LoopInfo *LI,
return None;
return j == 0;
}
- if (ExactUnroll)
- return j == 0;
- // Full, but non-exact unrolling
+ // Complete (but possibly inexact) unrolling
if (j == 0)
return true;
if (MaxTripCount && j >= MaxTripCount)
return false;
+ // Warning: ExactTripCount is the trip count of the exiting
+ // block which ends in ExitingBI, not neccessarily the loop.
if (ExactTripCount && j != ExactTripCount)
return false;
return None;