Skip to content

Commit 1e5d3f5

Browse files
wyrichteMikeHolman
authored andcommitted
1 parent 31f2588 commit 1e5d3f5

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

lib/Backend/BackwardPass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8742,7 +8742,7 @@ BackwardPass::RestoreInductionVariableValuesAfterMemOp(Loop *loop)
87428742
StackSym *sym = localFunc->m_symTable->FindStackSym(symId)->GetInt32EquivSym(localFunc);
87438743

87448744
IR::Opnd *inductionVariableOpnd = IR::RegOpnd::New(sym, IRType::TyInt32, localFunc);
8745-
IR::Opnd *sizeOpnd = globOpt->GenerateInductionVariableChangeForMemOp(loop, inductionVariableChangeInfo.unroll);
8745+
IR::Opnd *sizeOpnd = globOpt->GenerateInductionVariableChangeForMemOp(loop, inductionVariableChangeInfo.unroll, loop->memOpInfo->instr);
87468746
IR::Instr* restoreInductionVarInstr = IR::Instr::New(opCode, inductionVariableOpnd, inductionVariableOpnd, sizeOpnd, loop->GetFunc());
87478747

87488748
// The IR that restores the induction variable's value is placed before the MemOp. Since this IR can

lib/Backend/GlobOpt.cpp

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2087,6 +2087,7 @@ bool GlobOpt::CollectMemcopyStElementI(IR::Instr *instr, Loop *loop)
20872087

20882088
// Consider: Can we remove the count field?
20892089
memcopyInfo->count++;
2090+
AssertOrFailFast(memcopyInfo->count <= 1);
20902091
memcopyInfo->base = baseSymID;
20912092

20922093
return true;
@@ -2226,7 +2227,14 @@ GlobOpt::CollectMemOpInfo(IR::Instr *instrBegin, IR::Instr *instr, Value *src1Va
22262227
{
22272228
Loop::InductionVariableChangeInfo inductionVariableChangeInfo = { 0, 0 };
22282229
inductionVariableChangeInfo = loop->memOpInfo->inductionVariableChangeInfoMap->Lookup(inductionSymID, inductionVariableChangeInfo);
2229-
inductionVariableChangeInfo.unroll++;
2230+
2231+
// If inductionVariableChangeInfo.unroll has been invalidated, do
2232+
// not modify the Js::Constants::InvalidLoopUnrollFactor value
2233+
if (inductionVariableChangeInfo.unroll != Js::Constants::InvalidLoopUnrollFactor)
2234+
{
2235+
inductionVariableChangeInfo.unroll++;
2236+
}
2237+
22302238
inductionVariableChangeInfo.isIncremental = isIncr;
22312239
loop->memOpInfo->inductionVariableChangeInfoMap->Item(inductionSymID, inductionVariableChangeInfo);
22322240
}
@@ -16677,6 +16685,7 @@ GlobOpt::GetOrGenerateLoopCountForMemOp(Loop *loop)
1667716685
IR::Opnd *
1667816686
GlobOpt::GenerateInductionVariableChangeForMemOp(Loop *loop, byte unroll, IR::Instr *insertBeforeInstr)
1667916687
{
16688+
AssertOrFailFast(unroll != Js::Constants::InvalidLoopUnrollFactor);
1668016689
LoopCount *loopCount = loop->loopCount;
1668116690
IR::Opnd *sizeOpnd = nullptr;
1668216691
Assert(loopCount);
@@ -16714,11 +16723,12 @@ GlobOpt::GenerateInductionVariableChangeForMemOp(Loop *loop, byte unroll, IR::In
1671416723

1671516724
IR::Opnd *unrollOpnd = IR::IntConstOpnd::New(unroll, type, localFunc);
1671616725

16717-
InsertInstr(IR::Instr::New(Js::OpCode::Mul_I4,
16718-
sizeOpnd,
16719-
loopCountOpnd,
16720-
unrollOpnd,
16721-
localFunc));
16726+
IR::Instr* inductionChangeMultiplier = IR::Instr::New(
16727+
Js::OpCode::Mul_I4, sizeOpnd, loopCountOpnd, unrollOpnd, localFunc);
16728+
16729+
InsertInstr(inductionChangeMultiplier);
16730+
16731+
inductionChangeMultiplier->ConvertToBailOutInstr(loop->bailOutInfo, IR::BailOutOnOverflow);
1672216732

1672316733
}
1672416734
}

0 commit comments

Comments
 (0)