Skip to content

Casting via generic math doesn't always inline in R2R #84421

Closed
@xtqqczze

Description

@xtqqczze

Related: #78648.

uint M0() => uint.CreateTruncating(42u);
uint M1() => uint.CreateTruncating((byte)42);
uint M2() => uint.CreateTruncating(42UL);
uint M3() => uint.CreateTruncating(42);
uint M4() => uint.CreateTruncating((sbyte)42);
int M5() => int.CreateTruncating(42);
int M6() => int.CreateTruncating((sbyte)42);
int M7() => int.CreateTruncating(42L);
int M8() => int.CreateTruncating(42u);
int M9() => int.CreateTruncating((byte)42);
// crossgen2 8.0.0-preview.4.23206.99+18e2c5fd9e2239a8b06fe49dbb6492d40f5e5e19

C:M0():uint:this:
; Emitting BLENDED_CODE for X64 CPU with SSE2 - Unix
						;; size=0 bbWeight=1 PerfScore 0.00
       mov      eax, 42
						;; size=5 bbWeight=1 PerfScore 0.25
       ret      
						;; size=1 bbWeight=1 PerfScore 1.00

C:M1():uint:this:
; Emitting BLENDED_CODE for X64 CPU with SSE2 - Unix
						;; size=0 bbWeight=1 PerfScore 0.00
       lea      rax, [(reloc)]
       mov      edi, 42
						;; size=12 bbWeight=1 PerfScore 0.75
       tail.jmp [rax]System.UInt32:CreateTruncating[ubyte](ubyte):uint
						;; size=3 bbWeight=1 PerfScore 2.00

C:M2():uint:this:
; Emitting BLENDED_CODE for X64 CPU with SSE2 - Unix
						;; size=0 bbWeight=1 PerfScore 0.00
       lea      rax, [(reloc)]
       mov      edi, 42
						;; size=12 bbWeight=1 PerfScore 0.75
       tail.jmp [rax]System.UInt32:CreateTruncating[ulong](ulong):uint
						;; size=3 bbWeight=1 PerfScore 2.00

C:M3():uint:this:
; Emitting BLENDED_CODE for X64 CPU with SSE2 - Unix
						;; size=0 bbWeight=1 PerfScore 0.00
       lea      rax, [(reloc)]
       mov      edi, 42
						;; size=12 bbWeight=1 PerfScore 0.75
       tail.jmp [rax]System.UInt32:CreateTruncating[int](int):uint
						;; size=3 bbWeight=1 PerfScore 2.00

C:M4():uint:this:
; Emitting BLENDED_CODE for X64 CPU with SSE2 - Unix
						;; size=0 bbWeight=1 PerfScore 0.00
       lea      rax, [(reloc)]
       mov      edi, 42
						;; size=12 bbWeight=1 PerfScore 0.75
       tail.jmp [rax]System.UInt32:CreateTruncating[byte](byte):uint
						;; size=3 bbWeight=1 PerfScore 2.00

C:M5():int:this:
; Emitting BLENDED_CODE for X64 CPU with SSE2 - Unix
						;; size=0 bbWeight=1 PerfScore 0.00
       mov      eax, 42
						;; size=5 bbWeight=1 PerfScore 0.25
       ret      
						;; size=1 bbWeight=1 PerfScore 1.00

C:M6():int:this:
; Emitting BLENDED_CODE for X64 CPU with SSE2 - Unix
						;; size=0 bbWeight=1 PerfScore 0.00
       lea      rax, [(reloc)]
       mov      edi, 42
						;; size=12 bbWeight=1 PerfScore 0.75
       tail.jmp [rax]System.Int32:CreateTruncating[byte](byte):int
						;; size=3 bbWeight=1 PerfScore 2.00

C:M7():int:this:
; Emitting BLENDED_CODE for X64 CPU with SSE2 - Unix
						;; size=0 bbWeight=1 PerfScore 0.00
       lea      rax, [(reloc)]
       mov      edi, 42
						;; size=12 bbWeight=1 PerfScore 0.75
       tail.jmp [rax]System.Int32:CreateTruncating[long](long):int
						;; size=3 bbWeight=1 PerfScore 2.00

C:M8():int:this:
; Emitting BLENDED_CODE for X64 CPU with SSE2 - Unix
						;; size=0 bbWeight=1 PerfScore 0.00
       lea      rax, [(reloc)]
       mov      edi, 42
						;; size=12 bbWeight=1 PerfScore 0.75
       tail.jmp [rax]System.Int32:CreateTruncating[uint](uint):int
						;; size=3 bbWeight=1 PerfScore 2.00

C:M9():int:this:
; Emitting BLENDED_CODE for X64 CPU with SSE2 - Unix
						;; size=0 bbWeight=1 PerfScore 0.00
       lea      rax, [(reloc)]
       mov      edi, 42
						;; size=12 bbWeight=1 PerfScore 0.75
       tail.jmp [rax]System.Int32:CreateTruncating[ubyte](ubyte):int
						;; size=3 bbWeight=1 PerfScore 2.00

https://csharp.godbolt.org/z/K6xM8hP6P

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions