[llvm] 34d6820 - [LoopFlatten] Use Loop to identify loop induction phi. NFC
Rosie Sumpter via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 19 01:14:43 PDT 2021
Author: Rosie Sumpter
Date: 2021-07-19T09:06:57+01:00
New Revision: 34d6820551c6ee7e76199407b3c1ba6fecf4398f
URL: https://github.com/llvm/llvm-project/commit/34d6820551c6ee7e76199407b3c1ba6fecf4398f
DIFF: https://github.com/llvm/llvm-project/commit/34d6820551c6ee7e76199407b3c1ba6fecf4398f.diff
LOG: [LoopFlatten] Use Loop to identify loop induction phi. NFC
Replace code which identifies induction phi with helper function
getInductionVariable to improve robustness.
Differential Revision: https://reviews.llvm.org/D106045
Added:
Modified:
llvm/lib/Transforms/Scalar/LoopFlatten.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Scalar/LoopFlatten.cpp b/llvm/lib/Transforms/Scalar/LoopFlatten.cpp
index 37bfff4ba67f6..1cad134876a40 100644
--- a/llvm/lib/Transforms/Scalar/LoopFlatten.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopFlatten.cpp
@@ -124,19 +124,12 @@ static bool findLoopComponents(
// Find the induction PHI. If there is no induction PHI, we can't do the
// transformation. TODO: could other variables trigger this? Do we have to
// search for the best one?
- InductionPHI = nullptr;
- for (PHINode &PHI : L->getHeader()->phis()) {
- InductionDescriptor ID;
- if (InductionDescriptor::isInductionPHI(&PHI, L, SE, ID)) {
- InductionPHI = Φ
- LLVM_DEBUG(dbgs() << "Found induction PHI: "; InductionPHI->dump());
- break;
- }
- }
+ InductionPHI = L->getInductionVariable(*SE);
if (!InductionPHI) {
LLVM_DEBUG(dbgs() << "Could not find induction PHI\n");
return false;
}
+ LLVM_DEBUG(dbgs() << "Found induction PHI: "; InductionPHI->dump());
auto IsValidPredicate = [&](ICmpInst::Predicate Pred) {
if (ContinueOnTrue)
More information about the llvm-commits
mailing list