Skip to content

JIT: cmp + jump + jump #101160

@EgorBo

Description

@EgorBo

From: #101153

[MethodImpl(MethodImplOptions.NoInlining)]
static void Foo<T>() => Bar<T>();

[MethodImpl(MethodImplOptions.NoInlining)]
static void Bar<T>() { }

Codegen for Foo<_Canon> in Tier1:

; Assembly listing for method Prog:Foo[System.__Canon]() (FullOpts)
; FullOpts code
       sub      rsp, 40
       mov      qword ptr [rsp+0x20], rcx
       mov      rdx, qword ptr [rcx+0x38]
       mov      rdx, qword ptr [rdx+0x10]
       test     rdx, rdx
       je       SHORT G_M2381_IG04
       jmp      SHORT G_M2381_IG05
G_M2381_IG04:
       mov      rdx, 0x7FFE1F42D630 
       call     CORINFO_HELP_RUNTIMEHANDLE_METHOD
       mov      rdx, rax
G_M2381_IG05:
       mov      rcx, rdx
       call     [Prog:Bar[System.__Canon]()]
       nop      
       add      rsp, 40
       ret      

this block:

       test     rdx, rdx
       je       SHORT G_M2381_IG04
       jmp      SHORT G_M2381_IG05
G_M2381_IG04:

seems like it's better to be re-ordered to:

       test     rdx, rdx
       jne       SHORT G_M2381_IG05
G_M2381_IG04:

@amanasifkhalid something you might find interesting to take a look since it's block re-ordering. cc @dotnet/jit-contrib

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions