-
Notifications
You must be signed in to change notification settings - Fork 5k
Enable eliding some bounds checks in the jit #36263
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
PTAL @dotnet/jit-contrib |
Overall it looks good, thank you @nathan-moore.
but there are a few regressions, that happens when we create a new function instead of a better old variant.
where LCL_VAR is a result of ADD:
your new condition catches it when without your changes we were creating
? I attached the regressed method logs. Full diffs: |
@briansull how would you choose where to put that check? |
As far as I can tell by grepping around the code, Const_Loop_Bnd and Bound_Oper_Bnd are only consumed by rangecheck. In the example you linked, (and in the regressions from the framework), we now remove the range check in those cases. Something just goes awry after that. I compared the lir after lowering in the case you linked, and the only difference I saw was the removal of the range check. That leads me to think it's a register allocation oddity caused by removing the check, which would explain the new spilling, but I could be missing something as that's a bit odd. If you have ideas, I can look into them more.
I tried moving it to where you suggested and didn't see a difference (I also don't expect it to make a difference). I can move it if you think that location is better; I only put it where it is currently due to symmetry. |
You are right, I have another example when with your changes we don't remove null check on a call anymore, but on the second look we were reaching assertion limit there and that is why we did not create a constant assertion there (Microsoft.CodeAnalysis.VisualBasic.Binder:ReportOverloadResolutionFailureForASingleCandidate, Windows x64), so just a side-effect that should not be fixed. |
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
Thanks @nathan-moore! |
For loop conditionals like i < bnd +- k, fix up assertion prop to generate Bound Oper Bnd assertions instead of Const Loop Bnd assertions.
When checking the range of a tree, handle comma nodes.
Add logging for when the jit bails due to encountering a negative constant.
This removes bound checks from the first two cases in #31638.
I also see it enabling removing a couple of other bounds check types, like the ones here with the index casted to a byte:
runtime/src/libraries/Common/src/System/Net/CaseInsensitiveAscii.cs
Lines 90 to 97 in 6a48efa
The assembly diff is available here.
The two method regressions seem to be caused by register allocation. One of them is here if you wish to peruse through it.