Skip to content

Commit 85b382b

Browse files
committed
add simd_fsqrt intrinsic
1 parent ce92300 commit 85b382b

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

crates/core_simd/src/intrinsics.rs

+3
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ extern "platform-intrinsic" {
4545

4646
/// fabs
4747
pub(crate) fn simd_fabs<T>(x: T) -> T;
48+
49+
/// fsqrt
50+
pub(crate) fn simd_fsqrt<T>(x: T) -> T;
4851

4952
pub(crate) fn simd_eq<T, U>(x: T, y: T) -> U;
5053
pub(crate) fn simd_ne<T, U>(x: T, y: T) -> U;

crates/core_simd/src/vector/float.rs

+7
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ macro_rules! impl_float_vector {
3535
pub fn abs(self) -> Self {
3636
unsafe { crate::intrinsics::simd_fabs(self) }
3737
}
38+
39+
/// Produces a vector where every lane has the square root value
40+
/// of the equivalently-indexed lane in `self`
41+
#[inline]
42+
pub fn sqrt(self) -> Self {
43+
unsafe { crate::intrinsics::simd_fsqrt(self) }
44+
}
3845
}
3946

4047
impl<const LANES: usize> $name<LANES>

crates/core_simd/tests/ops_macros.rs

+7
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,13 @@ macro_rules! impl_float_tests {
426426
)
427427
}
428428

429+
fn sqrt<const LANES: usize>() {
430+
test_helpers::test_unary_elementwise(
431+
&Vector::<LANES>::sqrt,
432+
&Scalar::sqrt,
433+
&|_| true,
434+
)
435+
}
429436
fn horizontal_sum<const LANES: usize>() {
430437
test_helpers::test_1(&|x| {
431438
test_helpers::prop_assert_biteq! (

0 commit comments

Comments
 (0)