Skip to content

JIT: nullcheck is not folded for PHI #104489

@EgorBo

Description

@EgorBo

Seems like global assertprop bails out on the following snippet

bool Test(bool cond)
{
    object tmp;
    if (cond)
        tmp = "1111";
    else
        tmp = "2222";
    return tmp != null;
}

Current codegen:

; Assembly listing for method Proga:Test(ubyte):ubyte (FullOpts)
G_M26246_IG01:  ;; offset=0x0000
G_M26246_IG02:  ;; offset=0x0000
       mov      rax, 0x20000209798      ; '2222'
       mov      rdx, 0x200002097B8      ; '1111'
       test     cl, cl
       cmovne   rax, rdx
       test     rax, rax
       setne    al
       movzx    rax, al
G_M26246_IG03:  ;; offset=0x0023
       ret      

Expected codegen:

; Assembly listing for method Proga:Test(ubyte):ubyte (FullOpts)
G_M26246_IG01:  ;; offset=0x0000
G_M26246_IG02:  ;; offset=0x0000
       mov      eax, 1
G_M26246_IG03:  ;; offset=0x0023
       ret      

Metadata

Metadata

Assignees

Labels

area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMIin-prThere is an active PR which will close this issue when it is merged

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions