Skip to content
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: branch is not removed after a bounds check #109962

Open
EgorBo opened this issue Nov 19, 2024 · 1 comment
Open

JIT: branch is not removed after a bounds check #109962

EgorBo opened this issue Nov 19, 2024 · 1 comment
Assignees
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
Milestone

Comments

@EgorBo
Copy link
Member

EgorBo commented Nov 19, 2024

void Test(int[] arr)
{
    arr[10] = 0;
    if (arr.Length < 5)
    {
        Console.WriteLine("dead branch");
    }
}

Codegen:

; Method Program:Foo(int[]):this (FullOpts)
G_M33786_IG01:
       sub      rsp, 40
G_M33786_IG02: 
       mov      ecx, dword ptr [rdx+0x08]
       cmp      ecx, 10
       jbe      SHORT G_M33786_IG06
       xor      eax, eax
       mov      dword ptr [rdx+0x38], eax
       cmp      ecx, 5
       jl       SHORT G_M33786_IG04
G_M33786_IG03:
       add      rsp, 40
       ret      
G_M33786_IG04:
       mov      rcx, 0x210000055C8      ; 'Hello'
G_M33786_IG05:
       add      rsp, 40
       tail.jmp [System.Console:WriteLine(System.String)]
G_M33786_IG06:
       call     CORINFO_HELP_RNGCHKFAIL
       int3     
; Total bytes of code: 53

The branch with Console.WriteLine is still there.

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Nov 19, 2024
@EgorBo EgorBo self-assigned this Nov 19, 2024
@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Nov 19, 2024
@EgorBo EgorBo added this to the Future milestone Nov 19, 2024
@EgorBo EgorBo removed the untriaged New issue has not been triaged by the area owner label Nov 19, 2024
Copy link
Contributor

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
Projects
None yet
Development

No branches or pull requests

1 participant