Repository navigation
Add signed/unsigned casting - #435
Conversation
Shnatsel
left a comment
There was a problem hiding this comment.
I like the direction. This doesn't conflict with #439 as far as I can tell.
Personally I find the SimdInt/SimdUint split in std::simd cumbersome. It makes docs harder to navigate and makes abstracting over signedness much more difficult.
I think the generic bounds could be strengthened, I've left inline comments on the relevant code.
Please add tests that pin down behavior in edge cases so we don't break it accidentally in the future.
|
Done. I added a few more bounds than you suggested. For example, I strengthened the bounds around masks. This should allow users to share masks between signed and unsigned vectors without issue. I also strengthened the bounds of |
Shnatsel
left a comment
There was a problem hiding this comment.
Looks good now. Thank you!
|
@Shnatsel Do you want to merge? I might cut a new release today or tomorrow. |
|
SGTM. After you publish I might write a blog post for linebender.org about the progress since 1.0 |
This PR adds
SimdInt::{Signed, Unsigned, cast_signed, cast_unsigned}to allow users to cast the signedness of a vector without needing to name the target vector type. Similar to #420.I also added
SimdInt::unsigned_abs()because it's trivial to implement using the new APIs.I'm thinking of this PR as prep for
abs_diff, but I'm not sure if this is the right approach long term. IMO,std::simd's traitsSimdIntandSimdUintare much more elegant, but it's a little late for that now. Except if we add traits liketrait SimdSigned: SimdIntandtrait SimdUnsigned: SimdIntand move all sign-specific operations there.Ideas very welcome.