-
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
Description
Description
Consider the following three methods:
public static int TwoCalls(int a)
{
var one = One(a);
if (one > 0)
{
return one;
}
return Two(a);
}
[MethodImpl(MethodImplOptions.NoInlining)]
public static int One(int a) => a;
[MethodImpl(MethodImplOptions.NoInlining)]
public static int Two(int a) => a;Today (tested on 3ae36b5 via Disasmo), the following code is generated for TwoCalls on x64:
G_M61010_IG01:
push rsi
sub rsp, 32
mov esi, ecx
;; bbWeight=1 PerfScore 1.50
G_M61010_IG02:
mov ecx, esi
call ThrowawayTesting.Program:One(int):int
test eax, eax
jle SHORT G_M61010_IG04
;; bbWeight=1 PerfScore 2.50
G_M61010_IG03:
add rsp, 32
pop rsi
ret
;; bbWeight=0.50 PerfScore 0.88
G_M61010_IG04:
mov ecx, esi
;; bbWeight=0.50 PerfScore 0.12
G_M61010_IG05:
add rsp, 32
pop rsi
jmp ThrowawayTesting.Program:Two(int):intAs can be seen, for each path, parameter in rcx is first moved to rsi and then moved back to rcx, causing the method to also save and restore rsi (which is undesirable, especially when more parameters are involved).
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
Type
Projects
Status
Done