-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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 optReachable with excluded block check #51842
Conversation
`optReachable` is used by the redundant branch optimizer to try and determine if the successors of some dominating block can reach a target block. In doing so, we can exclude paths from a successor that must pass back through the dominating block to reach the target block. This lets us remove some redundant branches in loops that we were missing because we over-estimated reachability.
cc @dotnet/jit-contrib Simple example where this kicks in: public static int F(int x)
{
int r = 0;
for (int i = 0; i < 50; i++)
{
if (x != 0) continue;
r++;
if (x != 0) continue;
r++;
}
return r;
} Here the jit was unable to prove the second [edit: had the wrong graph here initially] While trying to prove that the branch at D would make the branch at S1 redundant, the jit was considering the path S2 -> D -> S1, and so decided both S1 and S2 could reach S1, and hence the value of The fix is to designate D as an excluded block, so that the jit only considers paths that do not pass through D. A moderate number of diffs, largely improvements. The largest improvements are cases where blocks with some substantial computation (newarr) are now unreachable. The two largest regressions (see libraries pmi) are case where the RA creates large numbers of compensation blocks. asm.aspnet.run.windows.x64.checked
Detail diffs
asm.benchmarks.run.windows.x64.checked
Detail diffs
asm.libraries.crossgen.windows.x64.checked
Detail diffs
asm.libraries.crossgen2.windows.x64.checked
Detail diffs
asm.libraries.pmi.windows.x64.checked
Detail diffs
asm.tests.pmi.windows.x64.checked
Detail diffs
asm.tests_libraries.pmi.windows.x64.checked
Detail diffs
|
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
Improvement: DrewScoggins/performance-2#5563 |
optReachable
is used by the redundant branch optimizer to try and determineif the successors of some dominating block can reach a target block.
In doing so, we can exclude paths from a successor that must pass
back through the dominating block to reach the target block.
This lets us remove some redundant branches in loops that we were missing
because we over-estimated reachability.