Debian Codegraph @

src/f32-rminmax/gen/f32-rminmax-wasmsimd-minmax-u4.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_minmax_u4(
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 for (; batch >= 4 * sizeof(float); batch -= 4 * sizeof(float)) {
32 const v128_t vt = wasm_v128_load(input);
33 input += 4;
34
35 vmin0 = wasm_f32x4_min(vmin0, vt);
36 vmax0 = wasm_f32x4_max(vmax0, vt);
37 }
38 vmin0 = wasm_f32x4_min(vmin0, wasm_v64x2_shuffle(vmin0, vmin0, 1, 1));
39 vmax0 = wasm_f32x4_max(vmax0, wasm_v64x2_shuffle(vmax0, vmax0, 1, 1));
40 if XNN_UNLIKELY(batch & (2 * sizeof(float))) {
41 const v128_t vt = wasm_v128_load64_zero(input);
42 input += 2;
43 vmin0 = wasm_f32x4_min(vmin0, vt);
44 vmax0 = wasm_f32x4_max(vmax0, vt);
45 }
46 vmin0 = wasm_f32x4_min(vmin0, wasm_v32x4_shuffle(vmin0, vmin0, 1, 1, 1, 1));
47 vmax0 = wasm_f32x4_max(vmax0, wasm_v32x4_shuffle(vmax0, vmax0, 1, 1, 1, 1));
48 if XNN_UNLIKELY(batch & (1 * sizeof(float))) {
49 const v128_t vt = wasm_v128_load32_zero(input);
50 vmin0 = wasm_f32x4_min(vmin0, vt);
51 vmax0 = wasm_f32x4_max(vmax0, vt);
52 }
53 wasm_v128_store32_lane(output, vmin0, 0);
54 wasm_v128_store32_lane(output + 1, vmax0, 0);
55 }