Skip to content

Strange boxing deopt #82291

Closed
Closed
@NinoFloris

Description

@NinoFloris

Description

Given the following code, only the first function optimizes acceptably here. I'm not quite sure why it can't kick in for the other cases?

Reproduction Steps

public class C {
    
    [SharpLab.Runtime.JitGeneric(typeof(int))]
    public bool GetValueOrNull<T>()
    {
        if (default(T) != null)
         return true;
         
       return false;
    }    
    
    [SharpLab.Runtime.JitGeneric(typeof(int))]
    public bool GetValueOrNullSlow<T>()
    {
        if (default(T) != null)
         return false;
         
       return false;
    }    

    
    [SharpLab.Runtime.JitGeneric(typeof(int))]
    public void GetValueOrNullSlow2<T>()
    {
        if (default(T) != null)
         return;
         
       return;
    }    
}

https://sharplab.io/#v2:EYLgxg9gTgpgtADwGwBYA0AXEBDAzgWwB8ABAJgEYBYAKGIAYACY8gOgCUBXAOwwEt8YLAMIR8AB14AbGFADKMgG68wMXAG4a9JuQCsG6poDMTUgyEMA3jQY2G12wG1ZAC2xQxAGWzB23PgJYAKV4MAHEYLhllAAoMAE8xGAgAM2jeHgBKDIBdextiY2AICEkGcIwANWxJDhgAeSgAOQ5JSQAeABUAPmiMvMt+2wZeZIZogBMYZOwWjGiOjIYAQgBeBi4WyT7qId3iAHYGDCha/V2hwfzD6clcGDPbAF8Lndt+p1d3Lx9OHn5BYJhCJRMCxBJJVLpDBZXKvfKFYqlcpVGr1JqbWSSCAAd06PW2QyscN2IzGk2ms3mi1W602BPOVwYNzuDwZlyY12qLP6zzeBmJ7xcbk83l8fwCgPCkSgMXiiRSaUyOX6BSYKDKMEq1VqDWarUxONIeN6/SJDOGowmUxmkjmC2Waw2rXpDIOrPO7LdPJejyAA

Expected behavior

GetValueOrNullSlow and GetValueOrNullSlow2 are both optimized like GetValueOrNull

Actual behavior

They don't

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

No response

Metadata

Metadata

Labels

area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMIhelp wanted[up-for-grabs] Good issue for external contributorsin-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