[PATCH] D106045: [LoopFlatten] Use Loop to identify loop induction phi. NFC
Rosie Sumpter via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 15 01:27:38 PDT 2021
RosieSumpter created this revision.
RosieSumpter added a reviewer: SjoerdMeijer.
Herald added a subscriber: hiraditya.
RosieSumpter requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Replace code which identifies induction phi with helper function
getInductionVariable to improve robustness.
https://reviews.llvm.org/D106045
Files:
llvm/lib/Transforms/Scalar/LoopFlatten.cpp
Index: llvm/lib/Transforms/Scalar/LoopFlatten.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/LoopFlatten.cpp
+++ llvm/lib/Transforms/Scalar/LoopFlatten.cpp
@@ -125,17 +125,12 @@
// 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;
+ } else {
+ LLVM_DEBUG(dbgs() << "Found induction PHI: "; InductionPHI->dump());
}
auto IsValidPredicate = [&](ICmpInst::Predicate Pred) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D106045.358864.patch
Type: text/x-patch
Size: 947 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210715/e02bb035/attachment.bin>
More information about the llvm-commits
mailing list