summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorAndrew Trick <atrick@apple.com>2012-01-17 06:45:52 +0000
committerAndrew Trick <atrick@apple.com>2012-01-17 06:45:52 +0000
commit12728f04ca6ef2490a8fed72f6723f878db1c375 (patch)
tree380659e2b93760ea6c24c9bd6f41b58db859e732 /llvm/lib/Transforms
parent209c514a1d790f0f152857e5c866bf2b90651db4 (diff)
downloadbcm5719-llvm-12728f04ca6ef2490a8fed72f6723f878db1c375.tar.gz
bcm5719-llvm-12728f04ca6ef2490a8fed72f6723f878db1c375.zip
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. llvm-svn: 148288
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
index 85f1389fe31..baf566906b6 100644
--- a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
+++ b/llvm/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;
OpenPOWER on IntegriCloud