Debian Codegraph @

third-party/simde/arm/neon/rsqrts.h

raw
1 /* SPDX-License-Identifier: MIT
2 *
3 * Permission is hereby granted, free of charge, to any person
4 * obtaining a copy of this software and associated documentation
5 * files (the "Software"), to deal in the Software without
6 * restriction, including without limitation the rights to use, copy,
7 * modify, merge, publish, distribute, sublicense, and/or sell copies
8 * of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be
12 * included in all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
18 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
19 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 * SOFTWARE.
22 *
23 * Copyright:
24 * 2021 Zhi An Ng <[email protected]> (Copyright owned by Google, LLC)
25 * 2021 Evan Nemerson <[email protected]>
26 */
27
28 #if !defined(SIMDE_ARM_NEON_RSQRTS_H)
29 #define SIMDE_ARM_NEON_RSQRTS_H
30
31 #include "types.h"
32 #include "mls.h"
33 #include "mul_n.h"
34 #include "dup_n.h"
35
36 HEDLEY_DIAGNOSTIC_PUSH
37 SIMDE_DISABLE_UNWANTED_DIAGNOSTICS
38 SIMDE_BEGIN_DECLS_
39
40 SIMDE_FUNCTION_ATTRIBUTES
41 simde_float32_t
42 simde_vrsqrtss_f32(simde_float32_t a, simde_float32_t b) {
43 #if defined(SIMDE_ARM_NEON_A64V8_NATIVE)
44 return vrsqrtss_f32(a, b);
45 #else
46 return SIMDE_FLOAT32_C(0.5) * (SIMDE_FLOAT32_C(3.0) - (a * b));
47 #endif
48 }
49 #if defined(SIMDE_ARM_NEON_A64V8_ENABLE_NATIVE_ALIASES)
50 #undef vrsqrtss_f32
51 #define vrsqrtss_f32(a, b) simde_vrsqrtss_f32((a), (b))
52 #endif
53
54 SIMDE_FUNCTION_ATTRIBUTES
55 simde_float64_t
56 simde_vrsqrtsd_f64(simde_float64_t a, simde_float64_t b) {
57 #if defined(SIMDE_ARM_NEON_A64V8_NATIVE)
58 return vrsqrtsd_f64(a, b);
59 #else
60 return SIMDE_FLOAT64_C(0.5) * (SIMDE_FLOAT64_C(3.0) - (a * b));
61 #endif
62 }
63 #if defined(SIMDE_ARM_NEON_A64V8_ENABLE_NATIVE_ALIASES)
64 #undef vrsqrtsd_f64
65 #define vrsqrtsd_f64(a, b) simde_vrsqrtsd_f64((a), (b))
66 #endif
67
68 SIMDE_FUNCTION_ATTRIBUTES
69 simde_float32x2_t
70 simde_vrsqrts_f32(simde_float32x2_t a, simde_float32x2_t b) {
71 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
72 return vrsqrts_f32(a, b);
73 #else
74 return
75 simde_vmul_n_f32(
76 simde_vmls_f32(
77 simde_vdup_n_f32(SIMDE_FLOAT32_C(3.0)),
78 a,
79 b),
80 SIMDE_FLOAT32_C(0.5)
81 );
82 #endif
83 }
84 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
85 #undef vrsqrts_f32
86 #define vrsqrts_f32(a, b) simde_vrsqrts_f32((a), (b))
87 #endif
88
89 SIMDE_FUNCTION_ATTRIBUTES
90 simde_float64x1_t
91 simde_vrsqrts_f64(simde_float64x1_t a, simde_float64x1_t b) {
92 #if defined(SIMDE_ARM_NEON_A64V8_NATIVE)
93 return vrsqrts_f64(a, b);
94 #else
95 return
96 simde_vmul_n_f64(
97 simde_vmls_f64(
98 simde_vdup_n_f64(SIMDE_FLOAT64_C(3.0)),
99 a,
100 b),
101 SIMDE_FLOAT64_C(0.5)
102 );
103 #endif
104 }
105 #if defined(SIMDE_ARM_NEON_A64V8_ENABLE_NATIVE_ALIASES)
106 #undef vrsqrts_f64
107 #define vrsqrts_f64(a, b) simde_vrsqrts_f64((a), (b))
108 #endif
109
110 SIMDE_FUNCTION_ATTRIBUTES
111 simde_float32x4_t
112 simde_vrsqrtsq_f32(simde_float32x4_t a, simde_float32x4_t b) {
113 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
114 return vrsqrtsq_f32(a, b);
115 #else
116 return
117 simde_vmulq_n_f32(
118 simde_vmlsq_f32(
119 simde_vdupq_n_f32(SIMDE_FLOAT32_C(3.0)),
120 a,
121 b),
122 SIMDE_FLOAT32_C(0.5)
123 );
124 #endif
125 }
126 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
127 #undef vrsqrtsq_f32
128 #define vrsqrtsq_f32(a, b) simde_vrsqrtsq_f32((a), (b))
129 #endif
130
131 SIMDE_FUNCTION_ATTRIBUTES
132 simde_float64x2_t
133 simde_vrsqrtsq_f64(simde_float64x2_t a, simde_float64x2_t b) {
134 #if defined(SIMDE_ARM_NEON_A64V8_NATIVE)
135 return vrsqrtsq_f64(a, b);
136 #else
137 return
138 simde_vmulq_n_f64(
139 simde_vmlsq_f64(
140 simde_vdupq_n_f64(SIMDE_FLOAT64_C(3.0)),
141 a,
142 b),
143 SIMDE_FLOAT64_C(0.5)
144 );
145 #endif
146 }
147 #if defined(SIMDE_ARM_NEON_A64V8_ENABLE_NATIVE_ALIASES)
148 #undef vrsqrtsq_f64
149 #define vrsqrtsq_f64(a, b) simde_vrsqrtsq_f64((a), (b))
150 #endif
151
152 SIMDE_END_DECLS_
153 HEDLEY_DIAGNOSTIC_POP
154 #endif /* !defined(SIMDE_ARM_NEON_RSQRTS_H) */