From 341bf1548e73299186fabe400b9c0347bf0bf6b8 Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Mon, 24 Oct 2011 05:51:01 +0000 Subject: [PATCH] PHI nodes not in the loop header aren't part of the loop iteration initial state. Furthermore, they might not have two operands. This fixes the underlying issue behind the crashes introduced in r142781. llvm-svn: 142788 --- lib/Analysis/ScalarEvolution.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Analysis/ScalarEvolution.cpp b/lib/Analysis/ScalarEvolution.cpp index 2da8e6fbd63..1e4bf19e849 100644 --- a/lib/Analysis/ScalarEvolution.cpp +++ b/lib/Analysis/ScalarEvolution.cpp @@ -4856,7 +4856,7 @@ ScalarEvolution::getConstantEvolutionLoopExitValue(PHINode *PN, for (DenseMap::const_iterator I = CurrentIterVals.begin(), E = CurrentIterVals.end(); I != E; ++I){ PHINode *PHI = dyn_cast(I->first); - if (!PHI || PHI == PN) continue; + if (!PHI || PHI == PN || PHI->getParent() != Header) continue; Constant *&NextPHI = NextIterVals[PHI]; if (NextPHI) continue; // Already computed!