KEMBAR78
Use BoundsCheckNoThrow assertion in optAssertionProp_RangeProperties by EgorBo · Pull Request #102089 · dotnet/runtime · GitHub
Skip to content

Conversation

@EgorBo
Copy link
Member

@EgorBo EgorBo commented May 10, 2024

Closes #102088

int Test(Span<int> x, int y) => x[y] + (y % 8);
; Method Bench:Test(System.Span`1[int],int):int:this (FullOpts)
       sub      rsp, 40
       cmp      r8d, dword ptr [rdx+0x08]
       jae      SHORT G_M45212_IG04
       mov      rax, bword ptr [rdx]
       mov      ecx, r8d
-      mov      edx, r8d
-      sar      edx, 31
-      and      edx, 7
-      add      edx, r8d
-      and      edx, -8
-      sub      r8d, edx
+      and      r8d, 7
       add      r8d, dword ptr [rax+4*rcx]
       mov      eax, r8d
       add      rsp, 40
       ret      
G_M45212_IG04:
       call     CORINFO_HELP_RNGCHKFAIL
       int3     
-; Total bytes of code: 52
+; Total bytes of code: 38

@ghost ghost added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label May 10, 2024
@EgorBo EgorBo marked this pull request as ready for review May 10, 2024 19:39
@EgorBo EgorBo requested review from AndyAyersMS and jakobbotsch May 10, 2024 21:55
@EgorBo
Copy link
Member Author

EgorBo commented May 10, 2024

@AndyAyersMS @jakobbotsch @dotnet/jit-contrib PTAL

@EgorBo EgorBo merged commit bdfbed6 into dotnet:main May 11, 2024
@EgorBo EgorBo deleted the improve-optAssertionProp_RangeProperties branch May 11, 2024 10:45
@github-actions github-actions bot locked and limited conversation to collaborators Jun 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JIT is missing a common case to track the IsNeverNegative assertion

3 participants