Skip to content

Conversation

@tomcur
Copy link
Member

@tomcur tomcur commented Jan 23, 2026

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 stays at the same bit width and has the sign behavior that's probably expected here.

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.
@tomcur tomcur enabled auto-merge January 24, 2026 10:08
@tomcur tomcur added this pull request to the merge queue Jan 24, 2026
Merged via the queue into linebender:main with commit fa2c255 Jan 24, 2026
18 checks passed
@tomcur tomcur deleted the push-txvnrukntqzq branch January 24, 2026 10:12
tomcur added a commit to tomcur/fearless_simd that referenced this pull request Jan 25, 2026
github-merge-queue bot pushed a commit that referenced this pull request Jan 25, 2026
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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants