Open
Description
My most common use case is for saturating narrowing casts, such as from i16
to u8
. It would be great to take advantage of native instructions without first having to use simd_clamp
. saturating_cast
would reduce code and chances of errors from clamping with incorrect values.
I'm not sure about the availability of this feature on other architectures. It might make sense to split this for narrowing and widening features based on availability. I'm not familiar with other architectures, but it looks like ARM has narrowing casts with VQMOVN
/VQMOVUN
.
Perhaps there could be a fallback which does simd_clamp().cast()
(or other optimal construction) for architectures that don't have these instructions.