Skip to content

Commit 9727207

Browse files
folkertdevAmanieu
authored andcommitted
add vec_sqrt
1 parent 5946cf7 commit 9727207

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

Diff for: crates/core_arch/src/s390x/vector.rs

+26
Original file line numberDiff line numberDiff line change
@@ -1444,6 +1444,17 @@ mod sealed {
14441444
impl_vec_trait! {[VectorSubc vec_subc] vec_vscbih (vector_unsigned_short, vector_unsigned_short) -> vector_unsigned_short }
14451445
impl_vec_trait! {[VectorSubc vec_subc] vec_vscbif (vector_unsigned_int, vector_unsigned_int) -> vector_unsigned_int }
14461446
impl_vec_trait! {[VectorSubc vec_subc] vec_vscbig (vector_unsigned_long_long, vector_unsigned_long_long) -> vector_unsigned_long_long }
1447+
1448+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
1449+
pub trait VectorSqrt {
1450+
unsafe fn vec_sqrt(self) -> Self;
1451+
}
1452+
1453+
test_impl! { vec_sqrt_f32 (v: vector_float) -> vector_float [ simd_fsqrt, "vector-enhancements-1" vfsqsb ] }
1454+
test_impl! { vec_sqrt_f64 (v: vector_double) -> vector_double [ simd_fsqrt, vfsqdb ] }
1455+
1456+
impl_vec_trait! { [VectorSqrt vec_sqrt] vec_sqrt_f32 (vector_float) }
1457+
impl_vec_trait! { [VectorSqrt vec_sqrt] vec_sqrt_f64 (vector_double) }
14471458
}
14481459

14491460
/// Vector element-wise addition.
@@ -1564,6 +1575,17 @@ where
15641575
a.vec_nabs()
15651576
}
15661577

1578+
/// Vector square root.
1579+
#[inline]
1580+
#[target_feature(enable = "vector")]
1581+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
1582+
pub unsafe fn vec_sqrt<T>(a: T) -> T
1583+
where
1584+
T: sealed::VectorSqrt,
1585+
{
1586+
a.vec_sqrt()
1587+
}
1588+
15671589
/// Vector splats.
15681590
#[inline]
15691591
#[target_feature(enable = "vector")]
@@ -2651,4 +2673,8 @@ mod tests {
26512673
[0x00, 0x01, 0x02, 0x03, 0x10, 0x11, 0x12, 0x13,
26522674
0x04, 0x05, 0x06, 0x07, 0x14, 0x15, 0x16, 0x17],
26532675
[0.0, 1.0, 1.0, 1.1]}
2676+
2677+
test_vec_1! { test_vec_sqrt, vec_sqrt, f32x4,
2678+
[core::f32::consts::PI, 1.0, 25.0, 2.0],
2679+
[core::f32::consts::PI.sqrt(), 1.0, 5.0, core::f32::consts::SQRT_2] }
26542680
}

0 commit comments

Comments
 (0)