From: Nick Lewycky Date: Mon, 24 Oct 2011 05:51:01 +0000 (+0000) Subject: PHI nodes not in the loop header aren't part of the loop iteration initial X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=5bef0eb1de5f52662de7b4808bee5e9d643b04db;p=oota-llvm.git 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142788 91177308-0d34-0410-b5e6-96231b3b80d8 --- 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!