Debian Codegraph @

src/f32-vclamp/gen/f32-vclamp-wasmsimd-x86-u4.c

raw
1 // Auto-generated file. Do not edit!
2 // Template: src/f32-vclamp/wasmsimd.c.in
3 // Generator: tools/xngen
4 //
5 // Copyright 2020 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
12 #include <wasm_simd128.h>
13
14 #include "xnnpack/common.h"
15 #include "xnnpack/vunary.h"
16
17
18 void xnn_f32_vclamp_ukernel__wasmsimd_x86_u4(
19 size_t batch,
20 const float* input,
21 float* output,
22 const union xnn_f32_minmax_params params[restrict XNN_MIN_ELEMENTS(1)]) XNN_OOB_READS
23 {
24 assert(batch != 0);
25 assert(batch % sizeof(float) == 0);
26 assert(input != NULL);
27 assert(output != NULL);
28
29 const v128_t vy_min = wasm_v128_load32_splat(&params->scalar.min);
30 const v128_t vy_max = wasm_v128_load32_splat(&params->scalar.max);
31 XNN_FORCE_REALIZATION(vy_min);
32 XNN_FORCE_REALIZATION(vy_max);
33
34 for (; batch >= 4 * sizeof(float); batch -= 4 * sizeof(float)) {
35 v128_t vacc = wasm_v128_load(input);
36 input += 4;
37
38 vacc = wasm_f32x4_pmax(vy_min, vacc);
39 vacc = wasm_f32x4_pmin(vy_max, vacc);
40
41 wasm_v128_store(output, vacc);
42 output += 4;
43 }
44 if XNN_UNLIKELY(batch != 0) {
45 v128_t vacc = wasm_v128_load(input);
46
47 vacc = wasm_f32x4_pmax(vy_min, vacc);
48 vacc = wasm_f32x4_pmin(vy_max, vacc);
49
50 if (batch & (2 * sizeof(float))) {
51 wasm_v128_store64_lane(output, vacc, 0);
52 vacc = wasm_v64x2_shuffle(vacc, vacc, 1, 1);
53 output += 2;
54 }
55 if (batch & (1 * sizeof(float))) {
56 wasm_v128_store32_lane(output, vacc, 0);
57 }
58 }
59 }