-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Bounds checks on array/span not eliminated after length check #10596
Copy link
Copy link
Closed
Labels
JitUntriagedCLR JIT issues needing additional triageCLR JIT issues needing additional triagearea-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 SuperPMIenhancementProduct code improvement that does NOT require public API changes/additionsProduct code improvement that does NOT require public API changes/additionsoptimization
Milestone
Metadata
Metadata
Assignees
Labels
JitUntriagedCLR JIT issues needing additional triageCLR JIT issues needing additional triagearea-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 SuperPMIenhancementProduct code improvement that does NOT require public API changes/additionsProduct code improvement that does NOT require public API changes/additionsoptimization
Type
Fields
Give feedbackNo fields configured for issues without a type.
I've got code similar to the following repro:
I was hoping/expecting the bounds checks on each of those four writes to dst to be eliminated, but they’re not:
To work around that, I can use Unsafe.Add and MemoryMarshal.GetReference, e.g.
in which case I get the better:
but it’d be nice not to have to use Unsafe for cases like this.
cc: @AndyAyersMS
Related: https://github.com/dotnet/coreclr/issues/12639
category:cq
theme:range-check
skill-level:intermediate
cost:medium