-
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 SuperPMIin-prThere is an active PR which will close this issue when it is mergedThere is an active PR which will close this issue when it is merged
Milestone
Description
If we have:
void Test(int[] arr, int i)
{
arr[i + 0] = 0;
arr[i + 1] = 0;
arr[i + 2] = 0;
arr[i + 3] = 0;
}Which generates a single BasicBlock with either multiple statements or a single statement with multiple COMMAs containing STOREIND node, we should be able to just clone it and remove all bound checks in the fast path:
public void Test(int[] arr, int i)
{
if (i >= 0 && i < arr.Length - 3)
{
// Fast path: no bounds checks
arr[i + 0] = 0;
arr[i + 1] = 0;
arr[i + 2] = 0;
arr[i + 3] = 0;
}
else
{
// Slow fallback
arr[i + 0] = 0;
arr[i + 1] = 0;
arr[i + 2] = 0;
arr[i + 3] = 0;
}
}So, essentially, a loop clonning but for non-loop stuff.
cc @dotnet/jit-contrib opinions? such patterns aren't uncommon in BCL
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 SuperPMIin-prThere is an active PR which will close this issue when it is mergedThere is an active PR which will close this issue when it is merged