Use safe spans in BigInteger RightShiftSelf#127409
Open
EgorBo wants to merge 4 commits intodotnet:mainfrom
Open
Use safe spans in BigInteger RightShiftSelf#127409EgorBo wants to merge 4 commits intodotnet:mainfrom
EgorBo wants to merge 4 commits intodotnet:mainfrom
Conversation
Rewrite the vectorized in-place shift helpers to consume Span<nuint> slices and Vector*.Create/CopyTo instead of ref arithmetic with LoadUnsafe/StoreUnsafe. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors the vectorized BigIntegerCalculator shift-in-place helpers to use span slicing plus Vector*.Create(ReadOnlySpan<T>) and CopyTo, removing the prior MemoryMarshal.GetReference + LoadUnsafe/StoreUnsafe approach.
Changes:
- Reworked
LeftShiftSelfto operate over a shrinkingSpan<nuint>window from the high end usingVector512/256/128.CreateandCopyTo. - Reworked
RightShiftSelfto operate over an advancingSpan<nuint>window from the low end usingVector512/256/128.CreateandCopyTo. - Removed the now-unneeded
System.Runtime.InteropServicesusing.
Member
Author
Restore LeftShiftSelf to the main-branch implementation so PR 127409 only changes RightShiftSelf. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Member
Author
MihaZupan
approved these changes
Apr 25, 2026
09d8387 to
b30f3f8
Compare
…ordinates Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note
This PR description was generated by GitHub Copilot.
Summary
RightShiftSelfto use slicedSpan<nuint>inputs withVector*.CreateandCopyToLeftShiftSelfunchanged frommainLoadUnsafe/StoreUnsafepattern from the right-shift vector loopValidation
dotnet.cmd build src\libraries\System.Runtime.Numerics\src\System.Runtime.Numerics.csproj -v:minimaldotnet.cmd build /t:test src\libraries\System.Runtime.Numerics\tests\System.Runtime.Numerics.Tests.csproj -v:minimal(3033 tests, 0 failed)Diffs - improvements.