-
Notifications
You must be signed in to change notification settings - Fork 5.2k
JIT: Optimize SSA #94672
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: Optimize SSA #94672
Conversation
* Stop considering "successor EH successors" to be EH successors of each block. Instead, add this special case where it is actually needed: when computing the dominator tree. * Update PHI arg insertion to insert the handler phi args with the 'try' entry block as the pred instead of the pred of the 'try' * Optimize computation of the dominator tree to avoid multiple enumerations of the preds * Optimize computation of the dominator tree to utilize computed postorder indices for "visited" checks, instead of a block set A few minor diffs are expected in some cases due to building a different block visit order in VN.
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch Issue Details
A few minor diffs are expected in some cases due to building a different block visit order in VN.
|
@@ -1311,7 +1298,7 @@ void SsaBuilder::AddPhiArgsToSuccessors(BasicBlock* block) | |||
GenTreePhi* phi = tree->AsLclVar()->Data()->AsPhi(); | |||
unsigned ssaNum = m_renameStack.Top(lclNum); | |||
|
|||
AddPhiArg(handlerStart, stmt, phi, lclNum, ssaNum, block); | |||
AddPhiArg(handlerStart, stmt, phi, lclNum, ssaNum, succ); |
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.
This seemed a bit questionable before -- e.g. for
x = 123;
try
{
M();
x = 456;
M();
}
catch
{
}
we would have no phi arg in the handler indicating that the value of x
could be 123
even if control came from the try
block (note that we did have the value, but only from the pred outside the try
).
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.
So this changes the catch from something like
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 don't have
/azp run runtime-coreclr jitstress, runtime-coreclr libraries-jitstress, Fuzzlyn |
Azure Pipelines successfully started running 3 pipeline(s). |
cc @dotnet/jit-contrib PTAL @AndyAyersMS Diffs. Minor codegen diffs from the removal of successors leading to a new order built by VN (some of these will probably go away with #94623), otherwise just throughput improvements. The Fuzzlyn failures are #94660 and #94680. The linux-arm32 failure is known. |
…uccessor-eh-successors
Merged up and pushed, but it passed jitstress/libraries-jitstress/Fuzzlyn on the previous commit. I'm expecting fewer (or no) diffs now with #94623 included, will double check why they are there tomorrow if there still are some. |
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.
Very nice improvement. Great to see us leveraging reverse postorder information like this.
{ | ||
DBG_SSA_JITDUMP("Pred block is " FMT_BB ".\n", predBlock->bbNum); | ||
} | ||
if ((numIters <= 0) && (domPred->bbPostorderNum <= (unsigned)i)) |
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.
This <= 0
confused me for a second, maybe == 0
?
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.
You're not the first to be confused by my use of <= 0
for these kinds of comparisons, so maybe I should switch to ==
in the future. But let me avoid rerunning CI for it here.
Hmm, the diffs now look like something I need to fix in assertion prop. In this code: runtime/src/coreclr/tools/Common/JitInterface/CorInfoImpl_generated.cs Lines 1536 to 1548 in 81393b7
we now seem to be able to prove that _this is non-null inside the catch, from the non-null assertion generated by the instance call inside the try . That's odd since that assertion shouldn't be live into the try. I'll take a closer look.
|
Seems like the data flow of assertion prop reasons that since the assertion is live out of all preds of the handler, we don't need to even consider the handler. But that's not how data flow for handlers works. |
The Assertion prop also uses CSE also uses |
The remaining diffs now seem to be from LSRA using Using successors to avoid inserting these seems like an approximation, in reality the precise thing would be to check if any of the remaining blocks in linear order has the local as live-in. So I don't think there is a correctness issue here. |
A few minor diffs are expected in some cases due to building a different block visit order in VN.