-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JIT: update debug dumping for loop hoisting #59287
Conversation
I kept adding stuff like this whenever I wanted to understand why hosting was doing what it was doing, so figured it likely had lasting value.
Tagging subscribers to this area: @JulieLeeMSFT Issue DetailsI kept adding stuff like this whenever I wanted to understand why hosting was
|
@BruceForstall PTAL Sample jit dump fragment
Note we skip hosting from the inner loop block BB03 because it is conditionally executed. Added todos to the code for this (echoing some of what's over in #35735). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for doing this!
src/coreclr/jit/optimizer.cpp
Outdated
@@ -5688,6 +5691,7 @@ void Compiler::optHoistLoopCode() | |||
{ | |||
if (optLoopTable[lnum].lpFlags & LPFLG_REMOVED) | |||
{ | |||
JITDUMP("\nLoop L%02u was removed\n", lnum); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We now have FMT_LP
src/coreclr/jit/optimizer.cpp
Outdated
@@ -5746,7 +5750,7 @@ void Compiler::optHoistLoopCode() | |||
void Compiler::optHoistLoopNest(unsigned lnum, LoopHoistContext* hoistCtxt) | |||
{ | |||
// Do this loop, then recursively do all nested loops. | |||
CLANG_FORMAT_COMMENT_ANCHOR; | |||
JITDUMP("\n%s L%02u\n", optLoopTable[lnum].lpParent == BasicBlock::NOT_IN_LOOP ? "Loop Nest" : "Nested Loop", lnum); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
src/coreclr/jit/optimizer.cpp
Outdated
ArrayStack<BasicBlock*> defExec(getAllocatorLoopHoist()); | ||
if (pLoopDsc->lpFlags & LPFLG_ONE_EXIT) | ||
{ | ||
assert(pLoopDsc->lpExit != nullptr); | ||
JITDUMP(" Only considering hosting in blocks that dominate exit block " FMT_BB "\n", pLoopDsc->lpExit->bbNum); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: hosting
src/coreclr/jit/optimizer.cpp
Outdated
@@ -5947,12 +5970,16 @@ void Compiler::optHoistThisLoop(unsigned lnum, LoopHoistContext* hoistCtxt) | |||
// If we didn't reach the entry block, give up and *just* push the entry block. | |||
if (cur != pLoopDsc->lpEntry) | |||
{ | |||
JITDUMP(" -- odd, we didn't reach entry from exit via dominators. Only considering hosting in entry " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: hosting
src/coreclr/jit/optimizer.cpp
Outdated
defExec.Reset(); | ||
} | ||
defExec.Push(pLoopDsc->lpEntry); | ||
} | ||
else // More than one exit | ||
{ | ||
JITDUMP(" only considering hosting in entry block " FMT_BB "\n", pLoopDsc->lpEntry->bbNum); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: hosting
src/coreclr/jit/optimizer.cpp
Outdated
@@ -6032,6 +6059,8 @@ bool Compiler::optIsProfitableToHoistableTree(GenTree* tree, unsigned lnum) | |||
// Don't hoist expressions that are not heavy: tree->GetCostEx() < (2*IND_COST_EX) | |||
if (tree->GetCostEx() < (2 * IND_COST_EX)) | |||
{ | |||
JITDUMP(" tree cost too low: %d < %d (lvc %u >= arc %u)\n", tree->GetCostEx(), 2 * IND_COST_EX, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO, spelling out the variables here would be better. (same below)
src/coreclr/jit/optimizer.cpp
Outdated
@@ -6415,6 +6475,7 @@ void Compiler::optHoistLoopBlocks(unsigned loopNum, ArrayStack<BasicBlock*>* blo | |||
if (!child.m_invariant) | |||
{ | |||
treeIsInvariant = false; | |||
INDEBUG(failReason = "variant child";); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I presume you only need one of the semicolons (here and below)
Oh, I was going to use "Loop Hoisting" as an example of a jit area that needs more diagnostic info in my write-up 😐 |
I kept adding stuff like this whenever I wanted to understand why hosting was
doing what it was doing, so figured it likely had lasting value.