Repository navigation
JIT: rework optCanonicalizeLoop - #70792
Conversation
Rework loop canonicalization in anticipation of extending it to handle non-loop edges like those seen in dotnet#70569. The code to fix up flow out of `h` was not needed and has been removed; we now assert upstream that no such fix up will be needed.
commented
Jun 15, 2022
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch Issue DetailsRework loop canonicalization in anticipation of extending it to handle The code to fix up flow out of
|
commented
Jun 15, 2022
|
@BruceForstall PTAL No diffs expected. |
| modified = true; | ||
| } | ||
| } | ||
| bool modified = optCanonicalizeLoop(loopInd); |
There was a problem hiding this comment.
I didn't understand why the check of if (optLoopTable[loopInd].lpTop->bbNatLoopNum != loopInd) was removed although the comment says "For loopInd and all contained loops, ensures each loop top's back edges do not come from nested loops."
There was a problem hiding this comment.
We were checking this redundantly; now we just check it down in optCanonicalizeLoop.
I may move that check back up to the caller with my next round of revisions, but the point is we don't need to check it twice.
commented
Jun 15, 2022
|
msbuild crashed building linker tests. should be an issue with the dotnet host and this PR. Am going to retry. |
| // Canonicalize the loop nest rooted at parent loop 'loopInd'. | ||
| // Returns 'true' if the flow graph is modified. | ||
| //----------------------------------------------------------------------------- | ||
| // optCanonicalizeLoop: Canonicalize a loop nest |
There was a problem hiding this comment.
| // optCanonicalizeLoop: Canonicalize a loop nest | |
| // optCanonicalizeLoopNest: Canonicalize a loop nest |
| if (optCanonicalizeLoopNest(child)) | ||
| { | ||
| modified = true; | ||
| } | ||
| modified |= optCanonicalizeLoopNest(child); |
There was a problem hiding this comment.
fwiw, I prefer the previous expression.
There was a problem hiding this comment.
Odd that reply ended up there.
In the follow-on changes there will be more reasons to canonicalize loops and pre-screening for them all starts to get clunky.
| BlockToBlockMap* const blockMap = new (getAllocator(CMK_LoopOpt)) BlockToBlockMap(getAllocator(CMK_LoopOpt)); | ||
| blockMap->Set(t, newT); | ||
| optRedirectBlock(b, blockMap); | ||
| JITDUMP("Redirecting top->bottom backedge " FMT_BB " -> " FMT_BB " to " FMT_BB " -> " FMT_BB "\n", b->bbNum, |
There was a problem hiding this comment.
| JITDUMP("Redirecting top->bottom backedge " FMT_BB " -> " FMT_BB " to " FMT_BB " -> " FMT_BB "\n", b->bbNum, | |
| JITDUMP("Redirecting bottom->top backedge " FMT_BB " -> " FMT_BB " to " FMT_BB " -> " FMT_BB "\n", b->bbNum, |
There was a problem hiding this comment.
Maybe we should just add this output to optRedirectBlock at the point where bbJumpDest or >bbJumpSwt->bbsDstTab[i] is set.
There was a problem hiding this comment.
We could, but we won't have a friendly name for the edge unless the caller passes one.
| JITDUMP("in optCanonicalizeLoop: 'top' predecessor " FMT_BB " is in the range of " FMT_LP " (" FMT_BB | ||
| ".." FMT_BB "); not redirecting its bottom edge\n", | ||
| topPredBlock->bbNum, loopInd, t->bbNum, b->bbNum); | ||
| // Note we've already redirected t->b above. |
There was a problem hiding this comment.
| // Note we've already redirected t->b above. | |
| // Note we've already redirected b->t above. |
Rework loop canonicalization in anticipation of extending it to handle
non-loop edges like those seen in #70569.
The code to fix up flow out of
hwas not needed and has been removed;we now assert upstream that no such fix up will be needed.