Skip to content

Conversation

@LaurenzV
Copy link
Collaborator

@LaurenzV LaurenzV commented Jan 3, 2026

As per title, by having this, we don't have to store them back using copy_from_slice (which may or may not optimize into vector store instructions) but can use methods that use the corresponding intrinsics under the hood.

@LaurenzV LaurenzV requested review from Ralith and valadaptive January 3, 2026 09:29
@LaurenzV
Copy link
Collaborator Author

LaurenzV commented Jan 3, 2026

(Will add changeling entry upon approval.)

Comment on lines +170 to +173
/// Store a SIMD vector into a slice.
///
/// The slice must be the proper width.
fn store_slice(&self, slice: &mut [Self::Element]);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should rename to store_into_slice?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think store_slice is fine.

@LaurenzV LaurenzV changed the title Add store methods to use intrinsics for storing vectors back to memory Add methods for storing vectors back to memory Jan 3, 2026
Copy link
Contributor

@valadaptive valadaptive left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good! Just a few minor code style nits.

/// `[f32; 4]` for `f32x4<S>`) or a reference to it.
AsArray { kind: RefKind },
/// Takes a vector and a mutable reference to an array, and stores the vector elements into the array.
ToArray,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this should be renamed StoreArray?

} else {
let blocks = (0..block_count).map(|n| {
let offset = n * num_scalars_per_block;
let block_idx = proc_macro2::Literal::usize_unsuffixed(n);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason to use usize_unsuffixed here specifically? It definitely results in nicer generated code but we don't seem to use it in many other places.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does seem to be used in various places, no? 🤔

image

Comment on lines +170 to +173
/// Store a SIMD vector into a slice.
///
/// The slice must be the proper width.
fn store_slice(&self, slice: &mut [Self::Element]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think store_slice is fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants