PHI nodes not in the loop header aren't part of the loop iteration initial
authorNick Lewycky <nicholas@mxc.ca>
Mon, 24 Oct 2011 05:51:01 +0000 (05:51 +0000)
committerNick Lewycky <nicholas@mxc.ca>
Mon, 24 Oct 2011 05:51:01 +0000 (05:51 +0000)
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

lib/Analysis/ScalarEvolution.cpp

index 2da8e6fbd6384184e8cf0227976e5ada7abc9ce7..1e4bf19e84971736228e8c53b2278ff682a86d47 100644 (file)
@@ -4856,7 +4856,7 @@ ScalarEvolution::getConstantEvolutionLoopExitValue(PHINode *PN,
     for (DenseMap<Instruction *, Constant *>::const_iterator
            I = CurrentIterVals.begin(), E = CurrentIterVals.end(); I != E; ++I){
       PHINode *PHI = dyn_cast<PHINode>(I->first);
-      if (!PHI || PHI == PN) continue;
+      if (!PHI || PHI == PN || PHI->getParent() != Header) continue;
       Constant *&NextPHI = NextIterVals[PHI];
       if (NextPHI) continue;    // Already computed!