From 3c4d02448358e8dddffc756fcd31bb2f66265907 Mon Sep 17 00:00:00 2001 From: Bruce Forstall Date: Fri, 12 Nov 2021 11:44:12 -0800 Subject: [PATCH] Fix optIsLoopEntry to skip removed loops This was preventing block compaction with loop entry blocks in loops that had been previously optimized away (and thus removed from the loop table). There are a few cases where we now delete dead code that was previously left in the function. There are a number of spurious local weighting and IG textual asm diffs changes, possibly due to how PerfScore is implemented (there are some surprisingly large PerfScore changes in a few cases, despite no change in (most) generated code). --- src/coreclr/jit/optimizer.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/coreclr/jit/optimizer.cpp b/src/coreclr/jit/optimizer.cpp index b179dcc96ca55..b760e5d201e85 100644 --- a/src/coreclr/jit/optimizer.cpp +++ b/src/coreclr/jit/optimizer.cpp @@ -2649,7 +2649,11 @@ bool Compiler::optIsLoopEntry(BasicBlock* block) const { for (unsigned char loopInd = 0; loopInd < optLoopCount; loopInd++) { - // Traverse the outermost loops as entries into the loop nest; so skip non-outermost. + if ((optLoopTable[loopInd].lpFlags & LPFLG_REMOVED) != 0) + { + continue; + } + if (optLoopTable[loopInd].lpEntry == block) { return true;