Skip to content

Commit 73e1976

Browse files
authored
JIT: Add missing lvTracked check in optLocalHasNonLoopUses (#109505)
`optLocalHasNonLoopUses` checks if a local might be used after a loop by making use of its liveness information, but it does not check `lvTracked` before doing so. This is generally not a problem as there are other checks that the local is in SSA, and normally SSA implies lvTracked, but that's not the case for locals put into SSA by CSE. Since it is possible to have CSE defs in a loop with uses outside the loop, this check is necessary for correctness. It is expected to regress a bunch of IV opts cases, but in the future we can get those back by computing the necessary liveness when we insert into SSA.
1 parent 302e0d4 commit 73e1976

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/coreclr/jit/inductionvariableopts.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1284,6 +1284,11 @@ bool Compiler::optLocalHasNonLoopUses(unsigned lclNum, FlowGraphNaturalLoop* loo
12841284
return true;
12851285
}
12861286

1287+
if (!varDsc->lvTracked)
1288+
{
1289+
return true;
1290+
}
1291+
12871292
BasicBlockVisit visitResult = loop->VisitRegularExitBlocks([=](BasicBlock* block) {
12881293
if (VarSetOps::IsMember(this, block->bbLiveIn, varDsc->lvVarIndex))
12891294
{

0 commit comments

Comments
 (0)