Skip to content

Commit 979016d

Browse files
add prepass tracking to avoid redundant masking updates
1 parent 2ea17b5 commit 979016d

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

lib/Backend/BackwardPass.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ BackwardPass::BackwardPass(Func * func, GlobOpt * globOpt, Js::Phase tag)
1212
preOpBailOutInstrToProcess(nullptr),
1313
considerSymAsRealUseInNoImplicitCallUses(nullptr),
1414
isCollectionPass(false), currentRegion(nullptr),
15-
collectionPassSubPhase(CollectionPassSubPhase::None)
15+
collectionPassSubPhase(CollectionPassSubPhase::None),
16+
isLoopPrepass(false)
1617
{
1718
// Those are the only two phase dead store will be used currently
1819
Assert(tag == Js::BackwardPhase || tag == Js::DeadStorePhase);
@@ -1577,6 +1578,9 @@ BackwardPass::ProcessLoop(BasicBlock * lastBlock)
15771578

15781579
Loop *loop = lastBlock->loop;
15791580

1581+
bool prevIsLoopPrepass = this->isLoopPrepass;
1582+
this->isLoopPrepass = true;
1583+
15801584
// This code doesn't work quite as intended. It is meant to capture fields that are live out of a loop to limit the
15811585
// number of implicit call bailouts the forward pass must create (only compiler throughput optimization, no impact
15821586
// on emitted code), but because it looks only at the lexically last block in the loop, it does the right thing only
@@ -1643,6 +1647,8 @@ BackwardPass::ProcessLoop(BasicBlock * lastBlock)
16431647
__analysis_assume(lastBlock);
16441648
lastBlock->loop->hasDeadStorePrepass = true;
16451649

1650+
this->isLoopPrepass = prevIsLoopPrepass;
1651+
16461652
#if DBG_DUMP
16471653
if (this->IsTraceEnabled())
16481654
{
@@ -3189,7 +3195,7 @@ BackwardPass::ProcessBlock(BasicBlock * block)
31893195
if (this->tag == Js::DeadStorePhase)
31903196
{
31913197
#ifndef _M_ARM
3192-
if(block->loop)
3198+
if(block->loop && !this->isLoopPrepass)
31933199
{
31943200
// In the second pass, we mark instructions that we go by as being safe or unsafe.
31953201
//
@@ -3273,7 +3279,7 @@ BackwardPass::ProcessBlock(BasicBlock * block)
32733279
#if DBG_DUMP
32743280
if (PHASE_TRACE(Js::SpeculationPropagationAnalysisPhase, loop->topFunc))
32753281
{
3276-
Output::Print(_u("Adding symbols to out-edge masking:\n"));
3282+
Output::Print(_u("Adding symbols to out-edge masking for loop %u outward block %u:\n"), loop->GetLoopNumber(), maskingBlock->GetBlockNum());
32773283
symsToMask->Dump();
32783284
}
32793285
#endif

lib/Backend/BackwardPass.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ class BackwardPass
187187
FirstPass,
188188
SecondPass
189189
} collectionPassSubPhase;
190+
bool isLoopPrepass;
190191

191192
class FloatSymEquivalenceClass
192193
{

0 commit comments

Comments
 (0)