diff options
author | Andrew Trick <atrick@apple.com> | 2012-01-17 06:45:52 +0000 |
---|---|---|
committer | Andrew Trick <atrick@apple.com> | 2012-01-17 06:45:52 +0000 |
commit | 0f080913d1ff80bb61476724304359e14822b193 (patch) | |
tree | 12ec273d7c15379c36ff93a3ce7df448b7642036 /lib/Transforms | |
parent | 37c2677fbcff1187106c579abfbd498aac739c2a (diff) | |
download | external_llvm-0f080913d1ff80bb61476724304359e14822b193.zip external_llvm-0f080913d1ff80bb61476724304359e14822b193.tar.gz external_llvm-0f080913d1ff80bb61476724304359e14822b193.tar.bz2 |
LSR fix: broaden the check for loop preheaders.
It's becoming clear that LoopSimplify needs to unconditionally create loop preheaders. But that is a bigger fix. For now, continuing to hack LSR.
Fixes rdar://10701050 "Cannot split an edge from an IndirectBrInst" assert.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148288 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-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; |