-
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 SuperPMIgood first issueIssue should be easy to implement, good for first-time contributorsIssue should be easy to implement, good for first-time contributors
Milestone
Description
Given this code:
bool BothZero(int i, int j) => i == 0 && j == 0;
bool BothGTZ(int i, int j) => i >= 0 && j >= 0;The JIT optimises BothZero with:
L0000: or edx, ecx
L0002: sete al
L0005: movzx eax, al
L0008: retHowever BothGTZ introduces branching:
L0000: test ecx, ecx
L0002: jl short L000c
L0004: mov eax, edx
L0006: not eax
L0008: shr eax, 0x1f
L000b: ret
L000c: xor eax, eax
L000e: retThe branchless form, equivalent to C# (i | j) >= 0 could have better performance here:
L0000: or edx, ecx
L0002: mov eax, edx
L0004: not eax
L0006: shr eax, 0x1f
L0009: retcategory:cq
theme:basic-cq
skill-level:beginner
cost:small
impact:small
Naidile-P-N
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 SuperPMIgood first issueIssue should be easy to implement, good for first-time contributorsIssue should be easy to implement, good for first-time contributors