Debian Codegraph @

third-party/simde/arm/neon/subhn.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 Evan Nemerson <[email protected]>
25 */
26
27 #if !defined(SIMDE_ARM_NEON_SUBHN_H)
28 #define SIMDE_ARM_NEON_SUBHN_H
29
30 #include "sub.h"
31 #include "shr_n.h"
32 #include "movn.h"
33
34 #include "reinterpret.h"
35
36 HEDLEY_DIAGNOSTIC_PUSH
37 SIMDE_DISABLE_UNWANTED_DIAGNOSTICS
38 SIMDE_BEGIN_DECLS_
39
40 SIMDE_FUNCTION_ATTRIBUTES
41 simde_int8x8_t
42 simde_vsubhn_s16(simde_int16x8_t a, simde_int16x8_t b) {
43 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
44 return vsubhn_s16(a, b);
45 #elif defined(SIMDE_VECTOR_SUBSCRIPT_SCALAR) && HEDLEY_HAS_BUILTIN(__builtin_shufflevector)
46 simde_int8x8_private r_;
47 simde_int8x16_private tmp_ =
48 simde_int8x16_to_private(
49 simde_vreinterpretq_s8_s16(
50 simde_vsubq_s16(a, b)
51 )
52 );
53 #if SIMDE_ENDIAN_ORDER == SIMDE_ENDIAN_LITTLE
54 r_.values = __builtin_shufflevector(tmp_.values, tmp_.values, 1, 3, 5, 7, 9, 11, 13, 15);
55 #else
56 r_.values = __builtin_shufflevector(tmp_.values, tmp_.values, 0, 2, 4, 6, 8, 10, 12, 14);
57 #endif
58 return simde_int8x8_from_private(r_);
59 #else
60 return simde_vmovn_s16(simde_vshrq_n_s16(simde_vsubq_s16(a, b), 8));
61 #endif
62 }
63 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
64 #undef vsubhn_s16
65 #define vsubhn_s16(a, b) simde_vsubhn_s16((a), (b))
66 #endif
67
68 SIMDE_FUNCTION_ATTRIBUTES
69 simde_int16x4_t
70 simde_vsubhn_s32(simde_int32x4_t a, simde_int32x4_t b) {
71 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
72 return vsubhn_s32(a, b);
73 #elif defined(SIMDE_VECTOR_SUBSCRIPT_SCALAR) && HEDLEY_HAS_BUILTIN(__builtin_shufflevector)
74 simde_int16x4_private r_;
75 simde_int16x8_private tmp_ =
76 simde_int16x8_to_private(
77 simde_vreinterpretq_s16_s32(
78 simde_vsubq_s32(a, b)
79 )
80 );
81 #if SIMDE_ENDIAN_ORDER == SIMDE_ENDIAN_LITTLE
82 r_.values = __builtin_shufflevector(tmp_.values, tmp_.values, 1, 3, 5, 7);
83 #else
84 r_.values = __builtin_shufflevector(tmp_.values, tmp_.values, 0, 2, 4, 6);
85 #endif
86 return simde_int16x4_from_private(r_);
87 #else
88 return simde_vmovn_s32(simde_vshrq_n_s32(simde_vsubq_s32(a, b), 16));
89 #endif
90 }
91 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
92 #undef vsubhn_s32
93 #define vsubhn_s32(a, b) simde_vsubhn_s32((a), (b))
94 #endif
95
96 SIMDE_FUNCTION_ATTRIBUTES
97 simde_int32x2_t
98 simde_vsubhn_s64(simde_int64x2_t a, simde_int64x2_t b) {
99 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
100 return vsubhn_s64(a, b);
101 #elif defined(SIMDE_VECTOR_SUBSCRIPT_SCALAR) && HEDLEY_HAS_BUILTIN(__builtin_shufflevector)
102 simde_int32x2_private r_;
103 simde_int32x4_private tmp_ =
104 simde_int32x4_to_private(
105 simde_vreinterpretq_s32_s64(
106 simde_vsubq_s64(a, b)
107 )
108 );
109 #if SIMDE_ENDIAN_ORDER == SIMDE_ENDIAN_LITTLE
110 r_.values = __builtin_shufflevector(tmp_.values, tmp_.values, 1, 3);
111 #else
112 r_.values = __builtin_shufflevector(tmp_.values, tmp_.values, 0, 2);
113 #endif
114 return simde_int32x2_from_private(r_);
115 #else
116 return simde_vmovn_s64(simde_vshrq_n_s64(simde_vsubq_s64(a, b), 32));
117 #endif
118 }
119 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
120 #undef vsubhn_s64
121 #define vsubhn_s64(a, b) simde_vsubhn_s64((a), (b))
122 #endif
123
124 SIMDE_FUNCTION_ATTRIBUTES
125 simde_uint8x8_t
126 simde_vsubhn_u16(simde_uint16x8_t a, simde_uint16x8_t b) {
127 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
128 return vsubhn_u16(a, b);
129 #elif defined(SIMDE_VECTOR_SUBSCRIPT_SCALAR) && HEDLEY_HAS_BUILTIN(__builtin_shufflevector)
130 simde_uint8x8_private r_;
131 simde_uint8x16_private tmp_ =
132 simde_uint8x16_to_private(
133 simde_vreinterpretq_u8_u16(
134 simde_vsubq_u16(a, b)
135 )
136 );
137 #if SIMDE_ENDIAN_ORDER == SIMDE_ENDIAN_LITTLE
138 r_.values = __builtin_shufflevector(tmp_.values, tmp_.values, 1, 3, 5, 7, 9, 11, 13, 15);
139 #else
140 r_.values = __builtin_shufflevector(tmp_.values, tmp_.values, 0, 2, 4, 6, 8, 10, 12, 14);
141 #endif
142 return simde_uint8x8_from_private(r_);
143 #else
144 return simde_vmovn_u16(simde_vshrq_n_u16(simde_vsubq_u16(a, b), 8));
145 #endif
146 }
147 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
148 #undef vsubhn_u16
149 #define vsubhn_u16(a, b) simde_vsubhn_u16((a), (b))
150 #endif
151
152 SIMDE_FUNCTION_ATTRIBUTES
153 simde_uint16x4_t
154 simde_vsubhn_u32(simde_uint32x4_t a, simde_uint32x4_t b) {
155 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
156 return vsubhn_u32(a, b);
157 #elif defined(SIMDE_VECTOR_SUBSCRIPT_SCALAR) && HEDLEY_HAS_BUILTIN(__builtin_shufflevector)
158 simde_uint16x4_private r_;
159 simde_uint16x8_private tmp_ =
160 simde_uint16x8_to_private(
161 simde_vreinterpretq_u16_u32(
162 simde_vsubq_u32(a, b)
163 )
164 );
165 #if SIMDE_ENDIAN_ORDER == SIMDE_ENDIAN_LITTLE
166 r_.values = __builtin_shufflevector(tmp_.values, tmp_.values, 1, 3, 5, 7);
167 #else
168 r_.values = __builtin_shufflevector(tmp_.values, tmp_.values, 0, 2, 4, 6);
169 #endif
170 return simde_uint16x4_from_private(r_);
171 #else
172 return simde_vmovn_u32(simde_vshrq_n_u32(simde_vsubq_u32(a, b), 16));
173 #endif
174 }
175 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
176 #undef vsubhn_u32
177 #define vsubhn_u32(a, b) simde_vsubhn_u32((a), (b))
178 #endif
179
180 SIMDE_FUNCTION_ATTRIBUTES
181 simde_uint32x2_t
182 simde_vsubhn_u64(simde_uint64x2_t a, simde_uint64x2_t b) {
183 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
184 return vsubhn_u64(a, b);
185 #elif defined(SIMDE_VECTOR_SUBSCRIPT_SCALAR) && HEDLEY_HAS_BUILTIN(__builtin_shufflevector)
186 simde_uint32x2_private r_;
187 simde_uint32x4_private tmp_ =
188 simde_uint32x4_to_private(
189 simde_vreinterpretq_u32_u64(
190 simde_vsubq_u64(a, b)
191 )
192 );
193 #if SIMDE_ENDIAN_ORDER == SIMDE_ENDIAN_LITTLE
194 r_.values = __builtin_shufflevector(tmp_.values, tmp_.values, 1, 3);
195 #else
196 r_.values = __builtin_shufflevector(tmp_.values, tmp_.values, 0, 2);
197 #endif
198 return simde_uint32x2_from_private(r_);
199 #else
200 return simde_vmovn_u64(simde_vshrq_n_u64(simde_vsubq_u64(a, b), 32));
201 #endif
202 }
203 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
204 #undef vsubhn_u64
205 #define vsubhn_u64(a, b) simde_vsubhn_u64((a), (b))
206 #endif
207
208 SIMDE_END_DECLS_
209 HEDLEY_DIAGNOSTIC_POP
210
211 #endif /* !defined(SIMDE_ARM_NEON_SUBHN_H) */