-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Open
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 SuperPMIhelp wanted[up-for-grabs] Good issue for external contributors[up-for-grabs] Good issue for external contributorstenet-performancePerformance related issuePerformance related issue
Description
Description
Given operations like x *= -1, it appears JIT currently does not reduce this operation, using costlier FP multiplication.
Clang/LLVM:
double negate_mul(double num) {
return num * -1;
}
double negate(double num) {
return -num;
}.LCPI0_0:
.quad 0x8000000000000000
.quad 0x8000000000000000
negate_mul:
xorps xmm0, xmmword ptr [rip + .LCPI0_0]
ret
.LCPI1_0:
.quad 0x8000000000000000
.quad 0x8000000000000000
negate:
xorps xmm0, xmmword ptr [rip + .LCPI1_0]
ret
RyuJIT:
static double NegateMul(double num) => num * -1;
static double Negate(double num) => -num;// coreclr trunk-20251207+86dfeb91ce270da17416069463e33363bda3ec55
Program:.ctor():this (FullOpts):
ret
Program:NegateMul(double):double (FullOpts):
vmulsd xmm0, xmm0, qword ptr [reloc @RWD00]
ret
RWD00 dq BFF0000000000000h ; -1
Program:Negate(double):double (FullOpts):
vxorps xmm0, xmm0, xmmword ptr [reloc @RWD00]
ret
RWD00 dq 8000000000000000h, 8000000000000000h
BoyBaykiller and colejohnson66
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 SuperPMIhelp wanted[up-for-grabs] Good issue for external contributors[up-for-grabs] Good issue for external contributorstenet-performancePerformance related issuePerformance related issue