summaryrefslogtreecommitdiff
path: root/lib/Analysis/ScalarEvolutionExpander.cpp
diff options
context:
space:
mode:
authorAndrew Trick <atrick@apple.com>2012-01-02 21:25:10 +0000
committerAndrew Trick <atrick@apple.com>2012-01-02 21:25:10 +0000
commit0f8cd56bfdd32af4edb253654db02fb3143b25a8 (patch)
treed7b9bb41ca6850dd12bc1a94d81af4936ae3a066 /lib/Analysis/ScalarEvolutionExpander.cpp
parentcf6bd5a7c36b65a80a7c43bc094725181ae9c384 (diff)
downloadllvm-0f8cd56bfdd32af4edb253654db02fb3143b25a8.tar.gz
llvm-0f8cd56bfdd32af4edb253654db02fb3143b25a8.tar.bz2
llvm-0f8cd56bfdd32af4edb253654db02fb3143b25a8.tar.xz
Fix SCEVExpander to handle loops with no preheader when LSR gives it a
"phony" insertion point. Fixes rdar://10619599: "SelectionDAGBuilder shouldn't visit PHI nodes!" assert git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147439 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/ScalarEvolutionExpander.cpp')
-rw-r--r--lib/Analysis/ScalarEvolutionExpander.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/Analysis/ScalarEvolutionExpander.cpp b/lib/Analysis/ScalarEvolutionExpander.cpp
index 5f83914cb2..0a3cda998f 100644
--- a/lib/Analysis/ScalarEvolutionExpander.cpp
+++ b/lib/Analysis/ScalarEvolutionExpander.cpp
@@ -1443,6 +1443,12 @@ Value *SCEVExpander::expand(const SCEV *S) {
if (!L) break;
if (BasicBlock *Preheader = L->getLoopPreheader())
InsertPt = Preheader->getTerminator();
+ else {
+ // LSR sets the insertion point for AddRec start/step values to the
+ // block start to simplify value reuse, even though it's an invalid
+ // position. SCEVExpander must correct for this in all cases.
+ InsertPt = L->getHeader()->getFirstInsertionPt();
+ }
} else {
// If the SCEV is computable at this level, insert it into the header
// after the PHIs (and after any other instructions that we've inserted