]> git.proxmox.com Git - rustc.git/blame - vendor/packed_simd/src/api/ops/vector_neg.rs
Update upstream source from tag 'upstream/1.52.1+dfsg1'
[rustc.git] / vendor / packed_simd / src / api / ops / vector_neg.rs
CommitLineData
f20569fa
XL
1//! Vertical (lane-wise) vector `Neg`.
2
3macro_rules! impl_ops_vector_neg {
4 ([$elem_ty:ident; $elem_count:expr]: $id:ident | $test_tt:tt) => {
5 impl crate::ops::Neg for $id {
6 type Output = Self;
7 #[inline]
8 fn neg(self) -> Self {
9 Self::splat(-1 as $elem_ty) * self
10 }
11 }
12 test_if!{
13 $test_tt:
14 paste::item! {
15 pub mod [<$id _ops_vector_neg>] {
16 use super::*;
17 #[cfg_attr(not(target_arch = "wasm32"), test)] #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
18 fn neg() {
19 let z = $id::splat(0 as $elem_ty);
20 let o = $id::splat(1 as $elem_ty);
21 let t = $id::splat(2 as $elem_ty);
22 let f = $id::splat(4 as $elem_ty);
23
24 let nz = $id::splat(-(0 as $elem_ty));
25 let no = $id::splat(-(1 as $elem_ty));
26 let nt = $id::splat(-(2 as $elem_ty));
27 let nf = $id::splat(-(4 as $elem_ty));
28
29 assert_eq!(-z, nz);
30 assert_eq!(-o, no);
31 assert_eq!(-t, nt);
32 assert_eq!(-f, nf);
33
34 assert_eq!(z, -nz);
35 assert_eq!(o, -no);
36 assert_eq!(t, -nt);
37 assert_eq!(f, -nf);
38 }
39 }
40 }
41 }
42 };
43}