Skip to content

Commit 176c400

Browse files
folkertdevAmanieu
authored andcommitted
add vec_extend_s64
1 parent 588a4c2 commit 176c400

File tree

1 file changed

+88
-0
lines changed

1 file changed

+88
-0
lines changed

crates/core_arch/src/s390x/vector.rs

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3003,6 +3003,72 @@ mod sealed {
30033003
vcelfb(self)
30043004
}
30053005
}
3006+
3007+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
3008+
pub trait VectorExtendSigned64 {
3009+
unsafe fn vec_extend_s64(self) -> vector_signed_long_long;
3010+
}
3011+
3012+
#[inline]
3013+
#[target_feature(enable = "vector")]
3014+
// FIXME(llvm): https://github.com/llvm/llvm-project/issues/129899
3015+
// #[cfg_attr(test, assert_instr(vsegb))]
3016+
pub unsafe fn vsegb(a: vector_signed_char) -> vector_signed_long_long {
3017+
simd_as(simd_shuffle::<_, _, i8x2>(
3018+
a,
3019+
a,
3020+
const { u32x2::from_array([7, 15]) },
3021+
))
3022+
}
3023+
3024+
#[inline]
3025+
#[target_feature(enable = "vector")]
3026+
// FIXME(llvm): https://github.com/llvm/llvm-project/issues/129899
3027+
// #[cfg_attr(test, assert_instr(vsegh))]
3028+
pub unsafe fn vsegh(a: vector_signed_short) -> vector_signed_long_long {
3029+
simd_as(simd_shuffle::<_, _, i16x2>(
3030+
a,
3031+
a,
3032+
const { u32x2::from_array([3, 7]) },
3033+
))
3034+
}
3035+
3036+
#[inline]
3037+
#[target_feature(enable = "vector")]
3038+
// FIXME(llvm): https://github.com/llvm/llvm-project/issues/129899
3039+
// #[cfg_attr(test, assert_instr(vsegf))]
3040+
pub unsafe fn vsegf(a: vector_signed_int) -> vector_signed_long_long {
3041+
simd_as(simd_shuffle::<_, _, i32x2>(
3042+
a,
3043+
a,
3044+
const { u32x2::from_array([1, 3]) },
3045+
))
3046+
}
3047+
3048+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
3049+
impl VectorExtendSigned64 for vector_signed_char {
3050+
#[inline]
3051+
#[target_feature(enable = "vector")]
3052+
unsafe fn vec_extend_s64(self) -> vector_signed_long_long {
3053+
vsegb(self)
3054+
}
3055+
}
3056+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
3057+
impl VectorExtendSigned64 for vector_signed_short {
3058+
#[inline]
3059+
#[target_feature(enable = "vector")]
3060+
unsafe fn vec_extend_s64(self) -> vector_signed_long_long {
3061+
vsegh(self)
3062+
}
3063+
}
3064+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
3065+
impl VectorExtendSigned64 for vector_signed_int {
3066+
#[inline]
3067+
#[target_feature(enable = "vector")]
3068+
unsafe fn vec_extend_s64(self) -> vector_signed_long_long {
3069+
vsegf(self)
3070+
}
3071+
}
30063072
}
30073073

30083074
/// Load Count to Block Boundary
@@ -4314,6 +4380,14 @@ pub unsafe fn vec_double(a: impl sealed::VectorDouble) -> vector_double {
43144380
a.vec_double()
43154381
}
43164382

4383+
/// Vector Sign Extend to Doubleword
4384+
#[inline]
4385+
#[target_feature(enable = "vector")]
4386+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
4387+
pub unsafe fn vec_extend_s64(a: impl sealed::VectorExtendSigned64) -> vector_signed_long_long {
4388+
a.vec_extend_s64()
4389+
}
4390+
43174391
#[cfg(test)]
43184392
mod tests {
43194393
use super::*;
@@ -5459,4 +5533,18 @@ mod tests {
54595533
assert_eq!(d.as_array()[2], f64::MAX as f32);
54605534
}
54615535
}
5536+
5537+
#[simd_test(enable = "vector")]
5538+
fn test_vec_extend_s64() {
5539+
unsafe {
5540+
let v = vector_signed_char([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]);
5541+
assert_eq!(vec_extend_s64(v).as_array(), &[7, 15]);
5542+
5543+
let v = vector_signed_short([0, 1, 2, 3, 4, 5, 6, 7]);
5544+
assert_eq!(vec_extend_s64(v).as_array(), &[3, 7]);
5545+
5546+
let v = vector_signed_int([0, 1, 2, 3]);
5547+
assert_eq!(vec_extend_s64(v).as_array(), &[1, 3]);
5548+
}
5549+
}
54625550
}

0 commit comments

Comments
 (0)