Skip to content

JIT doesn't see real type of field in a shared generic type with exact context #96787

@EgorBo

Description

@EgorBo

Filed for #96773

JIT doesn't see real type of the arr field and doesn't fold the condition.

public class MyList<T>
{
    public T[] arr;
}

bool Test(MyList<string> list) => list.arr.GetType() == typeof(string[]);

Current codegen for Test:

; Method Program:Foo(MyList`1[System.String]):ubyte:this (FullOpts)
G_M55733_IG01:
G_M55733_IG02:
       mov      rax, gword ptr [rdx+0x08]
       mov      rcx, 0xD1FFAB1E      ; System.String[]
       cmp      qword ptr [rax], rcx
       sete     al
       movzx    rax, al
G_M55733_IG03:
       ret      
; Total bytes of code: 24

Expected codegen:

nullchecks
return true;

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
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions