Skip to content

Commit caef17d

Browse files
folkertdevAmanieu
authored andcommitted
add vec_cmpeq and vec_cmpne
1 parent 3913435 commit caef17d

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed

crates/core_arch/src/s390x/vector.rs

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3389,6 +3389,54 @@ mod sealed {
33893389
vector_unsigned_long_long
33903390
vector_double
33913391
}
3392+
3393+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
3394+
pub trait VectorEquality: Sized {
3395+
type Result;
3396+
3397+
#[inline]
3398+
#[target_feature(enable = "vector")]
3399+
unsafe fn vec_cmpeq(self, other: Self) -> Self::Result {
3400+
simd_eq(self, other)
3401+
}
3402+
3403+
#[inline]
3404+
#[target_feature(enable = "vector")]
3405+
unsafe fn vec_cmpne(self, other: Self) -> Self::Result {
3406+
simd_ne(self, other)
3407+
}
3408+
}
3409+
3410+
macro_rules! impl_compare_equality {
3411+
($($ty:ident)*) => {
3412+
$(
3413+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
3414+
impl VectorEquality for $ty {
3415+
type Result = t_b!($ty);
3416+
}
3417+
)*
3418+
}
3419+
}
3420+
3421+
impl_compare_equality! {
3422+
vector_bool_char
3423+
vector_signed_char
3424+
vector_unsigned_char
3425+
3426+
vector_bool_short
3427+
vector_signed_short
3428+
vector_unsigned_short
3429+
3430+
vector_bool_int
3431+
vector_signed_int
3432+
vector_unsigned_int
3433+
vector_float
3434+
3435+
vector_bool_long_long
3436+
vector_signed_long_long
3437+
vector_unsigned_long_long
3438+
vector_double
3439+
}
33923440
}
33933441

33943442
/// Load Count to Block Boundary
@@ -4934,6 +4982,22 @@ pub unsafe fn vec_cmpnrg_or_0_idx_cc<T: sealed::VectorCompareRange>(
49344982
x
49354983
}
49364984

4985+
/// Vector Compare Equal
4986+
#[inline]
4987+
#[target_feature(enable = "vector")]
4988+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
4989+
pub unsafe fn vec_cmpeq<T: sealed::VectorEquality>(a: T, b: T) -> T::Result {
4990+
a.vec_cmpeq(b)
4991+
}
4992+
4993+
/// Vector Compare Not Equal
4994+
#[inline]
4995+
#[target_feature(enable = "vector")]
4996+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
4997+
pub unsafe fn vec_cmpne<T: sealed::VectorEquality>(a: T, b: T) -> T::Result {
4998+
a.vec_cmpne(b)
4999+
}
5000+
49375001
/// Vector Compare Greater Than
49385002
#[inline]
49395003
#[target_feature(enable = "vector")]
@@ -6353,4 +6417,16 @@ mod tests {
63536417
[1.0, f32::NAN, 5.0, 3.14],
63546418
[!0, 0, 0, !0]
63556419
}
6420+
6421+
test_vec_2! { test_vec_cmpeq, vec_cmpeq, f32x4, f32x4 -> i32x4,
6422+
[1.0, f32::NAN, f32::NAN, 2.0],
6423+
[1.0, f32::NAN, 5.0, 3.14],
6424+
[!0, 0, 0, 0]
6425+
}
6426+
6427+
test_vec_2! { test_vec_cmpne, vec_cmpne, f32x4, f32x4 -> i32x4,
6428+
[1.0, f32::NAN, f32::NAN, 2.0],
6429+
[1.0, f32::NAN, 5.0, 3.14],
6430+
[0, !0, !0, !0]
6431+
}
63566432
}

0 commit comments

Comments
 (0)