-
Notifications
You must be signed in to change notification settings - Fork 22
Simplify some shift casting #186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
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
This is in preparation for bumping the lint set, which will include `clippy::cast_possible_wrap`. For the fallback code using `Shl`, we don't need to cast as `Shl` is implemented for all scalar types as shift argument. Casting versus calling directly compile to the same thing: https://godbolt.org/z/6G9bvYdjd. For the x86 code, we cast from `u32` to `i32`, so we can use `u32::cast_signed` for that, which explicitly is a no-op and has the overflow behavior that's probably expected here.
LaurenzV
approved these changes
Jan 23, 2026
tomcur
added a commit
to tomcur/fearless_simd
that referenced
this pull request
Jan 25, 2026
Missed this in linebender#186.
github-merge-queue bot
pushed a commit
that referenced
this pull request
Jan 25, 2026
Missed this in #186.
tomcur
added a commit
to tomcur/fearless_simd
that referenced
this pull request
Jan 25, 2026
Like linebender#186, explicitly reinterpret the bit patterns as signed (i.e., this is explicitly a no-op at the instruction-level). Also uses `cast_signed` for splatting on x86, which just broadcasts the bit pattern. Fixes the remainder of `clippy::cast_possible_wrap` warnings on x86.
tomcur
added a commit
to tomcur/fearless_simd
that referenced
this pull request
Jan 25, 2026
Like linebender#186, explicitly reinterpret the bit patterns as signed (i.e., this is explicitly a no-op at the instruction-level). Also uses `cast_signed` for splatting on x86, which just broadcasts the bit pattern. Fixes the remainder of `clippy::cast_possible_wrap` warnings on x86.
tomcur
added a commit
to tomcur/fearless_simd
that referenced
this pull request
Jan 25, 2026
Like linebender#186, explicitly reinterpret the bit patterns as signed (i.e., this is explicitly a no-op at the instruction-level). Also uses `cast_signed` for splatting on x86, which just broadcasts the bit pattern. Fixes the remainder of `clippy::cast_possible_wrap` warnings on x86.
tomcur
added a commit
to tomcur/fearless_simd
that referenced
this pull request
Jan 25, 2026
Like linebender#186, explicitly reinterpret the bit patterns as signed (i.e., this is explicitly a no-op at the instruction-level). Also uses `cast_signed` for splatting on x86, which just broadcasts the bit pattern. Fixes the remainder of `clippy::cast_possible_wrap` warnings on x86.
github-merge-queue bot
pushed a commit
that referenced
this pull request
Jan 25, 2026
This fixes the remainder of `clippy::cast_possible_wrap` warnings on x86. Very similarly to #186, explicitly reinterpret these bit patterns as signed (i.e., this again is explicitly a no-op at the instruction-level, but effectively checks bit width remains the same). Also uses `cast_signed` for splatting on x86, which just takes the bit pattern as a signed numeric type for broadcasting.
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 is in preparation for bumping the lint set, which will include
clippy::cast_possible_wrap.For the fallback code using
Shl, we don't need to cast asShlis implemented for all scalar types as shift argument. Casting versus calling directly compile to the same thing:https://godbolt.org/z/6G9bvYdjd.
For the x86 code, we cast from
u32toi32, so we can useu32::cast_signedfor that, which explicitly stays at the same bit width and has the sign behavior that's probably expected here.