aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms/Scalar/LoopStrengthReduce.cpp
diff options
context:
space:
mode:
authorAndrew Trick <atrick@apple.com>2012-01-07 03:16:50 +0000
committerAndrew Trick <atrick@apple.com>2012-01-07 03:16:50 +0000
commitacdb4aaf9b1f2edd96163c27bcc4e0557014f51e (patch)
tree41ec44bb17baa2ee5521ab042ef949a6a5b782bb /lib/Transforms/Scalar/LoopStrengthReduce.cpp
parent99b4237c1647156f0e1d3d7e03efdab23ed79778 (diff)
LSR: Don't optimize loops if an outer loop has no preheader.
LoopSimplify may not run on some outer loops, e.g. because of indirect branches. SCEVExpander simply cannot handle outer loops with no preheaders. Fixes rdar://10655343 SCEVExpander segfault. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147718 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/LoopStrengthReduce.cpp')
-rw-r--r--lib/Transforms/Scalar/LoopStrengthReduce.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/lib/Transforms/Scalar/LoopStrengthReduce.cpp
index f59e156c93..8f3a5ab071 100644
--- a/lib/Transforms/Scalar/LoopStrengthReduce.cpp
+++ b/lib/Transforms/Scalar/LoopStrengthReduce.cpp
@@ -3842,8 +3842,15 @@ LSRInstance::LSRInstance(const TargetLowering *tli, Loop *l, Pass *P)
TLI(tli), L(l), Changed(false), IVIncInsertPos(0) {
// If LoopSimplify form is not available, stay out of trouble.
- if (!L->isLoopSimplifyForm()) return;
+ 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;
+ }
// If there's no interesting work to be done, bail early.
if (IU.empty()) return;