Skip to content

Commit a855cb0

Browse files
folkertdevAmanieu
authored andcommitted
add vec_bperm_u128
1 parent 0afccca commit a855cb0

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

crates/core_arch/src/s390x/vector.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,8 @@ unsafe extern "unadjusted" {
206206
#[link_name = "llvm.s390.vgfmah"] fn vgfmah(a: vector_unsigned_short, b: vector_unsigned_short, c: vector_unsigned_int) -> vector_unsigned_int;
207207
#[link_name = "llvm.s390.vgfmaf"] fn vgfmaf(a: vector_unsigned_int, b: vector_unsigned_int, c: vector_unsigned_long_long) -> vector_unsigned_long_long;
208208
#[link_name = "llvm.s390.vgfmag"] fn vgfmag(a: vector_unsigned_long_long, b: vector_unsigned_long_long, c: u128) -> u128;
209+
210+
#[link_name = "llvm.s390.vbperm"] fn vbperm(a: vector_unsigned_char, b: vector_unsigned_char) -> vector_unsigned_long_long;
209211
}
210212

211213
impl_from! { i8x16, u8x16, i16x8, u16x8, i32x4, u32x4, i64x2, u64x2, f32x4, f64x2 }
@@ -3811,6 +3813,19 @@ pub unsafe fn vec_gfmsum_accum_128(
38113813
transmute(vgfmag(a, b, transmute(c)))
38123814
}
38133815

3816+
/// Vector Bit Permute
3817+
#[inline]
3818+
#[target_feature(enable = "vector-enhancements-1")]
3819+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
3820+
#[cfg_attr(test, assert_instr(vbperm))]
3821+
pub unsafe fn vec_bperm_u128(
3822+
a: vector_unsigned_char,
3823+
b: vector_unsigned_char,
3824+
) -> vector_unsigned_long_long {
3825+
vbperm(a, b)
3826+
}
3827+
3828+
/// Vector Gather Element
38143829
#[inline]
38153830
#[target_feature(enable = "vector")]
38163831
#[unstable(feature = "stdarch_s390x", issue = "135681")]
@@ -4760,6 +4775,16 @@ mod tests {
47604775
assert_eq!(d, 0xE000E000E000E000E000E000E000E);
47614776
}
47624777

4778+
#[simd_test(enable = "vector-enhancements-1")]
4779+
fn test_vec_bperm_u128() {
4780+
let a = vector_unsigned_char([65, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]);
4781+
let b = vector_unsigned_char([
4782+
0, 0, 0, 0, 1, 1, 1, 1, 128, 128, 128, 128, 255, 255, 255, 255,
4783+
]);
4784+
let d = unsafe { vec_bperm_u128(a, b) };
4785+
assert_eq!(d.as_array(), &[0xF00, 0]);
4786+
}
4787+
47634788
#[simd_test(enable = "vector")]
47644789
fn test_vec_gather_element() {
47654790
let a1: [u32; 10] = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19];

0 commit comments

Comments
 (0)