-
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 SuperPMIenhancementProduct code improvement that does NOT require public API changes/additionsProduct code improvement that does NOT require public API changes/additionsoptimizationtenet-performancePerformance related issuePerformance related issue
Milestone
Description
Sample C# code:
struct Number {
private double value;
public static implicit operator Number(double value) {
return new Number { value = value };
}
public static implicit operator double (Number number) {
return number.value;
}
public static Number operator +(Number x, Number y) {
return x.value + y.value;
}
}
class Program {
static int Main() {
Number x = 4, y = 2;
return (int)(x + y);
}
}A portion of the generated code:
vmovsd xmm0,qword ptr [rsp+20h]
vaddsd xmm0,xmm0,mmword ptr [rsp+18h]
xor eax,eax
mov qword ptr [rsp+10h],rax
mov qword ptr [rsp+10h],rax
vmovsd qword ptr [rsp+10h],xmm0
mov rax,qword ptr [rsp+10h]
mov qword ptr [rsp+38h],rax
mov rax,qword ptr [rsp+38h]
mov qword ptr [rsp+8],rax
vmovsd xmm0,qword ptr [rsp+8]
vcvttsd2si eax,xmm0
If int is used intstead of double or if double is used directly instead of Number then the generated code is simply mov eax, 6.
category:cq
theme:structs
skill-level:expert
cost:medium
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 SuperPMIenhancementProduct code improvement that does NOT require public API changes/additionsProduct code improvement that does NOT require public API changes/additionsoptimizationtenet-performancePerformance related issuePerformance related issue