diff options
Diffstat (limited to 'lib/Transforms/Scalar/LoopStrengthReduce.cpp')
-rw-r--r-- | lib/Transforms/Scalar/LoopStrengthReduce.cpp | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/lib/Transforms/Scalar/LoopStrengthReduce.cpp index 85f1389..baf5669 100644 --- a/lib/Transforms/Scalar/LoopStrengthReduce.cpp +++ b/lib/Transforms/Scalar/LoopStrengthReduce.cpp @@ -4518,11 +4518,19 @@ LSRInstance::LSRInstance(const TargetLowering *tli, Loop *l, Pass *P) if (!L->isLoopSimplifyForm()) return; - // All outer loops must have preheaders, or SCEVExpander may not be able to - // materialize an AddRecExpr whose Start is an outer AddRecExpr. - for (const Loop *OuterLoop = L; (OuterLoop = OuterLoop->getParentLoop());) { - if (!OuterLoop->getLoopPreheader()) - return; + // All dominating loops must have preheaders, or SCEVExpander may not be able + // to materialize an AddRecExpr whose Start is an outer AddRecExpr. + // + // FIXME: This is a little absurd. I think LoopSimplify should be taught + // to create a preheader under any circumstance. + for (DomTreeNode *Rung = DT.getNode(L->getLoopPreheader()); + Rung; Rung = Rung->getIDom()) { + BasicBlock *BB = Rung->getBlock(); + const Loop *DomLoop = LI.getLoopFor(BB); + if (DomLoop && DomLoop->getHeader() == BB) { + if (!DomLoop->getLoopPreheader()) + return; + } } // If there's no interesting work to be done, bail early. if (IU.empty()) return; |