[−][src]Macro safe_arch::shuffle_m128d
Shuffles the lanes around.
This is a macro because the shuffle pattern must be a compile time constant, and Rust doesn't currently support that for functions.
Two m128d
Inputs
You can provide two m128d
arguments, in which case:
- The lane lane of the output comes from
$a
, as picked by$z
(Zero) - The high lane of the output comes from
$b
, as picked by$o
(One) $a
and$b
must obviously bem128d
expressions.- Both of the lane selection values is a lane index (
0..2
). They can be any integer type as long as they're same type. Out of bounds index values are wrapped to just the low bit. - The lane selection values are combined into a private
const
which is computed at compile time and then used at runtime. This means that you can use literals, but you can also use the names of other constants or even aconst fn
expression, if that is somehow is useful to you.
let a = m128d::from_array([1.0, 2.0]); let b = m128d::from_array([3.0, 4.0]); // let c = shuffle_m128d!(a, b, 0, 0).to_array(); assert_eq!(c, [1.0, 3.0]); // let c = shuffle_m128d!(a, b, 0, 1).to_array(); assert_eq!(c, [1.0, 4.0]);
One m128
Input
You can provide one m128d
argument, in which case the above variant is
called with $a
as the input to both sides of the shuffle (note that any
potential side effects of evaluating $a
are executed only once).
let a = m128d::from_array([1.0, 2.0]); // let c = shuffle_m128d!(a, 0, 0).to_array(); assert_eq!(c, [1.0, 1.0]); // let c = shuffle_m128d!(a, 0, 1).to_array(); assert_eq!(c, [1.0, 2.0]);