Skip to content

Commit b494354

Browse files
committed
add vec_gfmsum_128
1 parent 77c4ffe commit b494354

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

crates/core_arch/src/s390x/vector.rs

+29
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,8 @@ unsafe extern "unadjusted" {
200200
#[link_name = "llvm.s390.vgfmb"] fn vgfmb(a: vector_unsigned_char, b: vector_unsigned_char) -> vector_unsigned_short;
201201
#[link_name = "llvm.s390.vgfmh"] fn vgfmh(a: vector_unsigned_short, b: vector_unsigned_short) -> vector_unsigned_int;
202202
#[link_name = "llvm.s390.vgfmf"] fn vgfmf(a: vector_unsigned_int, b: vector_unsigned_int) -> vector_unsigned_long_long;
203+
#[link_name = "llvm.s390.vgfmg"] fn vgfmg(a: vector_unsigned_long_long, b: vector_unsigned_long_long) -> u128;
204+
203205
}
204206

205207
impl_from! { i8x16, u8x16, i16x8, u16x8, i32x4, u32x4, i64x2, u64x2, f32x4, f64x2 }
@@ -3609,6 +3611,18 @@ pub unsafe fn vec_gfmsum<T: sealed::VectorGfmsum<U>, U>(a: T, b: T) -> U {
36093611
a.vec_gfmsum(b)
36103612
}
36113613

3614+
/// Vector Galois Field Multiply Sum 128-bits
3615+
#[inline]
3616+
#[target_feature(enable = "vector")]
3617+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
3618+
#[cfg_attr(test, assert_instr(vgfmg))]
3619+
pub unsafe fn vec_gfmsum_128(
3620+
a: vector_unsigned_long_long,
3621+
b: vector_unsigned_long_long,
3622+
) -> vector_unsigned_char {
3623+
transmute(vgfmg(a, b))
3624+
}
3625+
36123626
#[cfg(test)]
36133627
mod tests {
36143628
use super::*;
@@ -4531,4 +4545,19 @@ mod tests {
45314545
[0xFFFF, 0x0000, 0x5555, 0xAAAA, 0x0001, 0x8000, 0x7FFF, 0x1357],
45324546
[0, 0, 0x2B3C1234, 0x3781D244]
45334547
}
4548+
4549+
#[simd_test(enable = "vector")]
4550+
fn test_vec_gfmsum_128() {
4551+
let a = vector_unsigned_long_long([1, 2]);
4552+
let b = vector_unsigned_long_long([3, 4]);
4553+
4554+
let d: u128 = unsafe { transmute(vec_gfmsum_128(a, b)) };
4555+
assert_eq!(d, 11);
4556+
4557+
let a = vector_unsigned_long_long([0x0101010101010101, 0x0202020202020202]);
4558+
let b = vector_unsigned_long_long([0x0404040404040404, 0x0505050505050505]);
4559+
4560+
let d: u128 = unsafe { transmute(vec_gfmsum_128(a, b)) };
4561+
assert_eq!(d, 0xE000E000E000E000E000E000E000E);
4562+
}
45344563
}

0 commit comments

Comments
 (0)