diff --git a/src/mapleall/maple_me/src/ssa_epre_for_sr.cpp b/src/mapleall/maple_me/src/ssa_epre_for_sr.cpp index 9882180098b4e6548c18f824b16d1cec47a0e337..cbd888c937118627fc03c435b8057eec81cdc326 100644 --- a/src/mapleall/maple_me/src/ssa_epre_for_sr.cpp +++ b/src/mapleall/maple_me/src/ssa_epre_for_sr.cpp @@ -138,7 +138,6 @@ void SSAEPre::SRSetNeedRepair(MeOccur *useocc, std::set *needRepairInj RegMeExpr *regx = static_cast(curopnd); needRepairInjuringDefs->insert(regx->GetDefStmt()); } - return; // restricted injury requirement to at most 1 operand } } } @@ -332,8 +331,6 @@ MeExpr* SSAEPre::SRRepairInjuries(MeOccur *useocc, if (!OpndInDefOcc(curopnd, defocc, i)) { repairedTemp = SRRepairOpndInjuries(curopnd, defocc, i, repairedTemp, needRepairInjuringDefs, repairedInjuringDefs); - // restricted to only 1 var or reg injured - break; } } // for return repairedTemp; diff --git a/src/mapleall/maple_me/src/ssa_pre.cpp b/src/mapleall/maple_me/src/ssa_pre.cpp index 6b7130ec198fa223ec960c142ed3719dee900b41..aa3c6d8b4ab21e9887f382be3549321e72ad1713 100644 --- a/src/mapleall/maple_me/src/ssa_pre.cpp +++ b/src/mapleall/maple_me/src/ssa_pre.cpp @@ -269,7 +269,18 @@ void SSAPre::CodeMotion() { } else { // set phiOpnd4Temp needed in the temp's phi if (workCand->isSRCand) { + auto oldSize = repairedInjuringDefs.size(); phiOpnd->phiOpnd4Temp = SRRepairInjuries(phiOpnd, &needRepairInjuringDefs, &repairedInjuringDefs); + // the expr's version may changed after (realocc) repair injuries. if is, use the new version + if (repairedInjuringDefs.size() == oldSize) { + for (auto it = repairedInjuringDefs.rbegin(); it != repairedInjuringDefs.rend(); ++it) { + auto *stmt = *it; + if (stmt->GetBB() == defOcc->GetBB()) { + phiOpnd->phiOpnd4Temp = stmt->GetNextMeStmt()->GetLHS(); + break; + } + } + } } else { if (defOcc->GetOccType() == kOccReal) { phiOpnd->phiOpnd4Temp = static_cast(defOcc)->GetSavedExpr();