Add alignment parameter to simd_masked_{load,store}#147355
Merged
bors merged 3 commits intorust-lang:masterfrom Nov 5, 2025
Merged
Add alignment parameter to simd_masked_{load,store}#147355bors merged 3 commits intorust-lang:masterfrom
simd_masked_{load,store}#147355bors merged 3 commits intorust-lang:masterfrom
Conversation
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.
This PR adds an alignment parameter in
simd_masked_loadandsimd_masked_store, in the form of a const-generic enumcore::intrinsics::simd::SimdAlign. This represents the alignment of theptrargument in these intrinsics as followsSimdAlign::Unaligned-ptris unaligned/1-byte alignedSimdAlign::Element-ptris aligned to the element type of the SIMD vector (default behavior in the old signature)SimdAlign::Vector-ptris aligned to the SIMD vector typeThe main motive for this is stdarch - most vector loads are either fully aligned (to the vector size) or unaligned (byte-aligned), so the previous signature doesn't cut it.
Now, stdarch will mostly use
SimdAlign::UnalignedandSimdAlign::Vector, whereas portable-simd will useSimdAlign::Element.cg_llvmcg_clifmiri/const_evalAlternatives
Using a const-generic/"const"
u32parameter as alignment (and we error during codegen if this argument is not a power of two). This, although more flexible than this, has a few drawbacksalign_of::<T>()as the alignment, which isn't possible without GCEWe can remedy the problem with the const-generic
u32parameter by adding a special rule for the element alignment case (e.g.0can mean "use the alignment of the element type), but I feel like this is not as expressive as the enum approach, although I am open to suggestionscc @workingjubilee @RalfJung @BoxyUwU