Skip to content

Conversation

@valadaptive
Copy link
Contributor

Stacked on top of #116, because it touches some of the codegen stuff I cleaned up in that PR. it's unfortunate that GitHub doesn't have stacked PRs.

We have the Bytes trait, which lets us cast SIMD types to and from raw bytes (currently using mem::transmute). We can use its bitcast method instead of pulling in bytemuck for the "reinterpret" operations on Fallback.

On the x86 side, we can use the _mm_cast[...] intrinsics. All the x86 integer types are __m128i or __m256i, so conversions between integer widths are no-ops.

While working on this, I noticed that there are "reinterpret signed as unsigned" ops, but no corresponding "reinterpret unsigned as signed" ops. Are the reinterpret ops worth it at this point if we have the Bytes trait?

@valadaptive valadaptive requested a review from DJMcNab November 12, 2025 19:44
@DJMcNab
Copy link
Member

DJMcNab commented Nov 12, 2025

Initial reaction from a skim is that this seems reasonable and much more ergonomic. In #simd > ✔ Using `bytemuck`, we discussed using bytemuck for the operations which require unsafe (i.e. implementing Bytes). That would be especially neat in a post-#108 world, where everything would then be validated.

The changes in this PR are however pretty orthogonal to that. Using the appropriate SIMD intrinsic does make sense (especially if we get something like #simd > Function call ABI).
Otherwise I can't approve because of the stacking.

@valadaptive
Copy link
Contributor Author

I think we can reintroduce bytemuck in the future to back the Bytes trait if we want to avoid transmutes (although since the types are numeric, from_ne_bytes()/to_ne_bytes() should work).

I'll request a re-review once everything else is merged.

@valadaptive
Copy link
Contributor Author

This is ready to review now.

Copy link
Collaborator

@LaurenzV LaurenzV left a comment

Choose a reason for hiding this comment

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

Lovely, thanks!

@valadaptive valadaptive added this pull request to the merge queue Nov 16, 2025
Merged via the queue into linebender:main with commit 2c1ae23 Nov 16, 2025
18 checks passed
@valadaptive valadaptive deleted the no-bytemuck branch November 16, 2025 10:21
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.

3 participants