-
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: Sparse conditional propagation in value numbering #94563
JIT: Sparse conditional propagation in value numbering #94563
Conversation
Utilize the fact that VN is able to decide whether many non-trivial branches will be taken or not taken to prove basic blocks dynamically unreachable. Take this into account when building PHIs. Fix dotnet#94559
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch Issue DetailsUtilize the fact that VN is able to decide whether many non-trivial branches will be taken or not taken to prove basic blocks dynamically unreachable. Take this into account when building PHIs. Fix #94559 There are some additional improvements to make:
|
It would also be possible to add some of RBO's smarts in here to make it even stronger, of course at a TP cost. |
/azp run runtime-coreclr jitstress, runtime-coreclr libraries-jitstress |
Azure Pipelines successfully started running 2 pipeline(s). |
/azp run Fuzzlyn |
Azure Pipelines successfully started running 1 pipeline(s). |
The assert that the phi loop found a phi could be hit in cases where a block had a statically unreachable pred. In that case SSA may not have added any PHI arg for that pred, and if we then proved all other preds unreachable, we would end up with no VN for a phi. Fix it by using the value of the last phi arg in those cases.
/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. Mostly dominated by tests, in the real world I think the PHI disambiguation that RBO does handles most cases already. However, doing it this way in VN is naturally more precise. I want to try moving some of RBO's smarts to VN (at least the simple dominator checks). TP regressions weren't as bad as I expected, so I didn't bother to do more work to optimize the TP. I also ended up not doing the work to switch to a precomputed RPO. I still want to do that, but as a follow-up. |
continue; | ||
} | ||
|
||
JITDUMP(" ..but it looks like all preds are unreachable, so we are using it anyway\n"); |
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.
Maybe add a comment that since we're quite sure this block is unreachable it's ok to use a somewhat arbitrary VN for the PHI? Can add it later if you're going to tweak nearby code again soon (for rbo say).
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.
Will do that in the follow-up.
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.
Changes LGTM.
If you did switch over to the new RPO you could identify statically unreachable blocks. But maybe these are rare. At any rate rather than tolerate them here we probably should get rid of them before (or just after) we build SSA; it has identified these blocks too.
Yeah, I'll make use of that in the follow-up. |
Utilize the fact that VN is able to decide whether many non-trivial branches will be taken or not taken to prove basic blocks dynamically unreachable. Take this into account when building PHIs.
Fix #94559
There are some additional improvements to make:
I couldn't figure out how to look up the predecessor corresponding to a memory PHI arg, so currently we do not do this for memory PHIs.Adding the pred blocks for these and making use of them has almost no diffs, so doesn't seem worth it.Codegen of the example from #94559 before:
Codegen after: