Marat Dukhan | 403b7d4 | 2019-12-05 12:49:11 -0800 | [diff] [blame] | 1 | // Auto-generated file. Do not edit! |
| 2 | // Template: src/f32-vbinary/vop-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 <xmmintrin.h> |
| 13 | |
| 14 | #include <xnnpack/common.h> |
Marat Dukhan | 8aaf186 | 2020-04-28 10:26:13 -0700 | [diff] [blame^] | 15 | #include <xnnpack/intrinsics-polyfill.h> |
Marat Dukhan | 403b7d4 | 2019-12-05 12:49:11 -0800 | [diff] [blame] | 16 | #include <xnnpack/vbinary.h> |
| 17 | |
| 18 | |
| 19 | void xnn_f32_vmax_ukernel__sse_x8( |
| 20 | size_t n, |
| 21 | const float* a, |
| 22 | const float* b, |
| 23 | float* y, |
Marat Dukhan | f196d01 | 2020-04-15 11:50:03 -0700 | [diff] [blame] | 24 | const union xnn_f32_default_params params[restrict XNN_MIN_ELEMENTS(1)]) |
Marat Dukhan | 403b7d4 | 2019-12-05 12:49:11 -0800 | [diff] [blame] | 25 | { |
| 26 | assert(n != 0); |
| 27 | assert(n % sizeof(float) == 0); |
| 28 | |
Marat Dukhan | 403b7d4 | 2019-12-05 12:49:11 -0800 | [diff] [blame] | 29 | |
| 30 | for (; n >= 8 * sizeof(float); n -= 8 * sizeof(float)) { |
| 31 | const __m128 va0123 = _mm_loadu_ps(a); |
| 32 | const __m128 va4567 = _mm_loadu_ps(a + 4); |
| 33 | a += 8; |
| 34 | |
| 35 | const __m128 vb0123 = _mm_loadu_ps(b); |
| 36 | const __m128 vb4567 = _mm_loadu_ps(b + 4); |
| 37 | b += 8; |
| 38 | |
| 39 | __m128 vy0123 = _mm_max_ps(va0123, vb0123); |
| 40 | __m128 vy4567 = _mm_max_ps(va4567, vb4567); |
| 41 | |
Marat Dukhan | 403b7d4 | 2019-12-05 12:49:11 -0800 | [diff] [blame] | 42 | |
| 43 | _mm_storeu_ps(y, vy0123); |
| 44 | _mm_storeu_ps(y + 4, vy4567); |
| 45 | y += 8; |
| 46 | } |
| 47 | for (; n >= 4 * sizeof(float); n -= 4 * sizeof(float)) { |
| 48 | const __m128 va0123 = _mm_loadu_ps(a); |
| 49 | a += 4; |
| 50 | |
| 51 | const __m128 vb0123 = _mm_loadu_ps(b); |
| 52 | b += 4; |
| 53 | |
| 54 | __m128 vy0123 = _mm_max_ps(va0123, vb0123); |
Marat Dukhan | 403b7d4 | 2019-12-05 12:49:11 -0800 | [diff] [blame] | 55 | _mm_storeu_ps(y, vy0123); |
| 56 | y += 4; |
| 57 | } |
| 58 | if XNN_UNLIKELY(n != 0) { |
Marat Dukhan | 8aaf186 | 2020-04-28 10:26:13 -0700 | [diff] [blame^] | 59 | const __m128 va0123 = _mm_loadu_ps_notsan(a); |
| 60 | const __m128 vb0123 = _mm_loadu_ps_notsan(b); |
Marat Dukhan | 403b7d4 | 2019-12-05 12:49:11 -0800 | [diff] [blame] | 61 | |
| 62 | __m128 vy0123 = _mm_max_ps(va0123, vb0123); |
Marat Dukhan | 403b7d4 | 2019-12-05 12:49:11 -0800 | [diff] [blame] | 63 | if (n & (2 * sizeof(float))) { |
| 64 | _mm_storel_pi((__m64*) y, vy0123); |
| 65 | vy0123 = _mm_movehl_ps(vy0123, vy0123); |
| 66 | y += 2; |
| 67 | } |
| 68 | if (n & (1 * sizeof(float))) { |
| 69 | _mm_store_ss(y, vy0123); |
| 70 | } |
| 71 | } |
| 72 | } |