Skip to content

Commit c0d0c39

Browse files
Meghana Guptapleath
authored andcommitted
1 parent 07b62fd commit c0d0c39

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

lib/Backend/GlobOptIntBounds.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2985,7 +2985,11 @@ void GlobOpt::DetermineArrayBoundCheckHoistability(
29852985
{
29862986
// The loop count is constant, fold (indexOffset + loopCountMinusOne * maxMagnitudeChange)
29872987
TRACE_PHASE_VERBOSE(Js::Phase::BoundCheckHoistPhase, 3, _u("Loop count is constant, folding\n"));
2988-
if(Int32Math::Mul(loopCount->LoopCountMinusOneConstantValue(), maxMagnitudeChange, &offset) ||
2988+
2989+
int loopCountMinusOnePlusOne = 0;
2990+
2991+
if (Int32Math::Add(loopCount->LoopCountMinusOneConstantValue(), 1, &loopCountMinusOnePlusOne) ||
2992+
Int32Math::Mul(loopCountMinusOnePlusOne, maxMagnitudeChange, &offset) ||
29892993
Int32Math::Add(offset, indexOffset, &offset))
29902994
{
29912995
TRACE_PHASE_VERBOSE(Js::Phase::BoundCheckHoistPhase, 4, _u("Folding failed\n"));

test/Optimizer/BoundCheckElimination.baseline

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Testtrace: BoundCheckElimination function testHoistability ( (#1.1), #2): Elimin
88
Testtrace: BoundCheckHoist function testHoistability ( (#1.1), #2): Hoisting array upper bound check out of loop
99
Testtrace: BoundCheckElimination function testHoistability ( (#1.1), #2): Eliminating array lower bound check
1010
Testtrace: BoundCheckElimination function testHoistability ( (#1.1), #2): Eliminating array upper bound check
11+
Testtrace: BoundCheckElimination function testHoistability ( (#1.1), #2): Separating array lower bound check
1112
Testtrace: BoundCheckHoist function testHoistability ( (#1.1), #2): Hoisting array upper bound check out of loop
1213
Testtrace: BoundCheckElimination function testHoistability ( (#1.1), #2): Eliminating array lower bound check
1314
Testtrace: BoundCheckElimination function testHoistability ( (#1.1), #2): Eliminating array upper bound check

0 commit comments

Comments
 (0)