aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp
diff options
context:
space:
mode:
authorJin Lin <net_linjin@yahoo.com>2018-04-19 20:29:43 +0000
committerJin Lin <net_linjin@yahoo.com>2018-04-19 20:29:43 +0000
commit585f2699cf5bbbb57d71337825b1137a6907cf3f (patch)
treea26607c84344dda49489cfdf0754a07a4daa6eb4 /llvm/lib/Transforms/Utils/LoopRotationUtils.cpp
parentfa322abee96dc3b1130a4b3218ad36886372276d (diff)
downloadllvm-585f2699cf5bbbb57d71337825b1137a6907cf3f.zip
llvm-585f2699cf5bbbb57d71337825b1137a6907cf3f.tar.gz
llvm-585f2699cf5bbbb57d71337825b1137a6907cf3f.tar.bz2
Refine the loop rotation's API
Summary: The following changes addresses the following two issues. 1) The existing loop rotation pass contains both loop latch simplification and loop rotation. So one flag RotationOnly is added to be passed to the loop rotation pass. 2) The threshold value is initialized with MAX_UINT since the loop rotation utility should not have threshold limit. Reviewers: dmgreen, efriedma Reviewed By: efriedma Differential Revision: https://reviews.llvm.org/D45582 llvm-svn: 330362
Diffstat (limited to 'llvm/lib/Transforms/Utils/LoopRotationUtils.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/LoopRotationUtils.cpp26
1 files changed, 17 insertions, 9 deletions
diff --git a/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp b/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp
index 529a0ec..d96c101 100644
--- a/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp
+++ b/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp
@@ -54,13 +54,16 @@ class LoopRotate {
DominatorTree *DT;
ScalarEvolution *SE;
const SimplifyQuery &SQ;
+ bool RotationOnly;
+ bool IsUtilMode;
public:
LoopRotate(unsigned MaxHeaderSize, LoopInfo *LI,
const TargetTransformInfo *TTI, AssumptionCache *AC,
- DominatorTree *DT, ScalarEvolution *SE, const SimplifyQuery &SQ)
+ DominatorTree *DT, ScalarEvolution *SE, const SimplifyQuery &SQ,
+ bool RotationOnly, bool IsUtilMode)
: MaxHeaderSize(MaxHeaderSize), LI(LI), TTI(TTI), AC(AC), DT(DT), SE(SE),
- SQ(SQ) {}
+ SQ(SQ), RotationOnly(RotationOnly), IsUtilMode(IsUtilMode) {}
bool processLoop(Loop *L);
private:
@@ -219,7 +222,7 @@ bool LoopRotate::rotateLoop(Loop *L, bool SimplifiedLatch) {
// Rotate if either the loop latch does *not* exit the loop, or if the loop
// latch was just simplified. Or if we think it will be profitable.
- if (L->isLoopExiting(OrigLatch) && !SimplifiedLatch &&
+ if (L->isLoopExiting(OrigLatch) && !SimplifiedLatch && IsUtilMode == false &&
!shouldRotateLoopExitingLatch(L))
return false;
@@ -604,10 +607,13 @@ bool LoopRotate::processLoop(Loop *L) {
// Save the loop metadata.
MDNode *LoopMD = L->getLoopID();
+ bool SimplifiedLatch = false;
+
// Simplify the loop latch before attempting to rotate the header
// upward. Rotation may not be needed if the loop tail can be folded into the
// loop exit.
- bool SimplifiedLatch = simplifyLoopLatch(L);
+ if (!RotationOnly)
+ SimplifiedLatch = simplifyLoopLatch(L);
bool MadeChange = rotateLoop(L, SimplifiedLatch);
assert((!MadeChange || L->isLoopExiting(L->getLoopLatch())) &&
@@ -623,11 +629,13 @@ bool LoopRotate::processLoop(Loop *L) {
/// The utility to convert a loop into a loop with bottom test.
-bool llvm::LoopRotation(Loop *L, unsigned MaxHeaderSize, LoopInfo *LI,
- const TargetTransformInfo *TTI, AssumptionCache *AC,
- DominatorTree *DT, ScalarEvolution *SE,
- const SimplifyQuery &SQ) {
- LoopRotate LR(MaxHeaderSize, LI, TTI, AC, DT, SE, SQ);
+bool llvm::LoopRotation(Loop *L, LoopInfo *LI, const TargetTransformInfo *TTI,
+ AssumptionCache *AC, DominatorTree *DT,
+ ScalarEvolution *SE, const SimplifyQuery &SQ,
+ bool RotationOnly = true,
+ unsigned Threshold = unsigned(-1),
+ bool IsUtilMode = true) {
+ LoopRotate LR(Threshold, LI, TTI, AC, DT, SE, SQ, RotationOnly, IsUtilMode);
return LR.processLoop(L);
}