Debian Codegraph @

src/f32-vcopysign/gen/f32-vrcopysignc-sse2.c

raw
1 // Auto-generated file. Do not edit!
2 // Template: src/f32-vcopysign/rcopysignc.c.in
3 // Generator: tools/xngen
4 //
5 // Copyright 2024 Google LLC
6 //
7 // This source code is licensed under the BSD-style license found in the
8 // LICENSE file in the root directory of this source tree.
9
10 #include <assert.h>
11 #include <stddef.h>
12 #include <stdint.h>
13
14 #include "xnnpack/simd/f32-sse2.h"
15
16 #include "xnnpack/common.h"
17 #include "xnnpack/microparams.h"
18 #include "xnnpack/vunary.h"
19
20
21 void xnn_f32_vrcopysignc_ukernel__sse2_u4(
22 size_t batch,
23 const float* sign,
24 const float* mag,
25 float* output,
26 const struct xnn_f32_default_params unused_params[restrict XNN_MIN_ELEMENTS(1)])
27 {
28 assert(batch != 0);
29 assert(batch % sizeof(float) == 0);
30 assert(sign != NULL);
31 assert(mag != NULL);
32 assert(output != NULL);
33 assert(xnn_simd_size_f32 == 4);
34
35 XNN_SIMD_CONST_F32(vsign_mask, -0.f);
36 xnn_simd_f32_t vmag = xnn_abs_f32(xnn_set1_f32(*mag));
37
38 for (; batch >= xnn_simd_bytes_f32; batch -= xnn_simd_bytes_f32) {
39 xnn_simd_f32_t vsign = xnn_loadu_f32(sign);
40 sign += xnn_simd_size_f32;
41
42 vsign = xnn_and_f32(vsign, vsign_mask);
43
44 xnn_simd_f32_t vy = xnn_or_f32(vsign, vmag);
45
46 xnn_storeu_f32(output, vy);
47 output += xnn_simd_size_f32;
48 }
49 if XNN_UNLIKELY(batch != 0) {
50 xnn_simd_f32_t vsign = xnn_load_tail_f32(sign, batch >> XNN_LOG2_SIZEOF_FLOAT);
51 vsign = xnn_and_f32(vsign, vsign_mask);
52
53 xnn_simd_f32_t vy = xnn_or_f32(vsign, vmag);
54
55 xnn_store_tail_f32(output, vy, batch >> XNN_LOG2_SIZEOF_FLOAT);
56 }
57 }
58
59 void xnn_f32_vrcopysignc_ukernel__sse2_u8(
60 size_t batch,
61 const float* sign,
62 const float* mag,
63 float* output,
64 const struct xnn_f32_default_params unused_params[restrict XNN_MIN_ELEMENTS(1)])
65 {
66 assert(batch != 0);
67 assert(batch % sizeof(float) == 0);
68 assert(sign != NULL);
69 assert(mag != NULL);
70 assert(output != NULL);
71 assert(xnn_simd_size_f32 == 4);
72
73 XNN_SIMD_CONST_F32(vsign_mask, -0.f);
74 xnn_simd_f32_t vmag = xnn_abs_f32(xnn_set1_f32(*mag));
75
76 for (; batch >= 8 * sizeof(float); batch -= 8 * sizeof(float)) {
77 xnn_simd_f32_t vsign_0 = xnn_loadu_f32(sign);
78 xnn_simd_f32_t vsign_1 = xnn_loadu_f32(sign + 1 * xnn_simd_size_f32);
79 sign += 8;
80
81 vsign_0 = xnn_and_f32(vsign_0, vsign_mask);
82 vsign_1 = xnn_and_f32(vsign_1, vsign_mask);
83
84 xnn_simd_f32_t vy_0 = xnn_or_f32(vsign_0, vmag);
85 xnn_simd_f32_t vy_1 = xnn_or_f32(vsign_1, vmag);
86
87 xnn_storeu_f32(output, vy_0);
88 xnn_storeu_f32(output + 1 * xnn_simd_size_f32, vy_1);
89 output += 8;
90 }
91 for (; batch >= xnn_simd_bytes_f32; batch -= xnn_simd_bytes_f32) {
92 xnn_simd_f32_t vsign = xnn_loadu_f32(sign);
93 sign += xnn_simd_size_f32;
94
95 vsign = xnn_and_f32(vsign, vsign_mask);
96
97 xnn_simd_f32_t vy = xnn_or_f32(vsign, vmag);
98
99 xnn_storeu_f32(output, vy);
100 output += xnn_simd_size_f32;
101 }
102 if XNN_UNLIKELY(batch != 0) {
103 xnn_simd_f32_t vsign = xnn_load_tail_f32(sign, batch >> XNN_LOG2_SIZEOF_FLOAT);
104 vsign = xnn_and_f32(vsign, vsign_mask);
105
106 xnn_simd_f32_t vy = xnn_or_f32(vsign, vmag);
107
108 xnn_store_tail_f32(output, vy, batch >> XNN_LOG2_SIZEOF_FLOAT);
109 }
110 }
111
112 void xnn_f32_vrcopysignc_ukernel__sse2_u12(
113 size_t batch,
114 const float* sign,
115 const float* mag,
116 float* output,
117 const struct xnn_f32_default_params unused_params[restrict XNN_MIN_ELEMENTS(1)])
118 {
119 assert(batch != 0);
120 assert(batch % sizeof(float) == 0);
121 assert(sign != NULL);
122 assert(mag != NULL);
123 assert(output != NULL);
124 assert(xnn_simd_size_f32 == 4);
125
126 XNN_SIMD_CONST_F32(vsign_mask, -0.f);
127 xnn_simd_f32_t vmag = xnn_abs_f32(xnn_set1_f32(*mag));
128
129 for (; batch >= 12 * sizeof(float); batch -= 12 * sizeof(float)) {
130 xnn_simd_f32_t vsign_0 = xnn_loadu_f32(sign);
131 xnn_simd_f32_t vsign_1 = xnn_loadu_f32(sign + 1 * xnn_simd_size_f32);
132 xnn_simd_f32_t vsign_2 = xnn_loadu_f32(sign + 2 * xnn_simd_size_f32);
133 sign += 12;
134
135 vsign_0 = xnn_and_f32(vsign_0, vsign_mask);
136 vsign_1 = xnn_and_f32(vsign_1, vsign_mask);
137 vsign_2 = xnn_and_f32(vsign_2, vsign_mask);
138
139 xnn_simd_f32_t vy_0 = xnn_or_f32(vsign_0, vmag);
140 xnn_simd_f32_t vy_1 = xnn_or_f32(vsign_1, vmag);
141 xnn_simd_f32_t vy_2 = xnn_or_f32(vsign_2, vmag);
142
143 xnn_storeu_f32(output, vy_0);
144 xnn_storeu_f32(output + 1 * xnn_simd_size_f32, vy_1);
145 xnn_storeu_f32(output + 2 * xnn_simd_size_f32, vy_2);
146 output += 12;
147 }
148 for (; batch >= xnn_simd_bytes_f32; batch -= xnn_simd_bytes_f32) {
149 xnn_simd_f32_t vsign = xnn_loadu_f32(sign);
150 sign += xnn_simd_size_f32;
151
152 vsign = xnn_and_f32(vsign, vsign_mask);
153
154 xnn_simd_f32_t vy = xnn_or_f32(vsign, vmag);
155
156 xnn_storeu_f32(output, vy);
157 output += xnn_simd_size_f32;
158 }
159 if XNN_UNLIKELY(batch != 0) {
160 xnn_simd_f32_t vsign = xnn_load_tail_f32(sign, batch >> XNN_LOG2_SIZEOF_FLOAT);
161 vsign = xnn_and_f32(vsign, vsign_mask);
162
163 xnn_simd_f32_t vy = xnn_or_f32(vsign, vmag);
164
165 xnn_store_tail_f32(output, vy, batch >> XNN_LOG2_SIZEOF_FLOAT);
166 }
167 }
168
169 void xnn_f32_vrcopysignc_ukernel__sse2_u16(
170 size_t batch,
171 const float* sign,
172 const float* mag,
173 float* output,
174 const struct xnn_f32_default_params unused_params[restrict XNN_MIN_ELEMENTS(1)])
175 {
176 assert(batch != 0);
177 assert(batch % sizeof(float) == 0);
178 assert(sign != NULL);
179 assert(mag != NULL);
180 assert(output != NULL);
181 assert(xnn_simd_size_f32 == 4);
182
183 XNN_SIMD_CONST_F32(vsign_mask, -0.f);
184 xnn_simd_f32_t vmag = xnn_abs_f32(xnn_set1_f32(*mag));
185
186 for (; batch >= 16 * sizeof(float); batch -= 16 * sizeof(float)) {
187 xnn_simd_f32_t vsign_0 = xnn_loadu_f32(sign);
188 xnn_simd_f32_t vsign_1 = xnn_loadu_f32(sign + 1 * xnn_simd_size_f32);
189 xnn_simd_f32_t vsign_2 = xnn_loadu_f32(sign + 2 * xnn_simd_size_f32);
190 xnn_simd_f32_t vsign_3 = xnn_loadu_f32(sign + 3 * xnn_simd_size_f32);
191 sign += 16;
192
193 vsign_0 = xnn_and_f32(vsign_0, vsign_mask);
194 vsign_1 = xnn_and_f32(vsign_1, vsign_mask);
195 vsign_2 = xnn_and_f32(vsign_2, vsign_mask);
196 vsign_3 = xnn_and_f32(vsign_3, vsign_mask);
197
198 xnn_simd_f32_t vy_0 = xnn_or_f32(vsign_0, vmag);
199 xnn_simd_f32_t vy_1 = xnn_or_f32(vsign_1, vmag);
200 xnn_simd_f32_t vy_2 = xnn_or_f32(vsign_2, vmag);
201 xnn_simd_f32_t vy_3 = xnn_or_f32(vsign_3, vmag);
202
203 xnn_storeu_f32(output, vy_0);
204 xnn_storeu_f32(output + 1 * xnn_simd_size_f32, vy_1);
205 xnn_storeu_f32(output + 2 * xnn_simd_size_f32, vy_2);
206 xnn_storeu_f32(output + 3 * xnn_simd_size_f32, vy_3);
207 output += 16;
208 }
209 for (; batch >= xnn_simd_bytes_f32; batch -= xnn_simd_bytes_f32) {
210 xnn_simd_f32_t vsign = xnn_loadu_f32(sign);
211 sign += xnn_simd_size_f32;
212
213 vsign = xnn_and_f32(vsign, vsign_mask);
214
215 xnn_simd_f32_t vy = xnn_or_f32(vsign, vmag);
216
217 xnn_storeu_f32(output, vy);
218 output += xnn_simd_size_f32;
219 }
220 if XNN_UNLIKELY(batch != 0) {
221 xnn_simd_f32_t vsign = xnn_load_tail_f32(sign, batch >> XNN_LOG2_SIZEOF_FLOAT);
222 vsign = xnn_and_f32(vsign, vsign_mask);
223
224 xnn_simd_f32_t vy = xnn_or_f32(vsign, vmag);
225
226 xnn_store_tail_f32(output, vy, batch >> XNN_LOG2_SIZEOF_FLOAT);
227 }
228 }