Make bitcast() work in generic contexts, remove reinterpret_* methods - #284
Merged
Conversation
…e to treat it as a u8 vector in generic code. Requires a type system recursion workaround.
Merged
LaurenzV
approved these changes
Jul 27, 2026
LaurenzV
left a comment
Collaborator
There was a problem hiding this comment.
Nice! Bonus points for maybe letting AI code up some examples that use reinterpret before vs. after and making sure there are no obvious regressions in assembly, but here I'm less concerned than in #286, so it should be fine.
Contributor
Author
|
I had Codex do that before opening the PR and the assembly is identical, but self-contained examples always optimize well, so that's neither here nor there. I see Vello has a few reinterpret calls, so I'll port it to this PR, disassemble the relevant functions and compare before and after. |
# Conflicts: # CHANGELOG.md # fearless_simd_gen/src/mk_simd_trait.rs # fearless_simd_tests/tests/generics.rs
Shnatsel
added a commit
to Shnatsel/fearless_simd
that referenced
this pull request
Jul 27, 2026
The relationships that already hold for all types are now encoded in the type system, to allow more things to be expressed in generic code. Adds tests to enforce that this kind of generic code will keep compiling. Unlike linebender#284 this is not a breaking change because all the relevant traits are sealed (except SimdFrom but the change involving it is non-breaking).
Contributor
Author
|
This optimizes fine, save for a register allocation perturbation in one function on AVX-512 only: linebender/vello#1773 |
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Jul 28, 2026
Shnatsel
enabled auto-merge
July 28, 2026 15:42
pull Bot
pushed a commit
to Mu-L/vello
that referenced
this pull request
Jul 31, 2026
…nder#1773) Adjusts for linebender/fearless_simd#284 `bitcast()` was already present in earlier versions, so this still works with fearless_simd v0.4, all the way to the upcoming v0.7 The generated assembly is identical on SSE4.2 and AVX2. AVX-512 adds two register moves in the large function `pt_splat_simd` gets inlined into because the change perturbed the IR and resulted in different register allocator choices.
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.
Motivated by #simd > Missing reinterpret_u64_* methods on Simd trait
bitcast()work in generic contexts on variable-width vectorsSelf::u8sas theirBytesrepresentation, which avoids arcane boundscvt_to/from_bytesimplementations, use safe transmute to implement them insteadreinterpretandtransmutetobitcastto make it more discoverable via search