-
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 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
Consider:
using System.Runtime.CompilerServices;
class Program
{
static void Main()
{
Mod(123);
Cast(123);
And(123);
}
[MethodImpl(MethodImplOptions.NoInlining)] static byte Cast(uint i) => (byte)(i);
[MethodImpl(MethodImplOptions.NoInlining)] static byte And(uint i) => (byte)(i & 0xFF);
[MethodImpl(MethodImplOptions.NoInlining)] static byte Mod(uint i) => (byte)(i % 256);
}For Cast and And I get:
0FB6C1 movzx rax, cl
C3 ret
but for Mod I get:
81E1FF000000 and ecx, 255
0FB6C1 movzx rax, cl
C3 ret
Is there a reason that extra and instruction needs to exist?
category:cq
theme:basic-cq
skill-level:intermediate
cost:medium
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