Debian Codegraph @

third-party/simde/arm/neon/qdmulh.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_QDMULH_H)
29 #define SIMDE_ARM_NEON_QDMULH_H
30
31 #include "types.h"
32
33 #include "combine.h"
34 #include "get_high.h"
35 #include "get_low.h"
36 #include "qdmull.h"
37 #include "reinterpret.h"
38
39 HEDLEY_DIAGNOSTIC_PUSH
40 SIMDE_DISABLE_UNWANTED_DIAGNOSTICS
41 SIMDE_BEGIN_DECLS_
42
43 SIMDE_FUNCTION_ATTRIBUTES
44 int32_t
45 simde_vqdmulhs_s32(int32_t a, int32_t b) {
46 #if defined(SIMDE_ARM_NEON_A64V8_NATIVE)
47 return vqdmulhs_s32(a, b);
48 #else
49 int64_t tmp = simde_vqdmulls_s32(a, b);
50 return HEDLEY_STATIC_CAST(int32_t, tmp >> 32);
51 #endif
52 }
53 #if defined(SIMDE_ARM_NEON_A64V8_ENABLE_NATIVE_ALIASES)
54 #undef vqdmulhs_s32
55 #define vqdmulhs_s32(a) simde_vqdmulhs_s32((a))
56 #endif
57
58 SIMDE_FUNCTION_ATTRIBUTES
59 simde_int16x4_t
60 simde_vqdmulh_s16(simde_int16x4_t a, simde_int16x4_t b) {
61 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
62 return vqdmulh_s16(a, b);
63 #else
64 simde_int16x4_private r_;
65
66 #if HEDLEY_HAS_BUILTIN(__builtin_shufflevector)
67 simde_int16x8_private tmp_ =
68 simde_int16x8_to_private(
69 simde_vreinterpretq_s16_s32(
70 simde_vqdmull_s16(a, b)
71 )
72 );
73
74 r_.values = __builtin_shufflevector(tmp_.values, tmp_.values, 1, 3, 5, 7);
75 #else
76 simde_int32x4_private tmp = simde_int32x4_to_private(simde_vqdmull_s16(a, b));
77
78 SIMDE_VECTORIZE
79 for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) {
80 r_.values[i] = HEDLEY_STATIC_CAST(int16_t, tmp.values[i] >> 16);
81 }
82 #endif
83
84 return simde_int16x4_from_private(r_);
85 #endif
86 }
87 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
88 #undef vqdmulh_s16
89 #define vqdmulh_s16(a, b) simde_vqdmulh_s16((a), (b))
90 #endif
91
92 SIMDE_FUNCTION_ATTRIBUTES
93 simde_int32x2_t
94 simde_vqdmulh_s32(simde_int32x2_t a, simde_int32x2_t b) {
95 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
96 return vqdmulh_s32(a, b);
97 #else
98 simde_int32x2_private r_;
99
100 #if HEDLEY_HAS_BUILTIN(__builtin_shufflevector)
101 simde_int32x4_private tmp_ =
102 simde_int32x4_to_private(
103 simde_vreinterpretq_s32_s64(
104 simde_vqdmull_s32(a, b)
105 )
106 );
107
108 r_.values = __builtin_shufflevector(tmp_.values, tmp_.values, 1, 3);
109 #else
110 simde_int32x2_private a_ = simde_int32x2_to_private(a);
111 simde_int32x2_private b_ = simde_int32x2_to_private(b);
112
113 SIMDE_VECTORIZE
114 for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) {
115 r_.values[i] = simde_vqdmulhs_s32(a_.values[i], b_.values[i]);
116 }
117 #endif
118
119 return simde_int32x2_from_private(r_);
120 #endif
121 }
122 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
123 #undef vqdmulh_s32
124 #define vqdmulh_s32(a, b) simde_vqdmulh_s32((a), (b))
125 #endif
126
127 SIMDE_FUNCTION_ATTRIBUTES
128 simde_int16x8_t
129 simde_vqdmulhq_s16(simde_int16x8_t a, simde_int16x8_t b) {
130 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
131 return vqdmulhq_s16(a, b);
132 #else
133 return simde_vcombine_s16(simde_vqdmulh_s16(simde_vget_low_s16(a), simde_vget_low_s16(b)),
134 simde_vqdmulh_s16(simde_vget_high_s16(a), simde_vget_high_s16(b)));
135 #endif
136 }
137 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
138 #undef vqdmulhq_s16
139 #define vqdmulhq_s16(a, b) simde_vqdmulhq_s16((a), (b))
140 #endif
141
142 SIMDE_FUNCTION_ATTRIBUTES
143 simde_int32x4_t
144 simde_vqdmulhq_s32(simde_int32x4_t a, simde_int32x4_t b) {
145 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
146 return vqdmulhq_s32(a, b);
147 #else
148 return simde_vcombine_s32(simde_vqdmulh_s32(simde_vget_low_s32(a), simde_vget_low_s32(b)),
149 simde_vqdmulh_s32(simde_vget_high_s32(a), simde_vget_high_s32(b)));
150 #endif
151 }
152 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
153 #undef vqdmulhq_s32
154 #define vqdmulhq_s32(a, b) simde_vqdmulhq_s32((a), (b))
155 #endif
156
157 SIMDE_END_DECLS_
158 HEDLEY_DIAGNOSTIC_POP
159
160 #endif /* !defined(SIMDE_ARM_NEON_QDMULH_H) */