Ideally the following two methods should generate similar code.
[MethodImpl(MethodImplOptions.NoInlining)]
static Span<int> TrimFirstLast_OpenCoded(Span<int> s) => s.Slice(1, s.Length - 1);
[MethodImpl(MethodImplOptions.NoInlining)]
static Span<int> TrimFirstLast_Range(Span<int> s) => s[Range.Create(1, new Index(1, true))];
Currently the Range-based version runs into a number of issues:
cc @stephentoub
Will fill in more details later.
Marking as 3.0 for now.
category:cq
theme:optimization
skill-level:expert
cost:large
Ideally the following two methods should generate similar code.
Currently the
Range-based version runs into a number of issues:Ranges are not promotable (fixed via JIT: allow slightly more general promotion of structs with struct fields coreclr#22867)Indexconstructor is blocking enregistration of fields (similar byref on IL stack across branch exposure issue as we saw in Improve perf for Index based span indexers coreclr#21196) (fixed in Index and Range updates coreclr#22331)Rangeenregistration (8 byte structs are returned by-value, so jit “retypes” the two adjacent ints in a Range as a long).cc @stephentoub
Will fill in more details later.
Marking as 3.0 for now.
category:cq
theme:optimization
skill-level:expert
cost:large