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 <evan@nemerson.com>
25 * 2020 Sean Maher <seanptmaher@gmail.com> (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
33 HEDLEY_DIAGNOSTIC_PUSH
34 SIMDE_DISABLE_UNWANTED_DIAGNOSTICS
35 SIMDE_BEGIN_DECLS_
36
37 SIMDE_FUNCTION_ATTRIBUTES
38 uint32_t
simde_vcagts_f32(simde_float32_t a,simde_float32_t b)39 simde_vcagts_f32(simde_float32_t a, simde_float32_t b) {
40 #if defined(SIMDE_ARM_NEON_A64V8_NATIVE)
41 return vcagts_f32(a, b);
42 #else
43 return (simde_math_fabsf(a) > simde_math_fabsf(b)) ? ~UINT32_C(0) : UINT32_C(0);
44 #endif
45 }
46 #if defined(SIMDE_ARM_NEON_A64V8_ENABLE_NATIVE_ALIASES)
47 #undef vcagts_f32
48 #define vcagts_f32(a, b) simde_vcagts_f32((a), (b))
49 #endif
50
51 SIMDE_FUNCTION_ATTRIBUTES
52 uint64_t
simde_vcagtd_f64(simde_float64_t a,simde_float64_t b)53 simde_vcagtd_f64(simde_float64_t a, simde_float64_t b) {
54 #if defined(SIMDE_ARM_NEON_A64V8_NATIVE)
55 return vcagtd_f64(a, b);
56 #else
57 return (simde_math_fabs(a) > simde_math_fabs(b)) ? ~UINT64_C(0) : UINT64_C(0);
58 #endif
59 }
60 #if defined(SIMDE_ARM_NEON_A64V8_ENABLE_NATIVE_ALIASES)
61 #undef vcagtd_f64
62 #define vcagtd_f64(a, b) simde_vcagtd_f64((a), (b))
63 #endif
64
65 SIMDE_FUNCTION_ATTRIBUTES
66 simde_uint32x2_t
simde_vcagt_f32(simde_float32x2_t a,simde_float32x2_t b)67 simde_vcagt_f32(simde_float32x2_t a, simde_float32x2_t b) {
68 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
69 return vcagt_f32(a, b);
70 #else
71 simde_uint32x2_private r_;
72 simde_float32x2_private
73 a_ = simde_float32x2_to_private(a),
74 b_ = simde_float32x2_to_private(b);
75
76 SIMDE_VECTORIZE
77 for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) {
78 r_.values[i] = simde_vcagts_f32(a_.values[i], b_.values[i]);
79 }
80
81 return simde_uint32x2_from_private(r_);
82 #endif
83 }
84 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
85 #undef vcagt_f32
86 #define vcagt_f32(a, b) simde_vcagt_f32((a), (b))
87 #endif
88
89 SIMDE_FUNCTION_ATTRIBUTES
90 simde_uint64x1_t
simde_vcagt_f64(simde_float64x1_t a,simde_float64x1_t b)91 simde_vcagt_f64(simde_float64x1_t a, simde_float64x1_t b) {
92 #if defined(SIMDE_ARM_NEON_A64V8_NATIVE)
93 return vcagt_f64(a, b);
94 #else
95 simde_uint64x1_private r_;
96 simde_float64x1_private
97 a_ = simde_float64x1_to_private(a),
98 b_ = simde_float64x1_to_private(b);
99
100 SIMDE_VECTORIZE
101 for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) {
102 r_.values[i] = simde_vcagtd_f64(a_.values[i], b_.values[i]);
103 }
104
105 return simde_uint64x1_from_private(r_);
106 #endif
107 }
108 #if defined(SIMDE_ARM_NEON_A64V8_ENABLE_NATIVE_ALIASES)
109 #undef vcagt_f64
110 #define vcagt_f64(a, b) simde_vcagt_f64((a), (b))
111 #endif
112
113 SIMDE_FUNCTION_ATTRIBUTES
114 simde_uint32x4_t
simde_vcagtq_f32(simde_float32x4_t a,simde_float32x4_t b)115 simde_vcagtq_f32(simde_float32x4_t a, simde_float32x4_t b) {
116 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
117 return vcagtq_f32(a, b);
118 #elif defined(SIMDE_WASM_SIMD128_NATIVE)
119 return wasm_f32x4_gt(wasm_f32x4_abs(a), wasm_f32x4_abs(b));
120 #else
121 simde_uint32x4_private r_;
122 simde_float32x4_private
123 a_ = simde_float32x4_to_private(a),
124 b_ = simde_float32x4_to_private(b);
125
126 SIMDE_VECTORIZE
127 for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) {
128 r_.values[i] = simde_vcagts_f32(a_.values[i], b_.values[i]);
129 }
130
131 return simde_uint32x4_from_private(r_);
132 #endif
133 }
134 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
135 #undef vcagtq_f32
136 #define vcagtq_f32(a, b) simde_vcagtq_f32((a), (b))
137 #endif
138
139 SIMDE_FUNCTION_ATTRIBUTES
140 simde_uint64x2_t
simde_vcagtq_f64(simde_float64x2_t a,simde_float64x2_t b)141 simde_vcagtq_f64(simde_float64x2_t a, simde_float64x2_t b) {
142 #if defined(SIMDE_ARM_NEON_A64V8_NATIVE)
143 return vcagtq_f64(a, b);
144 #elif defined(SIMDE_WASM_SIMD128_NATIVE)
145 return wasm_f64x2_gt(wasm_f64x2_abs(a), wasm_f64x2_abs(b));
146 #else
147 simde_uint64x2_private r_;
148 simde_float64x2_private
149 a_ = simde_float64x2_to_private(a),
150 b_ = simde_float64x2_to_private(b);
151
152 SIMDE_VECTORIZE
153 for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) {
154 r_.values[i] = simde_vcagtd_f64(a_.values[i], b_.values[i]);
155 }
156
157 return simde_uint64x2_from_private(r_);
158 #endif
159 }
160 #if defined(SIMDE_ARM_NEON_A64V8_ENABLE_NATIVE_ALIASES)
161 #undef vcagtq_f64
162 #define vcagtq_f64(a, b) simde_vcagtq_f64((a), (b))
163 #endif
164
165 SIMDE_END_DECLS_
166 HEDLEY_DIAGNOSTIC_POP
167
168 #endif /* !defined(SIMDE_ARM_NEON_CAGT_H) */
169