1 // Auto-generated file. Do not edit!
2 // Template: src/f32-ibilinear/sse.c.in
3 // Generator: tools/xngen
4 //
5 // Copyright 2019 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 <immintrin.h>
13
14 #include <xnnpack/ibilinear.h>
15
16
xnn_f32_ibilinear_ukernel__sse_c8(size_t output_pixels,size_t channels,const float ** restrict input,size_t input_offset,const float * restrict weights,float * restrict output,size_t output_increment)17 void xnn_f32_ibilinear_ukernel__sse_c8(
18 size_t output_pixels,
19 size_t channels,
20 const float**restrict input,
21 size_t input_offset,
22 const float*restrict weights,
23 float*restrict output,
24 size_t output_increment) XNN_DISABLE_TSAN
25 {
26 assert(output_pixels != 0);
27 assert(channels != 0);
28 assert(channels % sizeof(float) == 0);
29
30 do {
31 const float* i0 = (const float*) ((uintptr_t) input[0] + input_offset);
32 const float* i1 = (const float*) ((uintptr_t) input[1] + input_offset);
33 const float* i2 = (const float*) ((uintptr_t) input[2] + input_offset);
34 const float* i3 = (const float*) ((uintptr_t) input[3] + input_offset);
35 input += 4;
36
37 __m128 valphahv = _mm_loadl_pi(_mm_undefined_ps(), (const __m64*) weights);
38 valphahv = _mm_unpacklo_ps(valphahv, valphahv);
39 const __m128 valphah = _mm_movelh_ps(valphahv, valphahv);
40 const __m128 valphav = _mm_movehl_ps(valphahv, valphahv);
41 weights += 2;
42
43 size_t c = channels;
44 for (; c >= 8 * sizeof(float); c -= 8 * sizeof(float)) {
45 const __m128 vtl0123 = _mm_loadu_ps(i0);
46 const __m128 vtr0123 = _mm_loadu_ps(i1);
47 const __m128 vbl0123 = _mm_loadu_ps(i2);
48 const __m128 vbr0123 = _mm_loadu_ps(i3);
49 const __m128 vtl4567 = _mm_loadu_ps(i0 + 4);
50 const __m128 vtr4567 = _mm_loadu_ps(i1 + 4);
51 const __m128 vbl4567 = _mm_loadu_ps(i2 + 4);
52 const __m128 vbr4567 = _mm_loadu_ps(i3 + 4);
53 i0 += 8;
54 i1 += 8;
55 i2 += 8;
56 i3 += 8;
57
58 const __m128 vtd0123 = _mm_sub_ps(vtr0123, vtl0123);
59 const __m128 vbd0123 = _mm_sub_ps(vbr0123, vbl0123);
60 const __m128 vtd4567 = _mm_sub_ps(vtr4567, vtl4567);
61 const __m128 vbd4567 = _mm_sub_ps(vbr4567, vbl4567);
62
63 const __m128 vt0123 = _mm_add_ps(vtl0123, _mm_mul_ps(vtd0123, valphah));
64 const __m128 vb0123 = _mm_add_ps(vbl0123, _mm_mul_ps(vbd0123, valphah));
65 const __m128 vt4567 = _mm_add_ps(vtl4567, _mm_mul_ps(vtd4567, valphah));
66 const __m128 vb4567 = _mm_add_ps(vbl4567, _mm_mul_ps(vbd4567, valphah));
67
68 const __m128 vd0123 = _mm_sub_ps(vb0123, vt0123);
69 const __m128 vd4567 = _mm_sub_ps(vb4567, vt4567);
70
71 const __m128 vo0123 = _mm_add_ps(vt0123, _mm_mul_ps(vd0123, valphav));
72 const __m128 vo4567 = _mm_add_ps(vt4567, _mm_mul_ps(vd4567, valphav));
73
74 _mm_storeu_ps(output, vo0123);
75 _mm_storeu_ps(output + 4, vo4567);
76 output += 8;
77 }
78 for (; c >= 4 * sizeof(float); c -= 4 * sizeof(float)) {
79 const __m128 vtl0123 = _mm_loadu_ps(i0);
80 const __m128 vtr0123 = _mm_loadu_ps(i1);
81 const __m128 vbl0123 = _mm_loadu_ps(i2);
82 const __m128 vbr0123 = _mm_loadu_ps(i3);
83 i0 += 4;
84 i1 += 4;
85 i2 += 4;
86 i3 += 4;
87
88 const __m128 vtd0123 = _mm_sub_ps(vtr0123, vtl0123);
89 const __m128 vbd0123 = _mm_sub_ps(vbr0123, vbl0123);
90
91 const __m128 vt0123 = _mm_add_ps(vtl0123, _mm_mul_ps(vtd0123, valphah));
92 const __m128 vb0123 = _mm_add_ps(vbl0123, _mm_mul_ps(vbd0123, valphah));
93
94 const __m128 vd0123 = _mm_sub_ps(vb0123, vt0123);
95
96 const __m128 vo0123 = _mm_add_ps(vt0123, _mm_mul_ps(vd0123, valphav));
97
98 _mm_storeu_ps(output, vo0123);
99 output += 4;
100 }
101 if XNN_UNLIKELY(c != 0) {
102 const __m128 vtl0123 = _mm_loadu_ps(i0);
103 const __m128 vtr0123 = _mm_loadu_ps(i1);
104 const __m128 vbl0123 = _mm_loadu_ps(i2);
105 const __m128 vbr0123 = _mm_loadu_ps(i3);
106
107 const __m128 vtd0123 = _mm_sub_ps(vtr0123, vtl0123);
108 const __m128 vbd0123 = _mm_sub_ps(vbr0123, vbl0123);
109
110 const __m128 vt0123 = _mm_add_ps(vtl0123, _mm_mul_ps(vtd0123, valphah));
111 const __m128 vb0123 = _mm_add_ps(vbl0123, _mm_mul_ps(vbd0123, valphah));
112
113 const __m128 vd0123 = _mm_sub_ps(vb0123, vt0123);
114
115 __m128 vo0123 = _mm_add_ps(vt0123, _mm_mul_ps(vd0123, valphav));
116
117 if (c & (2 * sizeof(float))) {
118 _mm_storel_pi((__m64*) output, vo0123);
119 vo0123 = _mm_movehl_ps(vo0123, vo0123);
120 output += 2;
121 }
122 if (c & (1 * sizeof(float))) {
123 _mm_store_ss(output, vo0123);
124 output += 1;
125 }
126 }
127
128 output = (float*) ((uintptr_t) output + output_increment);
129 } while (--output_pixels != 0);
130 }
131