-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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 SuperPMIhelp wanted[up-for-grabs] Good issue for external contributors[up-for-grabs] Good issue for external contributors
Milestone
Description
This example is a derivative of one from wikipedia:
[Benchmark]
public int Example()
{
int a = 30;
int b = 9 - (a / 5);
int c;
c = b * 4;
if (c > 10)
{
c = c - 10;
}
return c * (60 / a);
}The JIT successfully reduces the entire operation to mov eax, 4, but it leaves behind multiple computations that would seem to no longer be necessary:
; .NET 6.0.0 (6.0.21.40103), X64 RyuJIT
; Program.Example()
mov ecx,1E
mov eax,3C
xor edx,edx
idiv ecx
mov eax,4
ret
; Total bytes of code 20Is there some kind of side effect it's relying on from all the earlier gunk, or should it be removing the mov, mov, xor, idiv and just isn't? Note that if I tweak the C# to make int a = 30 be const int a = 30, then all the extra operations go away as expected.
category:cq
theme:value-numbering
skill-level:expert
cost:medium
impact:medium
am11
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 contributors
Type
Projects
Status
Done