|
|
@@ -8669,7 +8669,15 @@ BackwardPass::RestoreInductionVariableValuesAfterMemOp(Loop *loop)
|
|
|
|
|
|
IR::Opnd *inductionVariableOpnd = IR::RegOpnd::New(sym, IRType::TyInt32, localFunc);
|
|
|
IR::Opnd *sizeOpnd = globOpt->GenerateInductionVariableChangeForMemOp(loop, inductionVariableChangeInfo.unroll);
|
|
|
- loop->landingPad->InsertAfter(IR::Instr::New(opCode, inductionVariableOpnd, inductionVariableOpnd, sizeOpnd, loop->GetFunc()));
|
|
|
+ IR::Instr* restoreInductionVarInstr = IR::Instr::New(opCode, inductionVariableOpnd, inductionVariableOpnd, sizeOpnd, loop->GetFunc());
|
|
|
+
|
|
|
+ // The IR that restores the induction variable's value is placed before the MemOp. Since this IR can
|
|
|
+ // bailout to the loop's landing pad, placing this IR before the MemOp avoids performing the MemOp,
|
|
|
+ // bailing out because of this IR, and then performing the effects of the loop again.
|
|
|
+ loop->landingPad->InsertInstrBefore(restoreInductionVarInstr, loop->memOpInfo->instr);
|
|
|
+
|
|
|
+ // If restoring an induction variable results in an overflow, bailout to the loop's landing pad.
|
|
|
+ restoreInductionVarInstr->ConvertToBailOutInstr(loop->bailOutInfo, IR::BailOutOnOverflow);
|
|
|
};
|
|
|
|
|
|
for (auto it = loop->memOpInfo->inductionVariableChangeInfoMap->GetIterator(); it.IsValid(); it.MoveNext())
|