Skip to content

Commit f62246b

Browse files
folkertdevAmanieu
authored andcommitted
add vec_cmpnrg
1 parent 5f631eb commit f62246b

File tree

1 file changed

+34
-4
lines changed

1 file changed

+34
-4
lines changed

crates/core_arch/src/s390x/vector.rs

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4720,13 +4720,22 @@ pub unsafe fn vec_srdb<T: sealed::VectorSrdb, const C: u32>(a: T, b: T) -> T {
47204720
a.vec_srdb::<C>(b)
47214721
}
47224722

4723+
/// Vector Compare Ranges
47234724
#[inline]
47244725
#[target_feature(enable = "vector")]
47254726
#[unstable(feature = "stdarch_s390x", issue = "135681")]
47264727
pub unsafe fn vec_cmprg<T: sealed::VectorCompareRange>(a: T, b: T, c: T) -> T::Result {
47274728
a.vstrc::<{ FindImm::Eq as u32 }>(b, c)
47284729
}
47294730

4731+
/// Vector Compare Not in Ranges
4732+
#[inline]
4733+
#[target_feature(enable = "vector")]
4734+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
4735+
pub unsafe fn vec_cmpnrg<T: sealed::VectorCompareRange>(a: T, b: T, c: T) -> T::Result {
4736+
a.vstrc::<{ FindImm::Ne as u32 }>(b, c)
4737+
}
4738+
47304739
#[cfg(test)]
47314740
mod tests {
47324741
use super::*;
@@ -6005,12 +6014,12 @@ mod tests {
60056014
}
60066015
}
60076016

6017+
const GT: u32 = 0x20000000;
6018+
const LT: u32 = 0x40000000;
6019+
const EQ: u32 = 0x80000000;
6020+
60086021
#[simd_test(enable = "vector")]
60096022
fn test_vec_cmprg() {
6010-
const GT: u32 = 0x20000000;
6011-
const LT: u32 = 0x40000000;
6012-
const EQ: u32 = 0x80000000;
6013-
60146023
let a = vector_unsigned_int([11, 22, 33, 44]);
60156024
let b = vector_unsigned_int([10, 20, 30, 40]);
60166025

@@ -6029,4 +6038,25 @@ mod tests {
60296038
let d = unsafe { vec_cmprg(a, b, c) };
60306039
assert_eq!(d.as_array(), &[!0, 0, 0, !0]);
60316040
}
6041+
6042+
#[simd_test(enable = "vector")]
6043+
fn test_vec_cmpnrg() {
6044+
let a = vector_unsigned_int([11, 22, 33, 44]);
6045+
let b = vector_unsigned_int([10, 20, 30, 40]);
6046+
6047+
let c = vector_unsigned_int([GT, LT, GT, LT]);
6048+
let d = unsafe { vec_cmpnrg(a, b, c) };
6049+
assert_eq!(d.as_array(), &[0, !0, 0, !0]);
6050+
6051+
let c = vector_unsigned_int([GT, LT, 0, 0]);
6052+
let d = unsafe { vec_cmpnrg(a, b, c) };
6053+
assert_eq!(d.as_array(), &[0, !0, !0, !0]);
6054+
6055+
let a = vector_unsigned_int([11, 22, 33, 30]);
6056+
let b = vector_unsigned_int([10, 20, 30, 30]);
6057+
6058+
let c = vector_unsigned_int([GT, LT, EQ, EQ]);
6059+
let d = unsafe { vec_cmpnrg(a, b, c) };
6060+
assert_eq!(d.as_array(), &[0, !0, !0, 0]);
6061+
}
60326062
}

0 commit comments

Comments
 (0)