-
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 SuperPMI
Milestone
Description
This is not a particularly common pattern, but it is a missed optimization all the same.
Consider:
public static int Array_NE(byte[] src)
{
int sum = 0;
for (int i = 0; i != src.Length; i++)
sum += src[i];
return sum;
}
public static int Array_LT(byte[] src)
{
int sum = 0;
for (int i = 0; i < src.Length; i++)
sum += src[i];
return sum;
}A bounds check is eliminated for the second method but not the first.
Applies to T[], string, Span<T>, ReadOnlySpan<T>, etc.
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 SuperPMI