-
Notifications
You must be signed in to change notification settings - Fork 5k
Fix tree threading in fgOptimizeBranch #51422
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
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.
@AndyAyersMS @dotnet/jit-contrib PTAL |
/azp run runtime-coreclr outerloop |
/azp run runtime-coreclr jitstress |
Azure Pipelines successfully started running 1 pipeline(s). |
1 similar comment
Azure Pipelines successfully started running 1 pipeline(s). |
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.
LGTM.
We really ought to find a way to cost trees without having this happen.
outerloop failures are #51430 |
In case
fgOptimizeBranch
gets far enough to calculate the cost ofstatements it is considering duplicating, then it calls
gtPrepareCost
=>gtSetEvalOrder
to compute a statement's costs. Unfortunately, thatcan reverse operands (and in this case, did).
fgOptimizeBranch
iscalled only by
fgReorderBlocks
which 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
fgReorderBlocks
isoptOptimizeLayout
, whichcomes before the trees are threaded.
The solution is to simply call
fgSetStmtSeq
if 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=1
also fixes the failure.