[llvm] 61368c8 - Rename LoopInfo::isRotated() to LoopInfo::isRotatedForm().
Kit Barton via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 12 11:23:16 PST 2019
Author: Kit Barton
Date: 2019-12-12T14:22:36-05:00
New Revision: 61368c8e98c567fa76d45e8f928306db9d00dde2
URL: https://github.com/llvm/llvm-project/commit/61368c8e98c567fa76d45e8f928306db9d00dde2
DIFF: https://github.com/llvm/llvm-project/commit/61368c8e98c567fa76d45e8f928306db9d00dde2.diff
LOG: Rename LoopInfo::isRotated() to LoopInfo::isRotatedForm().
This patch renames the LoopInfo::isRotated() method to LoopInfo::isRotatedForm()
to make it clear that the method checks whether the loop is in rotated form, not
whether the loop has been rotated by the LoopRotation pass.
Added:
Modified:
llvm/include/llvm/Analysis/LoopInfo.h
llvm/lib/Analysis/LoopInfo.cpp
llvm/unittests/Analysis/LoopInfoTest.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Analysis/LoopInfo.h b/llvm/include/llvm/Analysis/LoopInfo.h
index 5012f68b3eb3..f30320eaddb0 100644
--- a/llvm/include/llvm/Analysis/LoopInfo.h
+++ b/llvm/include/llvm/Analysis/LoopInfo.h
@@ -756,8 +756,12 @@ class Loop : public LoopBase<BasicBlock, Loop> {
/// - guarded by a loop guard branch.
bool isGuarded() const { return (getLoopGuardBranch() != nullptr); }
- /// Return true if the loop is rotated
- bool isRotated() const {
+ /// Return true if the loop is in rotated form.
+ ///
+ /// This does not check if the loop was rotated by loop rotation, instead it
+ /// only checks if the loop is in rotated form (has a valid latch that exists
+ /// the loop).
+ bool isRotatedForm() const {
assert(!isInvalid() && "Loop not in a valid state!");
BasicBlock *Latch = getLoopLatch();
return Latch && isLoopExiting(Latch);
diff --git a/llvm/lib/Analysis/LoopInfo.cpp b/llvm/lib/Analysis/LoopInfo.cpp
index 9a9063b3d4e2..3dc29b40834c 100644
--- a/llvm/lib/Analysis/LoopInfo.cpp
+++ b/llvm/lib/Analysis/LoopInfo.cpp
@@ -370,7 +370,7 @@ BranchInst *Loop::getLoopGuardBranch() const {
"Expecting a loop with valid preheader and latch");
// Loop should be in rotate form.
- if (!isRotated())
+ if (!isRotatedForm())
return nullptr;
// Disallow loops with more than one unique exit block, as we do not verify
diff --git a/llvm/unittests/Analysis/LoopInfoTest.cpp b/llvm/unittests/Analysis/LoopInfoTest.cpp
index 8873684879e6..bb518904e818 100644
--- a/llvm/unittests/Analysis/LoopInfoTest.cpp
+++ b/llvm/unittests/Analysis/LoopInfoTest.cpp
@@ -285,7 +285,7 @@ TEST(LoopInfoTest, CanonicalLoop) {
EXPECT_EQ(L->getInductionVariable(SE)->getName(), "i");
EXPECT_EQ(L->getLoopGuardBranch(), Guard);
EXPECT_TRUE(L->isGuarded());
- EXPECT_TRUE(L->isRotated());
+ EXPECT_TRUE(L->isRotatedForm());
});
}
@@ -344,7 +344,7 @@ TEST(LoopInfoTest, LoopWithInverseGuardSuccs) {
EXPECT_EQ(L->getInductionVariable(SE)->getName(), "i");
EXPECT_EQ(L->getLoopGuardBranch(), Guard);
EXPECT_TRUE(L->isGuarded());
- EXPECT_TRUE(L->isRotated());
+ EXPECT_TRUE(L->isRotatedForm());
});
}
@@ -403,7 +403,7 @@ TEST(LoopInfoTest, LoopWithSwappedGuardCmp) {
EXPECT_EQ(L->getInductionVariable(SE)->getName(), "i");
EXPECT_EQ(L->getLoopGuardBranch(), Guard);
EXPECT_TRUE(L->isGuarded());
- EXPECT_TRUE(L->isRotated());
+ EXPECT_TRUE(L->isRotatedForm());
});
}
@@ -462,7 +462,7 @@ TEST(LoopInfoTest, LoopWithInverseLatchSuccs) {
EXPECT_EQ(L->getInductionVariable(SE)->getName(), "i");
EXPECT_EQ(L->getLoopGuardBranch(), Guard);
EXPECT_TRUE(L->isGuarded());
- EXPECT_TRUE(L->isRotated());
+ EXPECT_TRUE(L->isRotatedForm());
});
}
@@ -521,7 +521,7 @@ TEST(LoopInfoTest, LoopWithLatchCmpNE) {
EXPECT_EQ(L->getInductionVariable(SE)->getName(), "i");
EXPECT_EQ(L->getLoopGuardBranch(), Guard);
EXPECT_TRUE(L->isGuarded());
- EXPECT_TRUE(L->isRotated());
+ EXPECT_TRUE(L->isRotatedForm());
});
}
@@ -581,7 +581,7 @@ TEST(LoopInfoTest, LoopWithGuardCmpSLE) {
EXPECT_EQ(L->getInductionVariable(SE)->getName(), "i");
EXPECT_EQ(L->getLoopGuardBranch(), Guard);
EXPECT_TRUE(L->isGuarded());
- EXPECT_TRUE(L->isRotated());
+ EXPECT_TRUE(L->isRotatedForm());
});
}
@@ -637,7 +637,7 @@ TEST(LoopInfoTest, LoopNonConstantStep) {
EXPECT_EQ(L->getInductionVariable(SE)->getName(), "i");
EXPECT_EQ(L->getLoopGuardBranch(), Guard);
EXPECT_TRUE(L->isGuarded());
- EXPECT_TRUE(L->isRotated());
+ EXPECT_TRUE(L->isRotatedForm());
});
}
@@ -696,7 +696,7 @@ TEST(LoopInfoTest, LoopUnsignedBounds) {
EXPECT_EQ(L->getInductionVariable(SE)->getName(), "i");
EXPECT_EQ(L->getLoopGuardBranch(), Guard);
EXPECT_TRUE(L->isGuarded());
- EXPECT_TRUE(L->isRotated());
+ EXPECT_TRUE(L->isRotatedForm());
});
}
@@ -755,7 +755,7 @@ TEST(LoopInfoTest, DecreasingLoop) {
EXPECT_EQ(L->getInductionVariable(SE)->getName(), "i");
EXPECT_EQ(L->getLoopGuardBranch(), Guard);
EXPECT_TRUE(L->isGuarded());
- EXPECT_TRUE(L->isRotated());
+ EXPECT_TRUE(L->isRotatedForm());
});
}
@@ -813,7 +813,7 @@ TEST(LoopInfoTest, CannotFindDirection) {
EXPECT_EQ(L->getInductionVariable(SE)->getName(), "i");
EXPECT_EQ(L->getLoopGuardBranch(), Guard);
EXPECT_TRUE(L->isGuarded());
- EXPECT_TRUE(L->isRotated());
+ EXPECT_TRUE(L->isRotatedForm());
});
}
@@ -875,7 +875,7 @@ TEST(LoopInfoTest, ZextIndVar) {
EXPECT_EQ(L->getInductionVariable(SE)->getName(), "indvars.iv");
EXPECT_EQ(L->getLoopGuardBranch(), Guard);
EXPECT_TRUE(L->isGuarded());
- EXPECT_TRUE(L->isRotated());
+ EXPECT_TRUE(L->isRotatedForm());
});
}
@@ -1048,7 +1048,7 @@ TEST(LoopInfoTest, UnguardedLoop) {
EXPECT_EQ(L->getInductionVariable(SE)->getName(), "i");
EXPECT_EQ(L->getLoopGuardBranch(), nullptr);
EXPECT_FALSE(L->isGuarded());
- EXPECT_TRUE(L->isRotated());
+ EXPECT_TRUE(L->isRotatedForm());
});
}
@@ -1106,7 +1106,7 @@ TEST(LoopInfoTest, UnguardedLoopWithControlFlow) {
EXPECT_EQ(L->getInductionVariable(SE)->getName(), "i");
EXPECT_EQ(L->getLoopGuardBranch(), Guard);
EXPECT_TRUE(L->isGuarded());
- EXPECT_TRUE(L->isRotated());
+ EXPECT_TRUE(L->isRotatedForm());
});
}
@@ -1177,7 +1177,7 @@ TEST(LoopInfoTest, LoopNest) {
EXPECT_EQ(L->getInductionVariable(SE)->getName(), "j");
EXPECT_EQ(L->getLoopGuardBranch(), OuterGuard);
EXPECT_TRUE(L->isGuarded());
- EXPECT_TRUE(L->isRotated());
+ EXPECT_TRUE(L->isRotatedForm());
// Next two basic blocks are for.outer and for.inner.preheader - skip
// them.
@@ -1202,7 +1202,7 @@ TEST(LoopInfoTest, LoopNest) {
EXPECT_EQ(L->getInductionVariable(SE)->getName(), "i");
EXPECT_EQ(L->getLoopGuardBranch(), InnerGuard);
EXPECT_TRUE(L->isGuarded());
- EXPECT_TRUE(L->isRotated());
+ EXPECT_TRUE(L->isRotatedForm());
});
}
@@ -1284,7 +1284,7 @@ TEST(LoopInfoTest, AuxiliaryIV) {
L->isAuxiliaryInductionVariable(Instruction_mulopcode, SE));
EXPECT_EQ(L->getLoopGuardBranch(), Guard);
EXPECT_TRUE(L->isGuarded());
- EXPECT_TRUE(L->isRotated());
+ EXPECT_TRUE(L->isRotatedForm());
});
}
@@ -1497,6 +1497,6 @@ TEST(LoopInfoTest, LoopNotRotated) {
EXPECT_TRUE(L->isLoopSimplifyForm());
// This loop is not rotated.
- EXPECT_FALSE(L->isRotated());
+ EXPECT_FALSE(L->isRotatedForm());
});
}
More information about the llvm-commits
mailing list