Debian Codegraph @

src/f32-rminmax/gen/f32-rminmax-wasmsimd-pminmax-u16-acc2.c

raw
1 // Auto-generated file. Do not edit!
2 // Template: src/f32-rminmax/wasmsimd.c.in
3 // Generator: tools/xngen
4 //
5 // Copyright 2023 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/reduce.h"
16
17
18 void xnn_f32_rminmax_ukernel__wasmsimd_pminmax_u16_acc2(
19 size_t batch,
20 const float* input,
21 float* output,
22 const struct xnn_f32_default_params params[restrict XNN_MIN_ELEMENTS(1)])
23 {
24 assert(batch != 0);
25 assert(batch % sizeof(float) == 0);
26 assert(input != NULL);
27 assert(output != NULL);
28
29 v128_t vmin0 = wasm_v128_load32_splat(input);
30 v128_t vmax0 = vmin0;
31 v128_t vmin1 = vmin0;
32 v128_t vmax1 = vmax0;
33 for (; batch >= 16 * sizeof(float); batch -= 16 * sizeof(float)) {
34 const v128_t vt0 = wasm_v128_load(input);
35 const v128_t vt1 = wasm_v128_load(input + 4);
36 const v128_t vt2 = wasm_v128_load(input + 8);
37 const v128_t vt3 = wasm_v128_load(input + 12);
38 input += 16;
39
40 vmin0 = wasm_f32x4_pmin(vmin0, vt0);
41 vmax0 = wasm_f32x4_pmax(vmax0, vt0);
42 vmin1 = wasm_f32x4_pmin(vmin1, vt1);
43 vmax1 = wasm_f32x4_pmax(vmax1, vt1);
44 vmin0 = wasm_f32x4_pmin(vmin0, vt2);
45 vmax0 = wasm_f32x4_pmax(vmax0, vt2);
46 vmin1 = wasm_f32x4_pmin(vmin1, vt3);
47 vmax1 = wasm_f32x4_pmax(vmax1, vt3);
48 }
49 vmin0 = wasm_f32x4_pmin(vmin0, vmin1);
50 vmax0 = wasm_f32x4_pmax(vmax0, vmax1);
51 for (; batch >= 4 * sizeof(float); batch -= 4 * sizeof(float)) {
52 const v128_t vt = wasm_v128_load(input);
53 input += 4;
54
55 vmin0 = wasm_f32x4_pmin(vmin0, vt);
56 vmax0 = wasm_f32x4_pmax(vmax0, vt);
57 }
58 vmin0 = wasm_f32x4_pmin(vmin0, wasm_v64x2_shuffle(vmin0, vmin0, 1, 1));
59 vmax0 = wasm_f32x4_pmax(vmax0, wasm_v64x2_shuffle(vmax0, vmax0, 1, 1));
60 if XNN_UNLIKELY(batch & (2 * sizeof(float))) {
61 const v128_t vt = wasm_v128_load64_zero(input);
62 input += 2;
63 vmin0 = wasm_f32x4_pmin(vmin0, vt);
64 vmax0 = wasm_f32x4_pmax(vmax0, vt);
65 }
66 vmin0 = wasm_f32x4_pmin(vmin0, wasm_v32x4_shuffle(vmin0, vmin0, 1, 1, 1, 1));
67 vmax0 = wasm_f32x4_pmax(vmax0, wasm_v32x4_shuffle(vmax0, vmax0, 1, 1, 1, 1));
68 if XNN_UNLIKELY(batch & (1 * sizeof(float))) {
69 const v128_t vt = wasm_v128_load32_zero(input);
70 vmin0 = wasm_f32x4_pmin(vmin0, vt);
71 vmax0 = wasm_f32x4_pmax(vmax0, vt);
72 }
73 wasm_v128_store32_lane(output, vmin0, 0);
74 wasm_v128_store32_lane(output + 1, vmax0, 0);
75 }