-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add additional binary operations into the RangeCheck analysis.
GT_LSH and GT_MUL are now covered in the range analysis check. This allows to catch and eliminate the range check for cases like ``` ReadOnlySpan<byte> readOnlySpan => new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; byte byt = 0; for (int i = 0; i < 5; i++) { byt = readOnlySpan[i * 3]; // ... } ``` or ``` bool[] flags = new bool[Size + 1]; for (int i = 2; i <= Size; i++) { for (int k = i * 2; k <= Size; k += i) { flags[k] = false; } } ``` Note that without this change, the previous snippet would not eliminate the range check on `flags[k]`, but the equivalent snippet would ``` for (int i = 2; i <= Size; i++) { for (int k = i + i; k <= Size; k += i) { flags[k] = false; } } ``` as additional was implemented in the range check analysis, but multiply was not.
- Loading branch information
1 parent
c397327
commit ebc2288
Showing
2 changed files
with
183 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters