-
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
JIT: remove bound check for negated ranges #96123
Conversation
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch Issue DetailsCloses #96046 byte Test(int a) => rva[8 - (a & 7)];
static ReadOnlySpan<byte> rva => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];Was: ; Method Program:Test(int):ubyte:this (FullOpts)
sub rsp, 40
and ecx, 7
mov eax, ecx
neg eax
add eax, 8
cmp eax, 10
jae SHORT G_M949_IG04
mov rcx, 0x1735CBE29D0
movzx rax, byte ptr [rax+rcx]
add rsp, 40
ret
G_M949_IG04:
call CORINFO_HELP_RNGCHKFAIL
int3
; Total bytes of code 44Now: ; Method Program:Test(int):ubyte:this (FullOpts)
sub rsp, 40
and edx, 7
mov eax, edx
neg eax
add eax, 8
mov rcx, 0x228C6572A20
movzx rax, byte ptr [rax+rcx]
add rsp, 40
ret
; Total bytes of code: 33
|
src/coreclr/jit/rangecheck.h
Outdated
| result.lLimit = Limit(Limit::keConstant, -range.UpperLimit().GetConstant()); | ||
| result.uLimit = Limit(Limit::keConstant, -range.LowerLimit().GetConstant()); |
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.
Can either the existing upper or lower limit be INT_MIN, in which case -INT_MIN == INT_MIN?
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.
I wasn't able to repro such a case, but added a check just in case 👍

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.

Closes #96046
Was:
Now: