-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
[RyuJIT][ARM] Redundant overflow check in "C / X" #46010
Comments
Un-assigning myself |
@TIHan are you actively looking at this? Otherwise could we assign it to @SwapnilGaikwad |
I marked it as future, but if you all want to look at it that is fine with me. If you have any questions, I am happy to answer. |
That's great. I'll take a look then. |
This part was fixed by #75272
This part is a much bigger fix. After the CIL has been parsed into IR, the array.Length has been turned into an indirect load, and there is nothing to indicate that it's different to any other indirect load. You would need to add something into the IR to indicate the value is >=0 during parsing. #64795 is a similar at first glance, but it doesn't really overlap with this. My thought would be to solve this with a new gtFlag entry. You could have GT_IS_GE_0 and GT_IS_GT_0. Both of these could then be used in other optimisations eg: to get rid of some comparisons. However, I'm not sure how many other places we can guarantee that a value is >0 or >=0. If it's small, then I doubt the work here is worthwhile. |
Current arm64 codegen:
As far as I understand overflow can only happen if we divide
int.MinValue
by-1
so it's not the case forC / x
whereC
is notint.MinValue
Also,
GT_ARRLEN
can't be-1
andint.MinValue
so e.g.array.Length % x
orx % array.Length
shouldn't produce any overflow checks as well.category:cq
theme:div-mod-rem
skill-level:intermediate
cost:medium
impact:medium
The text was updated successfully, but these errors were encountered: