Open MichalPetryka opened 1 year ago
From what I see there are two issues here: 1) https://github.com/dotnet/runtime/issues/67270 (that I tried to fix via https://github.com/dotnet/runtime/pull/67281) 2) https://github.com/dotnet/runtime/issues/35748 (range check elimination gives up on non-tracked pinned locals)
so presumably we can close this as dup
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch, @kunalspathak See info in area-owners.md if you want to be subscribed.
Author: | MichalPetryka |
---|---|
Assignees: | - |
Labels: | `tenet-performance`, `area-CodeGen-coreclr`, `untriaged` |
Milestone: | - |
From what I see there are two issues here:
- Redundant bound check for span.Length == 0 pattern #67270 (that I tried to fix via JIT: Normalize "X==/!=0" in VN #67281)
- Extra bound checks are not eliminated for pinning #35748 (range check elimination gives up on non-tracked pinned locals)
so presumably we can close this as dup
I don't think either talks about just ldelem
and ldelema
?
Setting to future to improve this code quality issue.
Description
ldelem
andldelema
without an explicit length check assume that array length can be negative and emitjbe
instead ofje
like in case of a manual one (see linked SharpLab Ldelem* methods).In case of array pinning, this leads to array length being checked twice which results in an always false check and a dead throw branch being emitted (see Array method).
Configuration
SharpLab Core CLR 7.0.122.56804 on x64
Regression?
I don't know
Data
SharpLab
Analysis
Citing @EgorBo from discord: