Neighboring bounds checks aren't collapsed #109983
Labels
area-CodeGen-coreclr
CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
tenet-performance
Performance related issue
Milestone
Description
Given the following code:
The only way for this method to fail a bounds/range check is if
span.Length < 4
. As such, I'd expect the runtime to optimize to something like this:Instead, the runtime generates this:
Note the four range checks against
esi
. Failures all call intoCORIFNO_HELP_RNGCHKFAIL
with no indication of which failed. As such, I'd expect the four compare+branch blocks to collapse into a singular one like this:Configuration
Godbolt Compiler Explorer against "trunk" (e33be4d)
Regression?
No. Present in net7.0.19 and net8.0.5.
Notes
Interestingly, a naive loop generates nearly the same assembly, but sets up and tears down a frame:
The text was updated successfully, but these errors were encountered: