-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Closed
Labels
area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMICLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMItenet-performancePerformance related issuePerformance related issue
Milestone
Description
Description
using System.Runtime.CompilerServices;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
byte Create<T>(T value)
{
return Unsafe.As<T, byte>(ref value);
}
Console.WriteLine(Create(500));
Console.WriteLine(Create(500L));JIT dump:
mov dword ptr [rsp+0x44], 0x1f4
movzx ecx, byte ptr [rsp+0x44]
call System.Console.WriteLine(Int32)
mov qword ptr [rsp+0x38], 0x1f4
movzx ecx, byte ptr [rsp+0x38]
call System.Console.WriteLine(Int32)
I think the ref can be omitted so that value won't be spilled to stack,
which is expected to be (on a little endian system):
mov ecx, 0xf4
call System.Console.WriteLine(Int32)
mov ecx, 0xf4
call System.Console.WriteLine(Int32)
Configuration
Version: .NET 6 preview 5
Tiered Compilation: off
category:cq
theme:codegen
skill-level:intermediate
cost:small
impact:medium
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMICLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMItenet-performancePerformance related issuePerformance related issue