Skip to content

Commit dd7d710

Browse files
committed
add vec_checksum
1 parent 1aa712d commit dd7d710

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

crates/core_arch/src/s390x/vector.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,8 @@ unsafe extern "unadjusted" {
184184
#[link_name = "llvm.s390.vavglh"] fn vavglh(a: vector_unsigned_short, b: vector_unsigned_short) -> vector_unsigned_short;
185185
#[link_name = "llvm.s390.vavglf"] fn vavglf(a: vector_unsigned_int, b: vector_unsigned_int) -> vector_unsigned_int;
186186
#[link_name = "llvm.s390.vavglg"] fn vavglg(a: vector_unsigned_long_long, b: vector_unsigned_long_long) -> vector_unsigned_long_long;
187+
188+
#[link_name = "llvm.s390.vcksm"] fn vcksm(a: vector_unsigned_int, b: vector_unsigned_int) -> vector_unsigned_int;
187189
}
188190

189191
impl_from! { i8x16, u8x16, i16x8, u16x8, i32x4, u32x4, i64x2, u64x2, f32x4, f64x2 }
@@ -3383,6 +3385,15 @@ pub unsafe fn vec_msub<T: sealed::VectorMadd>(a: T, b: T, c: T) -> T {
33833385
a.vec_msub(b, c)
33843386
}
33853387

3388+
/// Vector Checksum
3389+
#[inline]
3390+
#[target_feature(enable = "vector")]
3391+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
3392+
#[cfg_attr(test, assert_instr(vcksm))]
3393+
pub unsafe fn vec_checksum(a: vector_unsigned_int, b: vector_unsigned_int) -> vector_unsigned_int {
3394+
vcksm(a, b)
3395+
}
3396+
33863397
#[cfg(test)]
33873398
mod tests {
33883399
use super::*;
@@ -4229,4 +4240,10 @@ mod tests {
42294240
[4, 2, 2, 0],
42304241
[3, (1u32 + 2).div_ceil(2), (u32::MAX as u64 + 2u64).div_ceil(2) as u32, 0]
42314242
}
4243+
4244+
test_vec_2! { test_vec_checksum, vec_checksum, u32x4,
4245+
[1, 2, 3, u32::MAX],
4246+
[5, 6, 7, 8],
4247+
[0, 12, 0, 0]
4248+
}
42324249
}

0 commit comments

Comments
 (0)