]> git.lizzy.rs Git - rust.git/blob - library/portable-simd/crates/core_simd/src/comparisons.rs
Rollup merge of #85766 - workingjubilee:file-options, r=yaahc
[rust.git] / library / portable-simd / crates / core_simd / src / comparisons.rs
1 use crate::simd::intrinsics;
2 use crate::simd::{LaneCount, Mask, Simd, SimdElement, SupportedLaneCount};
3
4 impl<T, const LANES: usize> Simd<T, LANES>
5 where
6     T: SimdElement + PartialEq,
7     LaneCount<LANES>: SupportedLaneCount,
8 {
9     /// Test if each lane is equal to the corresponding lane in `other`.
10     #[inline]
11     pub fn lanes_eq(self, other: Self) -> Mask<T::Mask, LANES> {
12         unsafe { Mask::from_int_unchecked(intrinsics::simd_eq(self, other)) }
13     }
14
15     /// Test if each lane is not equal to the corresponding lane in `other`.
16     #[inline]
17     pub fn lanes_ne(self, other: Self) -> Mask<T::Mask, LANES> {
18         unsafe { Mask::from_int_unchecked(intrinsics::simd_ne(self, other)) }
19     }
20 }
21
22 impl<T, const LANES: usize> Simd<T, LANES>
23 where
24     T: SimdElement + PartialOrd,
25     LaneCount<LANES>: SupportedLaneCount,
26 {
27     /// Test if each lane is less than the corresponding lane in `other`.
28     #[inline]
29     pub fn lanes_lt(self, other: Self) -> Mask<T::Mask, LANES> {
30         unsafe { Mask::from_int_unchecked(intrinsics::simd_lt(self, other)) }
31     }
32
33     /// Test if each lane is greater than the corresponding lane in `other`.
34     #[inline]
35     pub fn lanes_gt(self, other: Self) -> Mask<T::Mask, LANES> {
36         unsafe { Mask::from_int_unchecked(intrinsics::simd_gt(self, other)) }
37     }
38
39     /// Test if each lane is less than or equal to the corresponding lane in `other`.
40     #[inline]
41     pub fn lanes_le(self, other: Self) -> Mask<T::Mask, LANES> {
42         unsafe { Mask::from_int_unchecked(intrinsics::simd_le(self, other)) }
43     }
44
45     /// Test if each lane is greater than or equal to the corresponding lane in `other`.
46     #[inline]
47     pub fn lanes_ge(self, other: Self) -> Mask<T::Mask, LANES> {
48         unsafe { Mask::from_int_unchecked(intrinsics::simd_ge(self, other)) }
49     }
50 }