Intrinsify Span.Slice(int,int) for Span[X..]#122065
Intrinsify Span.Slice(int,int) for Span[X..]#122065EgorBo wants to merge 6 commits intodotnet:mainfrom
Conversation
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
|
@EgorBo I do believe that static ReadOnlySpan<byte> Foo(ReadOnlySpan<byte> data)
{
if (data.Length < sizeof(ushort))
throw new ArgumentException("Data is too short", nameof(data));
var header = MemoryMarshal.Read<ushort>(data);
if (data.Length < sizeof(ushort) + header)
{
throw new ArgumentException("Data is too short for header", nameof(data));
}
return data.Slice(sizeof(ushort), header);
}Ideally there should be no bound checks inserted by the jit. This can be extrapolated further to include multiple data sections/slices |
|
Top regression method is funny :) Reducing those throw calls to 1 could easily result in an improvement |
It is, but this PR was targeting a very specific pattern emitted by
No clue why those tails were not merged |
|
@EgorBo I wonder if results are much better now after your tail merge fix |
|
I wonder if there is a conceptual difference between |
Should be the same thing |
|
Interesting. If you look at |
|
Draft Pull Request was automatically closed for 30 days of inactivity. Please let us know if you'd like to reopen it. |
|
Draft Pull Request was automatically closed for 30 days of inactivity. Please let us know if you'd like to reopen it. |
Closes #121987
Closes #122042
Just an experiment, if dotnet/roslyn#81485 lands, we can delete/ignore this (or intrinsify Slice anyway since it's a popular operation in general)