compiler_builtins/math/libm_math/
sqrt.rs

1/// The square root of `x` (f16).
2#[cfg(f16_enabled)]
3#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
4pub fn sqrtf16(x: f16) -> f16 {
5    select_implementation! {
6        name: sqrtf16,
7        use_arch: all(target_arch = "aarch64", target_feature = "fp16"),
8        args: x,
9    }
10
11    return super::generic::sqrt(x);
12}
13
14/// The square root of `x` (f32).
15#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
16pub fn sqrtf(x: f32) -> f32 {
17    select_implementation! {
18        name: sqrtf,
19        use_arch: any(
20            all(target_arch = "aarch64", target_feature = "neon"),
21            all(target_arch = "wasm32", intrinsics_enabled),
22            target_feature = "sse2"
23        ),
24        args: x,
25    }
26
27    super::generic::sqrt(x)
28}
29
30/// The square root of `x` (f64).
31#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
32pub fn sqrt(x: f64) -> f64 {
33    select_implementation! {
34        name: sqrt,
35        use_arch: any(
36            all(target_arch = "aarch64", target_feature = "neon"),
37            all(target_arch = "wasm32", intrinsics_enabled),
38            target_feature = "sse2"
39        ),
40        args: x,
41    }
42
43    super::generic::sqrt(x)
44}
45
46/// The square root of `x` (f128).
47#[cfg(f128_enabled)]
48#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
49pub fn sqrtf128(x: f128) -> f128 {
50    return super::generic::sqrt(x);
51}