Skip to content

Commit 67cb6d3

Browse files
folkertdevAmanieu
authored andcommitted
add vec_msum_u128
1 parent b477f18 commit 67cb6d3

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

crates/core_arch/src/s390x/vector.rs

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,8 @@ unsafe extern "unadjusted" {
229229
#[link_name = "llvm.s390.vistrbs"] fn vistrbs(a: vector_unsigned_char) -> PackedTuple<vector_unsigned_char, i32>;
230230
#[link_name = "llvm.s390.vistrhs"] fn vistrhs(a: vector_unsigned_short) -> PackedTuple<vector_unsigned_short, i32>;
231231
#[link_name = "llvm.s390.vistrfs"] fn vistrfs(a: vector_unsigned_int) -> PackedTuple<vector_unsigned_int, i32>;
232+
233+
#[link_name = "llvm.s390.vmslg"] fn vmslg(a: vector_unsigned_long_long, b: vector_unsigned_long_long, c: u128, d: u32) -> u128;
232234
}
233235

234236
impl_from! { i8x16, u8x16, i16x8, u16x8, i32x4, u32x4, i64x2, u64x2, f32x4, f64x2 }
@@ -4519,6 +4521,27 @@ pub unsafe fn vec_cp_until_zero_cc<T: sealed::VectorCopyUntilZeroCC>(a: T, cc: *
45194521
a.vec_cp_until_zero_cc(cc)
45204522
}
45214523

4524+
/// Vector Multiply Sum Logical
4525+
#[inline]
4526+
#[target_feature(enable = "vector-enhancements-1")]
4527+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
4528+
#[cfg_attr(
4529+
all(test, target_feature = "vector-enhancements-1"),
4530+
assert_instr(vmslg, D = 4)
4531+
)]
4532+
pub unsafe fn vec_msum_u128<const D: u32>(
4533+
a: vector_unsigned_long_long,
4534+
b: vector_unsigned_long_long,
4535+
c: vector_unsigned_char,
4536+
) -> vector_unsigned_char {
4537+
const {
4538+
if !matches!(D, 0 | 4 | 8 | 12) {
4539+
panic!("D needs to be one of 0, 4, 8, 12");
4540+
}
4541+
};
4542+
transmute(vmslg(a, b, transmute(c), D))
4543+
}
4544+
45224545
#[cfg(test)]
45234546
mod tests {
45244547
use super::*;
@@ -5730,4 +5753,26 @@ mod tests {
57305753
assert_eq!(cc, 0);
57315754
}
57325755
}
5756+
5757+
#[simd_test(enable = "vector-enhancements-1")]
5758+
fn test_vec_msum_u128() {
5759+
let a = vector_unsigned_long_long([1, 2]);
5760+
let b = vector_unsigned_long_long([3, 4]);
5761+
5762+
unsafe {
5763+
let c: vector_unsigned_char = transmute(100u128);
5764+
5765+
let d: u128 = transmute(vec_msum_u128::<0>(a, b, c));
5766+
assert_eq!(d, (1 * 3) + (2 * 4) + 100);
5767+
5768+
let d: u128 = transmute(vec_msum_u128::<4>(a, b, c));
5769+
assert_eq!(d, (1 * 3) + (2 * 4) * 2 + 100);
5770+
5771+
let d: u128 = transmute(vec_msum_u128::<8>(a, b, c));
5772+
assert_eq!(d, (1 * 3) * 2 + (2 * 4) + 100);
5773+
5774+
let d: u128 = transmute(vec_msum_u128::<12>(a, b, c));
5775+
assert_eq!(d, (1 * 3) * 2 + (2 * 4) * 2 + 100);
5776+
}
5777+
}
57335778
}

0 commit comments

Comments
 (0)