dotnet / dotnet/runtime

Eliminate bound checks for "% arr.Length" when possible

Open
#130,155 4 comments 0 reactions 1 assignee Claimed by @henriquewr View on GitHub
area-CodeGen-coreclr tenet-performance
Dominant language
C#
Stars
18.3k
Forks
5.6k
PR merge metrics
PR metrics pending

Description

The idea is to eliminate bound checks for:

`arr[(int)index % arr.Length]` when `index >= 0`

As discussed in the pr, the support of these will not be added:
`arr[arr.Length % (int)index]` when `arr.Length > 0 and index <= arr.Length`

`arr[(uint)arr.Length % (uint)index]` when `arr.Length > 0 and index <= arr.Length`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.