Fix tree threading in fgOptimizeBranch#51422
Merged
BruceForstall merged 1 commit intodotnet:mainfrom Apr 17, 2021
Merged
Conversation
In case `fgOptimizeBranch` gets far enough to calculate the cost of statements it is considering duplicating, then it calls `gtPrepareCost` => `gtSetEvalOrder` to compute a statement's costs. Unfortunately, that can reverse operands (and in this case, did). `fgOptimizeBranch` is called only by `fgReorderBlocks` which is called by `fgInsertGCPolls`, late enough that the tree is already threaded with gtNext/gtPrev links. (The test case inserted multiple GC polls for SuppressGCTransitionAttribute code.) When the operands of the tree were swapped, nobody fixed up these links. The only other caller of `fgReorderBlocks` is `optOptimizeLayout`, which comes before the trees are threaded. The solution is to simply call `fgSetStmtSeq` if needed. No SPMI x86, x64 asm diffs. Fixes dotnet#51293, a failure in JIT/Performance/CodeQuality/Burgers/Burgers/Burgers.sh on Linux arm32 under JitStress=1. There is IBC data, and setting `COMPlus_JitDisablePgo=1` also fixes the failure.
Contributor
Author
|
@AndyAyersMS @dotnet/jit-contrib PTAL |
Contributor
Author
|
/azp run runtime-coreclr outerloop |
Contributor
Author
|
/azp run runtime-coreclr jitstress |
|
Azure Pipelines successfully started running 1 pipeline(s). |
1 similar comment
|
Azure Pipelines successfully started running 1 pipeline(s). |
AndyAyersMS
approved these changes
Apr 17, 2021
Member
AndyAyersMS
left a comment
There was a problem hiding this comment.
LGTM.
We really ought to find a way to cost trees without having this happen.
Contributor
Author
|
outerloop failures are #51430 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In case
fgOptimizeBranchgets far enough to calculate the cost ofstatements it is considering duplicating, then it calls
gtPrepareCost=>gtSetEvalOrderto compute a statement's costs. Unfortunately, thatcan reverse operands (and in this case, did).
fgOptimizeBranchiscalled only by
fgReorderBlockswhich is called byfgInsertGCPolls,late enough that the tree is already threaded with gtNext/gtPrev links.
(The test case inserted multiple GC polls for SuppressGCTransitionAttribute
code.) When the operands of the tree were swapped, nobody fixed up these links.
The only other caller of
fgReorderBlocksisoptOptimizeLayout, whichcomes before the trees are threaded.
The solution is to simply call
fgSetStmtSeqif needed.No SPMI x86, x64 asm diffs.
Fixes #51293, a failure in JIT/Performance/CodeQuality/Burgers/Burgers/Burgers.sh
on Linux arm32 under JitStress=1. There is IBC data, and setting
COMPlus_JitDisablePgo=1also fixes the failure.