Index: vm/jitrino/src/optimizer/ssa/SSA.cpp =================================================================== --- vm/jitrino/src/optimizer/ssa/SSA.cpp (revision 475137) +++ vm/jitrino/src/optimizer/ssa/SSA.cpp (working copy) @@ -602,6 +602,26 @@ StlVector &changedVars) { Inst* phi = (Inst*)node->getSecondInst(); + if(phi && !phi->isPhi()) { + // try the next one (third) + phi = phi->getNextInst(); + } + +#ifdef _DEBUG + // Let's check that phi insts can start from the second or third position only + // and goes in a row + Inst* testInst = phi; + // skip all phis + while ( testInst!=NULL && testInst->isPhi() ) { + testInst = testInst->getNextInst(); + } + // ensure there is no any other phis in the node + while ( testInst!=NULL ) { + assert(!testInst->isPhi()); + testInst = testInst->getNextInst(); + } +#endif + bool removedPhi = false; #ifdef DEBUG_SSA if (Log::isEnabled()) { @@ -670,6 +690,26 @@ StlVector *removedVars) { Inst* phi = (Inst*)node->getSecondInst(); + if(phi && !phi->isPhi()) { + // try the next one (third) + phi = phi->getNextInst(); + } + +#ifdef _DEBUG + // Let's check that phi insts can start from the second or third position only + // and goes in a row + Inst* testInst = phi; + // skip all phis + while ( testInst!=NULL && testInst->isPhi() ) { + testInst = testInst->getNextInst(); + } + // ensure there is no any other phis in the node + while ( testInst!=NULL ) { + assert(!testInst->isPhi()); + testInst = testInst->getNextInst(); + } +#endif + Inst *nextphi = NULL; #ifdef DEBUG_SSA if (Log::isEnabled()) {