diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2022-07-03 14:10:23 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2022-07-03 14:10:23 +0000 |
| commit | 145449b1e420787bb99721a429341fa6be3adfb6 (patch) | |
| tree | 1d56ae694a6de602e348dd80165cf881a36600ed /llvm/lib/Transforms/Scalar/LoopFlatten.cpp | |
| parent | ecbca9f5fb7d7613d2b94982c4825eb0d33d6842 (diff) | |
Diffstat (limited to 'llvm/lib/Transforms/Scalar/LoopFlatten.cpp')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/LoopFlatten.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopFlatten.cpp b/llvm/lib/Transforms/Scalar/LoopFlatten.cpp index c46db4e63bfe..f36193fc468e 100644 --- a/llvm/lib/Transforms/Scalar/LoopFlatten.cpp +++ b/llvm/lib/Transforms/Scalar/LoopFlatten.cpp @@ -54,6 +54,7 @@ #include "llvm/ADT/Statistic.h" #include "llvm/Analysis/AssumptionCache.h" #include "llvm/Analysis/LoopInfo.h" +#include "llvm/Analysis/LoopNestAnalysis.h" #include "llvm/Analysis/MemorySSAUpdater.h" #include "llvm/Analysis/OptimizationRemarkEmitter.h" #include "llvm/Analysis/ScalarEvolution.h" @@ -64,12 +65,12 @@ #include "llvm/IR/IRBuilder.h" #include "llvm/IR/Module.h" #include "llvm/IR/PatternMatch.h" -#include "llvm/IR/Verifier.h" #include "llvm/InitializePasses.h" #include "llvm/Pass.h" #include "llvm/Support/Debug.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Transforms/Scalar.h" +#include "llvm/Transforms/Scalar/LoopPassManager.h" #include "llvm/Transforms/Utils/Local.h" #include "llvm/Transforms/Utils/LoopUtils.h" #include "llvm/Transforms/Utils/ScalarEvolutionExpander.h" @@ -210,8 +211,9 @@ struct FlattenInfo { if (!MatchedItCount) return false; - // Look through extends if the IV has been widened. - if (Widened && + // Look through extends if the IV has been widened. Don't look through + // extends if we already looked through a trunc. + if (Widened && IsAdd && (isa<SExtInst>(MatchedItCount) || isa<ZExtInst>(MatchedItCount))) { assert(MatchedItCount->getType() == InnerInductionPHI->getType() && "Unexpected type mismatch in types after widening"); @@ -410,7 +412,7 @@ static bool findLoopComponents( // pre-header and one from the latch. The incoming latch value is the // increment variable. Increment = - dyn_cast<BinaryOperator>(InductionPHI->getIncomingValueForBlock(Latch)); + cast<BinaryOperator>(InductionPHI->getIncomingValueForBlock(Latch)); if (Increment->hasNUsesOrMore(3)) { LLVM_DEBUG(dbgs() << "Could not find valid increment\n"); return false; @@ -921,7 +923,7 @@ PreservedAnalyses LoopFlattenPass::run(LoopNest &LN, LoopAnalysisManager &LAM, // this pass will simplify all loops that contain inner loops, // regardless of whether anything ends up being flattened. Changed |= Flatten(LN, &AR.DT, &AR.LI, &AR.SE, &AR.AC, &AR.TTI, &U, - MSSAU.hasValue() ? MSSAU.getPointer() : nullptr); + MSSAU ? MSSAU.getPointer() : nullptr); if (!Changed) return PreservedAnalyses::all(); @@ -987,7 +989,7 @@ bool LoopFlattenLegacyPass::runOnFunction(Function &F) { for (Loop *L : *LI) { auto LN = LoopNest::getLoopNest(*L, *SE); Changed |= Flatten(*LN, DT, LI, SE, AC, TTI, nullptr, - MSSAU.hasValue() ? MSSAU.getPointer() : nullptr); + MSSAU ? MSSAU.getPointer() : nullptr); } return Changed; } |
