Debian Codegraph @

third-party/simde/arm/neon/cagt.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 * 2020 Evan Nemerson <[email protected]>
25 * 2020 Sean Maher <[email protected]> (Copyright owned by Google, LLC)
26 */
27
28 #if !defined(SIMDE_ARM_NEON_CAGT_H)
29 #define SIMDE_ARM_NEON_CAGT_H
30
31 #include "types.h"
32 #include "abs.h"
33 #include "cgt.h"
34
35 HEDLEY_DIAGNOSTIC_PUSH
36 SIMDE_DISABLE_UNWANTED_DIAGNOSTICS
37 SIMDE_BEGIN_DECLS_
38
39 SIMDE_FUNCTION_ATTRIBUTES
40 uint16_t
41 simde_vcagth_f16(simde_float16_t a, simde_float16_t b) {
42 #if defined(SIMDE_ARM_NEON_A64V8_NATIVE) && defined(SIMDE_ARM_NEON_FP16)
43 return vcagth_f16(a, b);
44 #else
45 simde_float32_t
46 af = simde_float16_to_float32(a),
47 bf = simde_float16_to_float32(b);
48 return (simde_math_fabsf(af) > simde_math_fabsf(bf)) ? UINT16_MAX : UINT16_C(0);
49 #endif
50 }
51 #if defined(SIMDE_ARM_NEON_A64V8_ENABLE_NATIVE_ALIASES)
52 #undef vcagth_f16
53 #define vcagth_f16(a, b) simde_vcagth_f16((a), (b))
54 #endif
55
56 SIMDE_FUNCTION_ATTRIBUTES
57 uint32_t
58 simde_vcagts_f32(simde_float32_t a, simde_float32_t b) {
59 #if defined(SIMDE_ARM_NEON_A64V8_NATIVE)
60 return vcagts_f32(a, b);
61 #else
62 return (simde_math_fabsf(a) > simde_math_fabsf(b)) ? ~UINT32_C(0) : UINT32_C(0);
63 #endif
64 }
65 #if defined(SIMDE_ARM_NEON_A64V8_ENABLE_NATIVE_ALIASES)
66 #undef vcagts_f32
67 #define vcagts_f32(a, b) simde_vcagts_f32((a), (b))
68 #endif
69
70 SIMDE_FUNCTION_ATTRIBUTES
71 uint64_t
72 simde_vcagtd_f64(simde_float64_t a, simde_float64_t b) {
73 #if defined(SIMDE_ARM_NEON_A64V8_NATIVE)
74 return vcagtd_f64(a, b);
75 #else
76 return (simde_math_fabs(a) > simde_math_fabs(b)) ? ~UINT64_C(0) : UINT64_C(0);
77 #endif
78 }
79 #if defined(SIMDE_ARM_NEON_A64V8_ENABLE_NATIVE_ALIASES)
80 #undef vcagtd_f64
81 #define vcagtd_f64(a, b) simde_vcagtd_f64((a), (b))
82 #endif
83
84 SIMDE_FUNCTION_ATTRIBUTES
85 simde_uint16x4_t
86 simde_vcagt_f16(simde_float16x4_t a, simde_float16x4_t b) {
87 #if defined(SIMDE_ARM_NEON_A32V8_NATIVE) && defined(SIMDE_ARM_NEON_FP16)
88 return vcagt_f16(a, b);
89 #else
90 simde_uint16x4_private r_;
91 simde_float16x4_private
92 a_ = simde_float16x4_to_private(a),
93 b_ = simde_float16x4_to_private(b);
94 SIMDE_VECTORIZE
95 for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) {
96 r_.values[i] = simde_vcagth_f16(a_.values[i], b_.values[i]);
97 }
98
99 return simde_uint16x4_from_private(r_);
100 #endif
101 }
102 #if defined(SIMDE_ARM_NEON_A32V8_ENABLE_NATIVE_ALIASES)
103 #undef vcagt_f16
104 #define vcagt_f16(a, b) simde_vcagt_f16((a), (b))
105 #endif
106
107 SIMDE_FUNCTION_ATTRIBUTES
108 simde_uint32x2_t
109 simde_vcagt_f32(simde_float32x2_t a, simde_float32x2_t b) {
110 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
111 return vcagt_f32(a, b);
112 #else
113 return simde_vcgt_f32(simde_vabs_f32(a), simde_vabs_f32(b));
114 #endif
115 }
116 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
117 #undef vcagt_f32
118 #define vcagt_f32(a, b) simde_vcagt_f32((a), (b))
119 #endif
120
121 SIMDE_FUNCTION_ATTRIBUTES
122 simde_uint64x1_t
123 simde_vcagt_f64(simde_float64x1_t a, simde_float64x1_t b) {
124 #if defined(SIMDE_ARM_NEON_A64V8_NATIVE)
125 return vcagt_f64(a, b);
126 #else
127 return simde_vcgt_f64(simde_vabs_f64(a), simde_vabs_f64(b));
128 #endif
129 }
130 #if defined(SIMDE_ARM_NEON_A64V8_ENABLE_NATIVE_ALIASES)
131 #undef vcagt_f64
132 #define vcagt_f64(a, b) simde_vcagt_f64((a), (b))
133 #endif
134
135 SIMDE_FUNCTION_ATTRIBUTES
136 simde_uint16x8_t
137 simde_vcagtq_f16(simde_float16x8_t a, simde_float16x8_t b) {
138 #if defined(SIMDE_ARM_NEON_A32V8_NATIVE) && defined(SIMDE_ARM_NEON_FP16)
139 return vcagtq_f16(a, b);
140 #else
141 simde_uint16x8_private r_;
142 simde_float16x8_private
143 a_ = simde_float16x8_to_private(a),
144 b_ = simde_float16x8_to_private(b);
145 SIMDE_VECTORIZE
146 for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) {
147 r_.values[i] = simde_vcagth_f16(a_.values[i], b_.values[i]);
148 }
149
150 return simde_uint16x8_from_private(r_);
151 #endif
152 }
153 #if defined(SIMDE_ARM_NEON_A32V8_ENABLE_NATIVE_ALIASES)
154 #undef vcagtq_f16
155 #define vcagtq_f16(a, b) simde_vcagtq_f16((a), (b))
156 #endif
157
158 SIMDE_FUNCTION_ATTRIBUTES
159 simde_uint32x4_t
160 simde_vcagtq_f32(simde_float32x4_t a, simde_float32x4_t b) {
161 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
162 return vcagtq_f32(a, b);
163 #else
164 return simde_vcgtq_f32(simde_vabsq_f32(a), simde_vabsq_f32(b));
165 #endif
166 }
167 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
168 #undef vcagtq_f32
169 #define vcagtq_f32(a, b) simde_vcagtq_f32((a), (b))
170 #endif
171
172 SIMDE_FUNCTION_ATTRIBUTES
173 simde_uint64x2_t
174 simde_vcagtq_f64(simde_float64x2_t a, simde_float64x2_t b) {
175 #if defined(SIMDE_ARM_NEON_A64V8_NATIVE)
176 return vcagtq_f64(a, b);
177 #else
178 return simde_vcgtq_f64(simde_vabsq_f64(a), simde_vabsq_f64(b));
179 #endif
180 }
181 #if defined(SIMDE_ARM_NEON_A64V8_ENABLE_NATIVE_ALIASES)
182 #undef vcagtq_f64
183 #define vcagtq_f64(a, b) simde_vcagtq_f64((a), (b))
184 #endif
185
186 SIMDE_END_DECLS_
187 HEDLEY_DIAGNOSTIC_POP
188
189 #endif /* !defined(SIMDE_ARM_NEON_CAGT_H) */