Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 1 | /*===---- avxintrin.h - AVX intrinsics -------------------------------------=== |
| 2 | * |
| 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 4 | * of this software and associated documentation files (the "Software"), to deal |
| 5 | * in the Software without restriction, including without limitation the rights |
| 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 7 | * copies of the Software, and to permit persons to whom the Software is |
| 8 | * furnished to do so, subject to the following conditions: |
| 9 | * |
| 10 | * The above copyright notice and this permission notice shall be included in |
| 11 | * all copies or substantial portions of the Software. |
| 12 | * |
| 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 19 | * THE SOFTWARE. |
| 20 | * |
| 21 | *===-----------------------------------------------------------------------=== |
| 22 | */ |
| 23 | |
Benjamin Kramer | 6f35f3c | 2010-08-20 23:00:03 +0000 | [diff] [blame] | 24 | #ifndef __IMMINTRIN_H |
| 25 | #error "Never use <avxintrin.h> directly; include <immintrin.h> instead." |
| 26 | #endif |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 27 | |
Richard Smith | 49e5644 | 2013-07-14 05:41:45 +0000 | [diff] [blame] | 28 | #ifndef __AVXINTRIN_H |
| 29 | #define __AVXINTRIN_H |
| 30 | |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 31 | typedef double __v4df __attribute__ ((__vector_size__ (32))); |
| 32 | typedef float __v8sf __attribute__ ((__vector_size__ (32))); |
| 33 | typedef long long __v4di __attribute__ ((__vector_size__ (32))); |
| 34 | typedef int __v8si __attribute__ ((__vector_size__ (32))); |
| 35 | typedef short __v16hi __attribute__ ((__vector_size__ (32))); |
| 36 | typedef char __v32qi __attribute__ ((__vector_size__ (32))); |
| 37 | |
| 38 | typedef float __m256 __attribute__ ((__vector_size__ (32))); |
| 39 | typedef double __m256d __attribute__((__vector_size__(32))); |
| 40 | typedef long long __m256i __attribute__((__vector_size__(32))); |
| 41 | |
| 42 | /* Arithmetic */ |
| 43 | static __inline __m256d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 44 | _mm256_add_pd(__m256d __a, __m256d __b) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 45 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 46 | return __a+__b; |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 47 | } |
| 48 | |
| 49 | static __inline __m256 __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 50 | _mm256_add_ps(__m256 __a, __m256 __b) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 51 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 52 | return __a+__b; |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 53 | } |
| 54 | |
| 55 | static __inline __m256d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 56 | _mm256_sub_pd(__m256d __a, __m256d __b) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 57 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 58 | return __a-__b; |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 59 | } |
| 60 | |
| 61 | static __inline __m256 __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 62 | _mm256_sub_ps(__m256 __a, __m256 __b) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 63 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 64 | return __a-__b; |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 65 | } |
| 66 | |
| 67 | static __inline __m256d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 68 | _mm256_addsub_pd(__m256d __a, __m256d __b) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 69 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 70 | return (__m256d)__builtin_ia32_addsubpd256((__v4df)__a, (__v4df)__b); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 71 | } |
| 72 | |
| 73 | static __inline __m256 __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 74 | _mm256_addsub_ps(__m256 __a, __m256 __b) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 75 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 76 | return (__m256)__builtin_ia32_addsubps256((__v8sf)__a, (__v8sf)__b); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 77 | } |
| 78 | |
| 79 | static __inline __m256d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 80 | _mm256_div_pd(__m256d __a, __m256d __b) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 81 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 82 | return __a / __b; |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 83 | } |
| 84 | |
| 85 | static __inline __m256 __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 86 | _mm256_div_ps(__m256 __a, __m256 __b) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 87 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 88 | return __a / __b; |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 89 | } |
| 90 | |
| 91 | static __inline __m256d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 92 | _mm256_max_pd(__m256d __a, __m256d __b) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 93 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 94 | return (__m256d)__builtin_ia32_maxpd256((__v4df)__a, (__v4df)__b); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 95 | } |
| 96 | |
| 97 | static __inline __m256 __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 98 | _mm256_max_ps(__m256 __a, __m256 __b) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 99 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 100 | return (__m256)__builtin_ia32_maxps256((__v8sf)__a, (__v8sf)__b); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 101 | } |
| 102 | |
| 103 | static __inline __m256d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 104 | _mm256_min_pd(__m256d __a, __m256d __b) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 105 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 106 | return (__m256d)__builtin_ia32_minpd256((__v4df)__a, (__v4df)__b); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 107 | } |
| 108 | |
| 109 | static __inline __m256 __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 110 | _mm256_min_ps(__m256 __a, __m256 __b) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 111 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 112 | return (__m256)__builtin_ia32_minps256((__v8sf)__a, (__v8sf)__b); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 113 | } |
| 114 | |
| 115 | static __inline __m256d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 116 | _mm256_mul_pd(__m256d __a, __m256d __b) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 117 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 118 | return __a * __b; |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 119 | } |
| 120 | |
| 121 | static __inline __m256 __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 122 | _mm256_mul_ps(__m256 __a, __m256 __b) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 123 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 124 | return __a * __b; |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 125 | } |
| 126 | |
| 127 | static __inline __m256d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 128 | _mm256_sqrt_pd(__m256d __a) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 129 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 130 | return (__m256d)__builtin_ia32_sqrtpd256((__v4df)__a); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 131 | } |
| 132 | |
| 133 | static __inline __m256 __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 134 | _mm256_sqrt_ps(__m256 __a) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 135 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 136 | return (__m256)__builtin_ia32_sqrtps256((__v8sf)__a); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 137 | } |
| 138 | |
| 139 | static __inline __m256 __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 140 | _mm256_rsqrt_ps(__m256 __a) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 141 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 142 | return (__m256)__builtin_ia32_rsqrtps256((__v8sf)__a); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 143 | } |
| 144 | |
| 145 | static __inline __m256 __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 146 | _mm256_rcp_ps(__m256 __a) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 147 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 148 | return (__m256)__builtin_ia32_rcpps256((__v8sf)__a); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 149 | } |
| 150 | |
Chad Rosier | 060d03b | 2011-12-17 00:15:26 +0000 | [diff] [blame] | 151 | #define _mm256_round_pd(V, M) __extension__ ({ \ |
| 152 | __m256d __V = (V); \ |
Craig Topper | 9f00948 | 2011-12-24 07:55:14 +0000 | [diff] [blame] | 153 | (__m256d)__builtin_ia32_roundpd256((__v4df)__V, (M)); }) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 154 | |
Chad Rosier | 060d03b | 2011-12-17 00:15:26 +0000 | [diff] [blame] | 155 | #define _mm256_round_ps(V, M) __extension__ ({ \ |
| 156 | __m256 __V = (V); \ |
Craig Topper | 9f00948 | 2011-12-24 07:55:14 +0000 | [diff] [blame] | 157 | (__m256)__builtin_ia32_roundps256((__v8sf)__V, (M)); }) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 158 | |
| 159 | #define _mm256_ceil_pd(V) _mm256_round_pd((V), _MM_FROUND_CEIL) |
| 160 | #define _mm256_floor_pd(V) _mm256_round_pd((V), _MM_FROUND_FLOOR) |
| 161 | #define _mm256_ceil_ps(V) _mm256_round_ps((V), _MM_FROUND_CEIL) |
| 162 | #define _mm256_floor_ps(V) _mm256_round_ps((V), _MM_FROUND_FLOOR) |
| 163 | |
| 164 | /* Logical */ |
| 165 | static __inline __m256d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 166 | _mm256_and_pd(__m256d __a, __m256d __b) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 167 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 168 | return (__m256d)((__v4di)__a & (__v4di)__b); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 169 | } |
| 170 | |
| 171 | static __inline __m256 __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 172 | _mm256_and_ps(__m256 __a, __m256 __b) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 173 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 174 | return (__m256)((__v8si)__a & (__v8si)__b); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 175 | } |
| 176 | |
| 177 | static __inline __m256d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 178 | _mm256_andnot_pd(__m256d __a, __m256d __b) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 179 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 180 | return (__m256d)(~(__v4di)__a & (__v4di)__b); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 181 | } |
| 182 | |
| 183 | static __inline __m256 __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 184 | _mm256_andnot_ps(__m256 __a, __m256 __b) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 185 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 186 | return (__m256)(~(__v8si)__a & (__v8si)__b); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 187 | } |
| 188 | |
| 189 | static __inline __m256d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 190 | _mm256_or_pd(__m256d __a, __m256d __b) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 191 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 192 | return (__m256d)((__v4di)__a | (__v4di)__b); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 193 | } |
| 194 | |
| 195 | static __inline __m256 __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 196 | _mm256_or_ps(__m256 __a, __m256 __b) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 197 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 198 | return (__m256)((__v8si)__a | (__v8si)__b); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 199 | } |
| 200 | |
| 201 | static __inline __m256d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 202 | _mm256_xor_pd(__m256d __a, __m256d __b) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 203 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 204 | return (__m256d)((__v4di)__a ^ (__v4di)__b); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 205 | } |
| 206 | |
| 207 | static __inline __m256 __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 208 | _mm256_xor_ps(__m256 __a, __m256 __b) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 209 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 210 | return (__m256)((__v8si)__a ^ (__v8si)__b); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 211 | } |
| 212 | |
| 213 | /* Horizontal arithmetic */ |
| 214 | static __inline __m256d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 215 | _mm256_hadd_pd(__m256d __a, __m256d __b) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 216 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 217 | return (__m256d)__builtin_ia32_haddpd256((__v4df)__a, (__v4df)__b); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 218 | } |
| 219 | |
| 220 | static __inline __m256 __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 221 | _mm256_hadd_ps(__m256 __a, __m256 __b) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 222 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 223 | return (__m256)__builtin_ia32_haddps256((__v8sf)__a, (__v8sf)__b); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 224 | } |
| 225 | |
| 226 | static __inline __m256d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 227 | _mm256_hsub_pd(__m256d __a, __m256d __b) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 228 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 229 | return (__m256d)__builtin_ia32_hsubpd256((__v4df)__a, (__v4df)__b); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 230 | } |
| 231 | |
| 232 | static __inline __m256 __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 233 | _mm256_hsub_ps(__m256 __a, __m256 __b) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 234 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 235 | return (__m256)__builtin_ia32_hsubps256((__v8sf)__a, (__v8sf)__b); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 236 | } |
| 237 | |
| 238 | /* Vector permutations */ |
| 239 | static __inline __m128d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 240 | _mm_permutevar_pd(__m128d __a, __m128i __c) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 241 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 242 | return (__m128d)__builtin_ia32_vpermilvarpd((__v2df)__a, (__v2di)__c); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 243 | } |
| 244 | |
| 245 | static __inline __m256d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 246 | _mm256_permutevar_pd(__m256d __a, __m256i __c) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 247 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 248 | return (__m256d)__builtin_ia32_vpermilvarpd256((__v4df)__a, (__v4di)__c); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 249 | } |
| 250 | |
| 251 | static __inline __m128 __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 252 | _mm_permutevar_ps(__m128 __a, __m128i __c) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 253 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 254 | return (__m128)__builtin_ia32_vpermilvarps((__v4sf)__a, (__v4si)__c); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 255 | } |
| 256 | |
| 257 | static __inline __m256 __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 258 | _mm256_permutevar_ps(__m256 __a, __m256i __c) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 259 | { |
Craig Topper | 9fee8ab | 2015-01-31 06:33:59 +0000 | [diff] [blame^] | 260 | return (__m256)__builtin_ia32_vpermilvarps256((__v8sf)__a, (__v8si)__c); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 261 | } |
| 262 | |
Chad Rosier | 93375d5 | 2011-12-17 01:39:56 +0000 | [diff] [blame] | 263 | #define _mm_permute_pd(A, C) __extension__ ({ \ |
| 264 | __m128d __A = (A); \ |
Craig Topper | fec9f8e | 2012-02-08 05:16:54 +0000 | [diff] [blame] | 265 | (__m128d)__builtin_shufflevector((__v2df)__A, (__v2df) _mm_setzero_pd(), \ |
| 266 | (C) & 0x1, ((C) & 0x2) >> 1); }) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 267 | |
Chad Rosier | 93375d5 | 2011-12-17 01:39:56 +0000 | [diff] [blame] | 268 | #define _mm256_permute_pd(A, C) __extension__ ({ \ |
| 269 | __m256d __A = (A); \ |
Craig Topper | fec9f8e | 2012-02-08 05:16:54 +0000 | [diff] [blame] | 270 | (__m256d)__builtin_shufflevector((__v4df)__A, (__v4df) _mm256_setzero_pd(), \ |
| 271 | (C) & 0x1, ((C) & 0x2) >> 1, \ |
| 272 | 2 + (((C) & 0x4) >> 2), \ |
| 273 | 2 + (((C) & 0x8) >> 3)); }) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 274 | |
Chad Rosier | 7caca84 | 2011-12-17 01:51:05 +0000 | [diff] [blame] | 275 | #define _mm_permute_ps(A, C) __extension__ ({ \ |
| 276 | __m128 __A = (A); \ |
Craig Topper | fec9f8e | 2012-02-08 05:16:54 +0000 | [diff] [blame] | 277 | (__m128)__builtin_shufflevector((__v4sf)__A, (__v4sf) _mm_setzero_ps(), \ |
| 278 | (C) & 0x3, ((C) & 0xc) >> 2, \ |
Craig Topper | 678a53c | 2012-03-30 05:09:18 +0000 | [diff] [blame] | 279 | ((C) & 0x30) >> 4, ((C) & 0xc0) >> 6); }) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 280 | |
Chad Rosier | 7caca84 | 2011-12-17 01:51:05 +0000 | [diff] [blame] | 281 | #define _mm256_permute_ps(A, C) __extension__ ({ \ |
| 282 | __m256 __A = (A); \ |
Craig Topper | fec9f8e | 2012-02-08 05:16:54 +0000 | [diff] [blame] | 283 | (__m256)__builtin_shufflevector((__v8sf)__A, (__v8sf) _mm256_setzero_ps(), \ |
| 284 | (C) & 0x3, ((C) & 0xc) >> 2, \ |
| 285 | ((C) & 0x30) >> 4, ((C) & 0xc0) >> 6, \ |
| 286 | 4 + (((C) & 0x03) >> 0), \ |
| 287 | 4 + (((C) & 0x0c) >> 2), \ |
| 288 | 4 + (((C) & 0x30) >> 4), \ |
| 289 | 4 + (((C) & 0xc0) >> 6)); }) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 290 | |
Chad Rosier | 9138fea25 | 2011-12-16 21:07:34 +0000 | [diff] [blame] | 291 | #define _mm256_permute2f128_pd(V1, V2, M) __extension__ ({ \ |
| 292 | __m256d __V1 = (V1); \ |
| 293 | __m256d __V2 = (V2); \ |
Craig Topper | 26e74e5 | 2012-04-17 05:16:56 +0000 | [diff] [blame] | 294 | (__m256d)__builtin_ia32_vperm2f128_pd256((__v4df)__V1, (__v4df)__V2, (M)); }) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 295 | |
Chad Rosier | 9138fea25 | 2011-12-16 21:07:34 +0000 | [diff] [blame] | 296 | #define _mm256_permute2f128_ps(V1, V2, M) __extension__ ({ \ |
| 297 | __m256 __V1 = (V1); \ |
| 298 | __m256 __V2 = (V2); \ |
Craig Topper | 26e74e5 | 2012-04-17 05:16:56 +0000 | [diff] [blame] | 299 | (__m256)__builtin_ia32_vperm2f128_ps256((__v8sf)__V1, (__v8sf)__V2, (M)); }) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 300 | |
Chad Rosier | 9138fea25 | 2011-12-16 21:07:34 +0000 | [diff] [blame] | 301 | #define _mm256_permute2f128_si256(V1, V2, M) __extension__ ({ \ |
| 302 | __m256i __V1 = (V1); \ |
| 303 | __m256i __V2 = (V2); \ |
Craig Topper | 26e74e5 | 2012-04-17 05:16:56 +0000 | [diff] [blame] | 304 | (__m256i)__builtin_ia32_vperm2f128_si256((__v8si)__V1, (__v8si)__V2, (M)); }) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 305 | |
| 306 | /* Vector Blend */ |
Eli Friedman | f16beb3 | 2011-11-10 00:11:13 +0000 | [diff] [blame] | 307 | #define _mm256_blend_pd(V1, V2, M) __extension__ ({ \ |
| 308 | __m256d __V1 = (V1); \ |
| 309 | __m256d __V2 = (V2); \ |
Filipe Cabecinhas | 5d289b4 | 2014-05-13 02:37:02 +0000 | [diff] [blame] | 310 | (__m256d)__builtin_shufflevector((__v4df)__V1, (__v4df)__V2, \ |
| 311 | (((M) & 0x01) ? 4 : 0), \ |
| 312 | (((M) & 0x02) ? 5 : 1), \ |
| 313 | (((M) & 0x04) ? 6 : 2), \ |
| 314 | (((M) & 0x08) ? 7 : 3)); }) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 315 | |
Eli Friedman | f16beb3 | 2011-11-10 00:11:13 +0000 | [diff] [blame] | 316 | #define _mm256_blend_ps(V1, V2, M) __extension__ ({ \ |
| 317 | __m256 __V1 = (V1); \ |
| 318 | __m256 __V2 = (V2); \ |
Filipe Cabecinhas | 5d289b4 | 2014-05-13 02:37:02 +0000 | [diff] [blame] | 319 | (__m256)__builtin_shufflevector((__v8sf)__V1, (__v8sf)__V2, \ |
| 320 | (((M) & 0x01) ? 8 : 0), \ |
| 321 | (((M) & 0x02) ? 9 : 1), \ |
| 322 | (((M) & 0x04) ? 10 : 2), \ |
| 323 | (((M) & 0x08) ? 11 : 3), \ |
| 324 | (((M) & 0x10) ? 12 : 4), \ |
| 325 | (((M) & 0x20) ? 13 : 5), \ |
| 326 | (((M) & 0x40) ? 14 : 6), \ |
| 327 | (((M) & 0x80) ? 15 : 7)); }) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 328 | |
| 329 | static __inline __m256d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 330 | _mm256_blendv_pd(__m256d __a, __m256d __b, __m256d __c) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 331 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 332 | return (__m256d)__builtin_ia32_blendvpd256( |
| 333 | (__v4df)__a, (__v4df)__b, (__v4df)__c); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 334 | } |
| 335 | |
| 336 | static __inline __m256 __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 337 | _mm256_blendv_ps(__m256 __a, __m256 __b, __m256 __c) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 338 | { |
David Blaikie | 5bb7003 | 2013-01-16 23:13:42 +0000 | [diff] [blame] | 339 | return (__m256)__builtin_ia32_blendvps256( |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 340 | (__v8sf)__a, (__v8sf)__b, (__v8sf)__c); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 341 | } |
| 342 | |
| 343 | /* Vector Dot Product */ |
Eli Friedman | f16beb3 | 2011-11-10 00:11:13 +0000 | [diff] [blame] | 344 | #define _mm256_dp_ps(V1, V2, M) __extension__ ({ \ |
| 345 | __m256 __V1 = (V1); \ |
| 346 | __m256 __V2 = (V2); \ |
Craig Topper | 9f00948 | 2011-12-24 07:55:14 +0000 | [diff] [blame] | 347 | (__m256)__builtin_ia32_dpps256((__v8sf)__V1, (__v8sf)__V2, (M)); }) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 348 | |
| 349 | /* Vector shuffle */ |
Bob Wilson | c9b97cc | 2011-11-05 06:08:06 +0000 | [diff] [blame] | 350 | #define _mm256_shuffle_ps(a, b, mask) __extension__ ({ \ |
| 351 | __m256 __a = (a); \ |
| 352 | __m256 __b = (b); \ |
| 353 | (__m256)__builtin_shufflevector((__v8sf)__a, (__v8sf)__b, \ |
Bruno Cardoso Lopes | e712a13 | 2010-08-11 01:17:34 +0000 | [diff] [blame] | 354 | (mask) & 0x3, ((mask) & 0xc) >> 2, \ |
Bruno Cardoso Lopes | 8c33315 | 2010-08-11 18:45:43 +0000 | [diff] [blame] | 355 | (((mask) & 0x30) >> 4) + 8, (((mask) & 0xc0) >> 6) + 8, \ |
Bruno Cardoso Lopes | 7a98a7e | 2011-08-23 23:29:45 +0000 | [diff] [blame] | 356 | ((mask) & 0x3) + 4, (((mask) & 0xc) >> 2) + 4, \ |
Bob Wilson | c9b97cc | 2011-11-05 06:08:06 +0000 | [diff] [blame] | 357 | (((mask) & 0x30) >> 4) + 12, (((mask) & 0xc0) >> 6) + 12); }) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 358 | |
Bob Wilson | c9b97cc | 2011-11-05 06:08:06 +0000 | [diff] [blame] | 359 | #define _mm256_shuffle_pd(a, b, mask) __extension__ ({ \ |
| 360 | __m256d __a = (a); \ |
| 361 | __m256d __b = (b); \ |
| 362 | (__m256d)__builtin_shufflevector((__v4df)__a, (__v4df)__b, \ |
Bruno Cardoso Lopes | e712a13 | 2010-08-11 01:17:34 +0000 | [diff] [blame] | 363 | (mask) & 0x1, \ |
| 364 | (((mask) & 0x2) >> 1) + 4, \ |
| 365 | (((mask) & 0x4) >> 2) + 2, \ |
Bob Wilson | c9b97cc | 2011-11-05 06:08:06 +0000 | [diff] [blame] | 366 | (((mask) & 0x8) >> 3) + 6); }) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 367 | |
| 368 | /* Compare */ |
| 369 | #define _CMP_EQ_OQ 0x00 /* Equal (ordered, non-signaling) */ |
| 370 | #define _CMP_LT_OS 0x01 /* Less-than (ordered, signaling) */ |
| 371 | #define _CMP_LE_OS 0x02 /* Less-than-or-equal (ordered, signaling) */ |
| 372 | #define _CMP_UNORD_Q 0x03 /* Unordered (non-signaling) */ |
| 373 | #define _CMP_NEQ_UQ 0x04 /* Not-equal (unordered, non-signaling) */ |
| 374 | #define _CMP_NLT_US 0x05 /* Not-less-than (unordered, signaling) */ |
| 375 | #define _CMP_NLE_US 0x06 /* Not-less-than-or-equal (unordered, signaling) */ |
| 376 | #define _CMP_ORD_Q 0x07 /* Ordered (nonsignaling) */ |
| 377 | #define _CMP_EQ_UQ 0x08 /* Equal (unordered, non-signaling) */ |
| 378 | #define _CMP_NGE_US 0x09 /* Not-greater-than-or-equal (unord, signaling) */ |
| 379 | #define _CMP_NGT_US 0x0a /* Not-greater-than (unordered, signaling) */ |
| 380 | #define _CMP_FALSE_OQ 0x0b /* False (ordered, non-signaling) */ |
| 381 | #define _CMP_NEQ_OQ 0x0c /* Not-equal (ordered, non-signaling) */ |
| 382 | #define _CMP_GE_OS 0x0d /* Greater-than-or-equal (ordered, signaling) */ |
| 383 | #define _CMP_GT_OS 0x0e /* Greater-than (ordered, signaling) */ |
| 384 | #define _CMP_TRUE_UQ 0x0f /* True (unordered, non-signaling) */ |
| 385 | #define _CMP_EQ_OS 0x10 /* Equal (ordered, signaling) */ |
| 386 | #define _CMP_LT_OQ 0x11 /* Less-than (ordered, non-signaling) */ |
| 387 | #define _CMP_LE_OQ 0x12 /* Less-than-or-equal (ordered, non-signaling) */ |
| 388 | #define _CMP_UNORD_S 0x13 /* Unordered (signaling) */ |
| 389 | #define _CMP_NEQ_US 0x14 /* Not-equal (unordered, signaling) */ |
| 390 | #define _CMP_NLT_UQ 0x15 /* Not-less-than (unordered, non-signaling) */ |
| 391 | #define _CMP_NLE_UQ 0x16 /* Not-less-than-or-equal (unord, non-signaling) */ |
| 392 | #define _CMP_ORD_S 0x17 /* Ordered (signaling) */ |
| 393 | #define _CMP_EQ_US 0x18 /* Equal (unordered, signaling) */ |
| 394 | #define _CMP_NGE_UQ 0x19 /* Not-greater-than-or-equal (unord, non-sign) */ |
| 395 | #define _CMP_NGT_UQ 0x1a /* Not-greater-than (unordered, non-signaling) */ |
| 396 | #define _CMP_FALSE_OS 0x1b /* False (ordered, signaling) */ |
| 397 | #define _CMP_NEQ_OS 0x1c /* Not-equal (ordered, signaling) */ |
| 398 | #define _CMP_GE_OQ 0x1d /* Greater-than-or-equal (ordered, non-signaling) */ |
| 399 | #define _CMP_GT_OQ 0x1e /* Greater-than (ordered, non-signaling) */ |
| 400 | #define _CMP_TRUE_US 0x1f /* True (unordered, signaling) */ |
| 401 | |
Bob Wilson | c9b97cc | 2011-11-05 06:08:06 +0000 | [diff] [blame] | 402 | #define _mm_cmp_pd(a, b, c) __extension__ ({ \ |
| 403 | __m128d __a = (a); \ |
| 404 | __m128d __b = (b); \ |
| 405 | (__m128d)__builtin_ia32_cmppd((__v2df)__a, (__v2df)__b, (c)); }) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 406 | |
Bob Wilson | c9b97cc | 2011-11-05 06:08:06 +0000 | [diff] [blame] | 407 | #define _mm_cmp_ps(a, b, c) __extension__ ({ \ |
| 408 | __m128 __a = (a); \ |
| 409 | __m128 __b = (b); \ |
| 410 | (__m128)__builtin_ia32_cmpps((__v4sf)__a, (__v4sf)__b, (c)); }) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 411 | |
Bob Wilson | c9b97cc | 2011-11-05 06:08:06 +0000 | [diff] [blame] | 412 | #define _mm256_cmp_pd(a, b, c) __extension__ ({ \ |
| 413 | __m256d __a = (a); \ |
| 414 | __m256d __b = (b); \ |
| 415 | (__m256d)__builtin_ia32_cmppd256((__v4df)__a, (__v4df)__b, (c)); }) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 416 | |
Bob Wilson | c9b97cc | 2011-11-05 06:08:06 +0000 | [diff] [blame] | 417 | #define _mm256_cmp_ps(a, b, c) __extension__ ({ \ |
| 418 | __m256 __a = (a); \ |
| 419 | __m256 __b = (b); \ |
| 420 | (__m256)__builtin_ia32_cmpps256((__v8sf)__a, (__v8sf)__b, (c)); }) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 421 | |
Bob Wilson | c9b97cc | 2011-11-05 06:08:06 +0000 | [diff] [blame] | 422 | #define _mm_cmp_sd(a, b, c) __extension__ ({ \ |
| 423 | __m128d __a = (a); \ |
| 424 | __m128d __b = (b); \ |
| 425 | (__m128d)__builtin_ia32_cmpsd((__v2df)__a, (__v2df)__b, (c)); }) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 426 | |
Bob Wilson | c9b97cc | 2011-11-05 06:08:06 +0000 | [diff] [blame] | 427 | #define _mm_cmp_ss(a, b, c) __extension__ ({ \ |
| 428 | __m128 __a = (a); \ |
| 429 | __m128 __b = (b); \ |
| 430 | (__m128)__builtin_ia32_cmpss((__v4sf)__a, (__v4sf)__b, (c)); }) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 431 | |
| 432 | /* Vector extract */ |
Chad Rosier | 0adfe7a | 2011-12-17 01:22:27 +0000 | [diff] [blame] | 433 | #define _mm256_extractf128_pd(A, O) __extension__ ({ \ |
| 434 | __m256d __A = (A); \ |
Craig Topper | 9f00948 | 2011-12-24 07:55:14 +0000 | [diff] [blame] | 435 | (__m128d)__builtin_ia32_vextractf128_pd256((__v4df)__A, (O)); }) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 436 | |
Chad Rosier | 0adfe7a | 2011-12-17 01:22:27 +0000 | [diff] [blame] | 437 | #define _mm256_extractf128_ps(A, O) __extension__ ({ \ |
| 438 | __m256 __A = (A); \ |
Craig Topper | 9f00948 | 2011-12-24 07:55:14 +0000 | [diff] [blame] | 439 | (__m128)__builtin_ia32_vextractf128_ps256((__v8sf)__A, (O)); }) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 440 | |
Chad Rosier | 0adfe7a | 2011-12-17 01:22:27 +0000 | [diff] [blame] | 441 | #define _mm256_extractf128_si256(A, O) __extension__ ({ \ |
| 442 | __m256i __A = (A); \ |
Craig Topper | 9f00948 | 2011-12-24 07:55:14 +0000 | [diff] [blame] | 443 | (__m128i)__builtin_ia32_vextractf128_si256((__v8si)__A, (O)); }) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 444 | |
| 445 | static __inline int __attribute__((__always_inline__, __nodebug__)) |
Craig Topper | 459554f | 2015-01-31 06:31:30 +0000 | [diff] [blame] | 446 | _mm256_extract_epi32(__m256i __a, const int __imm) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 447 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 448 | __v8si __b = (__v8si)__a; |
Manman Ren | c94122e | 2013-10-23 20:33:14 +0000 | [diff] [blame] | 449 | return __b[__imm & 7]; |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 450 | } |
| 451 | |
| 452 | static __inline int __attribute__((__always_inline__, __nodebug__)) |
Craig Topper | 459554f | 2015-01-31 06:31:30 +0000 | [diff] [blame] | 453 | _mm256_extract_epi16(__m256i __a, const int __imm) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 454 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 455 | __v16hi __b = (__v16hi)__a; |
Manman Ren | c94122e | 2013-10-23 20:33:14 +0000 | [diff] [blame] | 456 | return __b[__imm & 15]; |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 457 | } |
| 458 | |
| 459 | static __inline int __attribute__((__always_inline__, __nodebug__)) |
Craig Topper | 459554f | 2015-01-31 06:31:30 +0000 | [diff] [blame] | 460 | _mm256_extract_epi8(__m256i __a, const int __imm) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 461 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 462 | __v32qi __b = (__v32qi)__a; |
Manman Ren | c94122e | 2013-10-23 20:33:14 +0000 | [diff] [blame] | 463 | return __b[__imm & 31]; |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 464 | } |
| 465 | |
| 466 | #ifdef __x86_64__ |
| 467 | static __inline long long __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 468 | _mm256_extract_epi64(__m256i __a, const int __imm) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 469 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 470 | __v4di __b = (__v4di)__a; |
Manman Ren | c94122e | 2013-10-23 20:33:14 +0000 | [diff] [blame] | 471 | return __b[__imm & 3]; |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 472 | } |
| 473 | #endif |
| 474 | |
| 475 | /* Vector insert */ |
Chad Rosier | 33d22d8 | 2011-12-16 21:40:31 +0000 | [diff] [blame] | 476 | #define _mm256_insertf128_pd(V1, V2, O) __extension__ ({ \ |
| 477 | __m256d __V1 = (V1); \ |
| 478 | __m128d __V2 = (V2); \ |
Craig Topper | 9f00948 | 2011-12-24 07:55:14 +0000 | [diff] [blame] | 479 | (__m256d)__builtin_ia32_vinsertf128_pd256((__v4df)__V1, (__v2df)__V2, (O)); }) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 480 | |
Chad Rosier | 33d22d8 | 2011-12-16 21:40:31 +0000 | [diff] [blame] | 481 | #define _mm256_insertf128_ps(V1, V2, O) __extension__ ({ \ |
| 482 | __m256 __V1 = (V1); \ |
| 483 | __m128 __V2 = (V2); \ |
Craig Topper | 9f00948 | 2011-12-24 07:55:14 +0000 | [diff] [blame] | 484 | (__m256)__builtin_ia32_vinsertf128_ps256((__v8sf)__V1, (__v4sf)__V2, (O)); }) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 485 | |
Chad Rosier | 33d22d8 | 2011-12-16 21:40:31 +0000 | [diff] [blame] | 486 | #define _mm256_insertf128_si256(V1, V2, O) __extension__ ({ \ |
| 487 | __m256i __V1 = (V1); \ |
| 488 | __m128i __V2 = (V2); \ |
Craig Topper | 9f00948 | 2011-12-24 07:55:14 +0000 | [diff] [blame] | 489 | (__m256i)__builtin_ia32_vinsertf128_si256((__v8si)__V1, (__v4si)__V2, (O)); }) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 490 | |
| 491 | static __inline __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 492 | _mm256_insert_epi32(__m256i __a, int __b, int const __imm) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 493 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 494 | __v8si __c = (__v8si)__a; |
| 495 | __c[__imm & 7] = __b; |
| 496 | return (__m256i)__c; |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 497 | } |
| 498 | |
| 499 | static __inline __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 500 | _mm256_insert_epi16(__m256i __a, int __b, int const __imm) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 501 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 502 | __v16hi __c = (__v16hi)__a; |
| 503 | __c[__imm & 15] = __b; |
| 504 | return (__m256i)__c; |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 505 | } |
| 506 | |
| 507 | static __inline __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 508 | _mm256_insert_epi8(__m256i __a, int __b, int const __imm) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 509 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 510 | __v32qi __c = (__v32qi)__a; |
| 511 | __c[__imm & 31] = __b; |
| 512 | return (__m256i)__c; |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 513 | } |
| 514 | |
| 515 | #ifdef __x86_64__ |
| 516 | static __inline __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 517 | _mm256_insert_epi64(__m256i __a, int __b, int const __imm) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 518 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 519 | __v4di __c = (__v4di)__a; |
| 520 | __c[__imm & 3] = __b; |
| 521 | return (__m256i)__c; |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 522 | } |
| 523 | #endif |
| 524 | |
| 525 | /* Conversion */ |
| 526 | static __inline __m256d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 527 | _mm256_cvtepi32_pd(__m128i __a) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 528 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 529 | return (__m256d)__builtin_ia32_cvtdq2pd256((__v4si) __a); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 530 | } |
| 531 | |
| 532 | static __inline __m256 __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 533 | _mm256_cvtepi32_ps(__m256i __a) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 534 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 535 | return (__m256)__builtin_ia32_cvtdq2ps256((__v8si) __a); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 536 | } |
| 537 | |
| 538 | static __inline __m128 __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 539 | _mm256_cvtpd_ps(__m256d __a) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 540 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 541 | return (__m128)__builtin_ia32_cvtpd2ps256((__v4df) __a); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 542 | } |
| 543 | |
| 544 | static __inline __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 545 | _mm256_cvtps_epi32(__m256 __a) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 546 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 547 | return (__m256i)__builtin_ia32_cvtps2dq256((__v8sf) __a); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 548 | } |
| 549 | |
| 550 | static __inline __m256d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 551 | _mm256_cvtps_pd(__m128 __a) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 552 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 553 | return (__m256d)__builtin_ia32_cvtps2pd256((__v4sf) __a); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 554 | } |
| 555 | |
| 556 | static __inline __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 557 | _mm256_cvttpd_epi32(__m256d __a) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 558 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 559 | return (__m128i)__builtin_ia32_cvttpd2dq256((__v4df) __a); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 560 | } |
| 561 | |
| 562 | static __inline __m128i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 563 | _mm256_cvtpd_epi32(__m256d __a) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 564 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 565 | return (__m128i)__builtin_ia32_cvtpd2dq256((__v4df) __a); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 566 | } |
| 567 | |
| 568 | static __inline __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 569 | _mm256_cvttps_epi32(__m256 __a) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 570 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 571 | return (__m256i)__builtin_ia32_cvttps2dq256((__v8sf) __a); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 572 | } |
| 573 | |
| 574 | /* Vector replicate */ |
| 575 | static __inline __m256 __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 576 | _mm256_movehdup_ps(__m256 __a) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 577 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 578 | return __builtin_shufflevector(__a, __a, 1, 1, 3, 3, 5, 5, 7, 7); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 579 | } |
| 580 | |
| 581 | static __inline __m256 __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 582 | _mm256_moveldup_ps(__m256 __a) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 583 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 584 | return __builtin_shufflevector(__a, __a, 0, 0, 2, 2, 4, 4, 6, 6); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 585 | } |
| 586 | |
| 587 | static __inline __m256d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 588 | _mm256_movedup_pd(__m256d __a) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 589 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 590 | return __builtin_shufflevector(__a, __a, 0, 0, 2, 2); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 591 | } |
| 592 | |
| 593 | /* Unpack and Interleave */ |
| 594 | static __inline __m256d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 595 | _mm256_unpackhi_pd(__m256d __a, __m256d __b) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 596 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 597 | return __builtin_shufflevector(__a, __b, 1, 5, 1+2, 5+2); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 598 | } |
| 599 | |
| 600 | static __inline __m256d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 601 | _mm256_unpacklo_pd(__m256d __a, __m256d __b) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 602 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 603 | return __builtin_shufflevector(__a, __b, 0, 4, 0+2, 4+2); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 604 | } |
| 605 | |
| 606 | static __inline __m256 __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 607 | _mm256_unpackhi_ps(__m256 __a, __m256 __b) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 608 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 609 | return __builtin_shufflevector(__a, __b, 2, 10, 2+1, 10+1, 6, 14, 6+1, 14+1); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 610 | } |
| 611 | |
| 612 | static __inline __m256 __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 613 | _mm256_unpacklo_ps(__m256 __a, __m256 __b) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 614 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 615 | return __builtin_shufflevector(__a, __b, 0, 8, 0+1, 8+1, 4, 12, 4+1, 12+1); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 616 | } |
| 617 | |
| 618 | /* Bit Test */ |
| 619 | static __inline int __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 620 | _mm_testz_pd(__m128d __a, __m128d __b) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 621 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 622 | return __builtin_ia32_vtestzpd((__v2df)__a, (__v2df)__b); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 623 | } |
| 624 | |
| 625 | static __inline int __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 626 | _mm_testc_pd(__m128d __a, __m128d __b) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 627 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 628 | return __builtin_ia32_vtestcpd((__v2df)__a, (__v2df)__b); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 629 | } |
| 630 | |
| 631 | static __inline int __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 632 | _mm_testnzc_pd(__m128d __a, __m128d __b) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 633 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 634 | return __builtin_ia32_vtestnzcpd((__v2df)__a, (__v2df)__b); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 635 | } |
| 636 | |
| 637 | static __inline int __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 638 | _mm_testz_ps(__m128 __a, __m128 __b) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 639 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 640 | return __builtin_ia32_vtestzps((__v4sf)__a, (__v4sf)__b); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 641 | } |
| 642 | |
| 643 | static __inline int __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 644 | _mm_testc_ps(__m128 __a, __m128 __b) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 645 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 646 | return __builtin_ia32_vtestcps((__v4sf)__a, (__v4sf)__b); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 647 | } |
| 648 | |
| 649 | static __inline int __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 650 | _mm_testnzc_ps(__m128 __a, __m128 __b) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 651 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 652 | return __builtin_ia32_vtestnzcps((__v4sf)__a, (__v4sf)__b); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 653 | } |
| 654 | |
| 655 | static __inline int __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 656 | _mm256_testz_pd(__m256d __a, __m256d __b) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 657 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 658 | return __builtin_ia32_vtestzpd256((__v4df)__a, (__v4df)__b); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 659 | } |
| 660 | |
| 661 | static __inline int __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 662 | _mm256_testc_pd(__m256d __a, __m256d __b) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 663 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 664 | return __builtin_ia32_vtestcpd256((__v4df)__a, (__v4df)__b); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 665 | } |
| 666 | |
| 667 | static __inline int __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 668 | _mm256_testnzc_pd(__m256d __a, __m256d __b) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 669 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 670 | return __builtin_ia32_vtestnzcpd256((__v4df)__a, (__v4df)__b); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 671 | } |
| 672 | |
| 673 | static __inline int __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 674 | _mm256_testz_ps(__m256 __a, __m256 __b) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 675 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 676 | return __builtin_ia32_vtestzps256((__v8sf)__a, (__v8sf)__b); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 677 | } |
| 678 | |
| 679 | static __inline int __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 680 | _mm256_testc_ps(__m256 __a, __m256 __b) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 681 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 682 | return __builtin_ia32_vtestcps256((__v8sf)__a, (__v8sf)__b); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 683 | } |
| 684 | |
| 685 | static __inline int __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 686 | _mm256_testnzc_ps(__m256 __a, __m256 __b) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 687 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 688 | return __builtin_ia32_vtestnzcps256((__v8sf)__a, (__v8sf)__b); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 689 | } |
| 690 | |
| 691 | static __inline int __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 692 | _mm256_testz_si256(__m256i __a, __m256i __b) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 693 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 694 | return __builtin_ia32_ptestz256((__v4di)__a, (__v4di)__b); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 695 | } |
| 696 | |
| 697 | static __inline int __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 698 | _mm256_testc_si256(__m256i __a, __m256i __b) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 699 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 700 | return __builtin_ia32_ptestc256((__v4di)__a, (__v4di)__b); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 701 | } |
| 702 | |
| 703 | static __inline int __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 704 | _mm256_testnzc_si256(__m256i __a, __m256i __b) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 705 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 706 | return __builtin_ia32_ptestnzc256((__v4di)__a, (__v4di)__b); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 707 | } |
| 708 | |
| 709 | /* Vector extract sign mask */ |
| 710 | static __inline int __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 711 | _mm256_movemask_pd(__m256d __a) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 712 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 713 | return __builtin_ia32_movmskpd256((__v4df)__a); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 714 | } |
| 715 | |
| 716 | static __inline int __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 717 | _mm256_movemask_ps(__m256 __a) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 718 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 719 | return __builtin_ia32_movmskps256((__v8sf)__a); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 720 | } |
| 721 | |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 722 | /* Vector __zero */ |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 723 | static __inline void __attribute__((__always_inline__, __nodebug__)) |
| 724 | _mm256_zeroall(void) |
| 725 | { |
| 726 | __builtin_ia32_vzeroall(); |
| 727 | } |
| 728 | |
| 729 | static __inline void __attribute__((__always_inline__, __nodebug__)) |
| 730 | _mm256_zeroupper(void) |
| 731 | { |
| 732 | __builtin_ia32_vzeroupper(); |
| 733 | } |
| 734 | |
| 735 | /* Vector load with broadcast */ |
| 736 | static __inline __m128 __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 737 | _mm_broadcast_ss(float const *__a) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 738 | { |
Adam Nemet | 286ae08 | 2014-05-29 20:47:29 +0000 | [diff] [blame] | 739 | float __f = *__a; |
| 740 | return (__m128)(__v4sf){ __f, __f, __f, __f }; |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 741 | } |
| 742 | |
| 743 | static __inline __m256d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 744 | _mm256_broadcast_sd(double const *__a) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 745 | { |
Adam Nemet | 286ae08 | 2014-05-29 20:47:29 +0000 | [diff] [blame] | 746 | double __d = *__a; |
| 747 | return (__m256d)(__v4df){ __d, __d, __d, __d }; |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 748 | } |
| 749 | |
| 750 | static __inline __m256 __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 751 | _mm256_broadcast_ss(float const *__a) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 752 | { |
Adam Nemet | 286ae08 | 2014-05-29 20:47:29 +0000 | [diff] [blame] | 753 | float __f = *__a; |
| 754 | return (__m256)(__v8sf){ __f, __f, __f, __f, __f, __f, __f, __f }; |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 755 | } |
| 756 | |
| 757 | static __inline __m256d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 758 | _mm256_broadcast_pd(__m128d const *__a) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 759 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 760 | return (__m256d)__builtin_ia32_vbroadcastf128_pd256(__a); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 761 | } |
| 762 | |
| 763 | static __inline __m256 __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 764 | _mm256_broadcast_ps(__m128 const *__a) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 765 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 766 | return (__m256)__builtin_ia32_vbroadcastf128_ps256(__a); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 767 | } |
| 768 | |
| 769 | /* SIMD load ops */ |
| 770 | static __inline __m256d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 771 | _mm256_load_pd(double const *__p) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 772 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 773 | return *(__m256d *)__p; |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 774 | } |
| 775 | |
| 776 | static __inline __m256 __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 777 | _mm256_load_ps(float const *__p) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 778 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 779 | return *(__m256 *)__p; |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 780 | } |
| 781 | |
| 782 | static __inline __m256d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 783 | _mm256_loadu_pd(double const *__p) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 784 | { |
Craig Topper | 9e9301a | 2012-01-25 04:26:17 +0000 | [diff] [blame] | 785 | struct __loadu_pd { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 786 | __m256d __v; |
Craig Topper | 9e9301a | 2012-01-25 04:26:17 +0000 | [diff] [blame] | 787 | } __attribute__((packed, may_alias)); |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 788 | return ((struct __loadu_pd*)__p)->__v; |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 789 | } |
| 790 | |
| 791 | static __inline __m256 __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 792 | _mm256_loadu_ps(float const *__p) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 793 | { |
Craig Topper | 9e9301a | 2012-01-25 04:26:17 +0000 | [diff] [blame] | 794 | struct __loadu_ps { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 795 | __m256 __v; |
Craig Topper | 9e9301a | 2012-01-25 04:26:17 +0000 | [diff] [blame] | 796 | } __attribute__((packed, may_alias)); |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 797 | return ((struct __loadu_ps*)__p)->__v; |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 798 | } |
| 799 | |
| 800 | static __inline __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 801 | _mm256_load_si256(__m256i const *__p) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 802 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 803 | return *__p; |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 804 | } |
| 805 | |
| 806 | static __inline __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 807 | _mm256_loadu_si256(__m256i const *__p) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 808 | { |
Craig Topper | 9e9301a | 2012-01-25 04:26:17 +0000 | [diff] [blame] | 809 | struct __loadu_si256 { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 810 | __m256i __v; |
Craig Topper | 9e9301a | 2012-01-25 04:26:17 +0000 | [diff] [blame] | 811 | } __attribute__((packed, may_alias)); |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 812 | return ((struct __loadu_si256*)__p)->__v; |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 813 | } |
| 814 | |
| 815 | static __inline __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 816 | _mm256_lddqu_si256(__m256i const *__p) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 817 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 818 | return (__m256i)__builtin_ia32_lddqu256((char const *)__p); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 819 | } |
| 820 | |
| 821 | /* SIMD store ops */ |
| 822 | static __inline void __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 823 | _mm256_store_pd(double *__p, __m256d __a) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 824 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 825 | *(__m256d *)__p = __a; |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 826 | } |
| 827 | |
| 828 | static __inline void __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 829 | _mm256_store_ps(float *__p, __m256 __a) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 830 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 831 | *(__m256 *)__p = __a; |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 832 | } |
| 833 | |
| 834 | static __inline void __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 835 | _mm256_storeu_pd(double *__p, __m256d __a) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 836 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 837 | __builtin_ia32_storeupd256(__p, (__v4df)__a); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 838 | } |
| 839 | |
| 840 | static __inline void __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 841 | _mm256_storeu_ps(float *__p, __m256 __a) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 842 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 843 | __builtin_ia32_storeups256(__p, (__v8sf)__a); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 844 | } |
| 845 | |
| 846 | static __inline void __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 847 | _mm256_store_si256(__m256i *__p, __m256i __a) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 848 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 849 | *__p = __a; |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 850 | } |
| 851 | |
| 852 | static __inline void __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 853 | _mm256_storeu_si256(__m256i *__p, __m256i __a) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 854 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 855 | __builtin_ia32_storedqu256((char *)__p, (__v32qi)__a); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 856 | } |
| 857 | |
| 858 | /* Conditional load ops */ |
| 859 | static __inline __m128d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 860 | _mm_maskload_pd(double const *__p, __m128d __m) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 861 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 862 | return (__m128d)__builtin_ia32_maskloadpd((const __v2df *)__p, (__v2df)__m); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 863 | } |
| 864 | |
| 865 | static __inline __m256d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 866 | _mm256_maskload_pd(double const *__p, __m256d __m) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 867 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 868 | return (__m256d)__builtin_ia32_maskloadpd256((const __v4df *)__p, |
| 869 | (__v4df)__m); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 870 | } |
| 871 | |
| 872 | static __inline __m128 __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 873 | _mm_maskload_ps(float const *__p, __m128 __m) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 874 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 875 | return (__m128)__builtin_ia32_maskloadps((const __v4sf *)__p, (__v4sf)__m); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 876 | } |
| 877 | |
| 878 | static __inline __m256 __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 879 | _mm256_maskload_ps(float const *__p, __m256 __m) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 880 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 881 | return (__m256)__builtin_ia32_maskloadps256((const __v8sf *)__p, (__v8sf)__m); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 882 | } |
| 883 | |
| 884 | /* Conditional store ops */ |
| 885 | static __inline void __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 886 | _mm256_maskstore_ps(float *__p, __m256 __m, __m256 __a) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 887 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 888 | __builtin_ia32_maskstoreps256((__v8sf *)__p, (__v8sf)__m, (__v8sf)__a); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 889 | } |
| 890 | |
| 891 | static __inline void __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 892 | _mm_maskstore_pd(double *__p, __m128d __m, __m128d __a) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 893 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 894 | __builtin_ia32_maskstorepd((__v2df *)__p, (__v2df)__m, (__v2df)__a); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 895 | } |
| 896 | |
| 897 | static __inline void __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 898 | _mm256_maskstore_pd(double *__p, __m256d __m, __m256d __a) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 899 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 900 | __builtin_ia32_maskstorepd256((__v4df *)__p, (__v4df)__m, (__v4df)__a); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 901 | } |
| 902 | |
| 903 | static __inline void __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 904 | _mm_maskstore_ps(float *__p, __m128 __m, __m128 __a) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 905 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 906 | __builtin_ia32_maskstoreps((__v4sf *)__p, (__v4sf)__m, (__v4sf)__a); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 907 | } |
| 908 | |
| 909 | /* Cacheability support ops */ |
| 910 | static __inline void __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 911 | _mm256_stream_si256(__m256i *__a, __m256i __b) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 912 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 913 | __builtin_ia32_movntdq256((__v4di *)__a, (__v4di)__b); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 914 | } |
| 915 | |
| 916 | static __inline void __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 917 | _mm256_stream_pd(double *__a, __m256d __b) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 918 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 919 | __builtin_ia32_movntpd256(__a, (__v4df)__b); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 920 | } |
| 921 | |
| 922 | static __inline void __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 923 | _mm256_stream_ps(float *__p, __m256 __a) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 924 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 925 | __builtin_ia32_movntps256(__p, (__v8sf)__a); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 926 | } |
| 927 | |
| 928 | /* Create vectors */ |
| 929 | static __inline __m256d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 930 | _mm256_set_pd(double __a, double __b, double __c, double __d) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 931 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 932 | return (__m256d){ __d, __c, __b, __a }; |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 933 | } |
| 934 | |
| 935 | static __inline __m256 __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 936 | _mm256_set_ps(float __a, float __b, float __c, float __d, |
Craig Topper | 9fee8ab | 2015-01-31 06:33:59 +0000 | [diff] [blame^] | 937 | float __e, float __f, float __g, float __h) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 938 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 939 | return (__m256){ __h, __g, __f, __e, __d, __c, __b, __a }; |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 940 | } |
| 941 | |
| 942 | static __inline __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 943 | _mm256_set_epi32(int __i0, int __i1, int __i2, int __i3, |
Craig Topper | 9fee8ab | 2015-01-31 06:33:59 +0000 | [diff] [blame^] | 944 | int __i4, int __i5, int __i6, int __i7) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 945 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 946 | return (__m256i)(__v8si){ __i7, __i6, __i5, __i4, __i3, __i2, __i1, __i0 }; |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 947 | } |
| 948 | |
| 949 | static __inline __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 950 | _mm256_set_epi16(short __w15, short __w14, short __w13, short __w12, |
Craig Topper | 9fee8ab | 2015-01-31 06:33:59 +0000 | [diff] [blame^] | 951 | short __w11, short __w10, short __w09, short __w08, |
| 952 | short __w07, short __w06, short __w05, short __w04, |
| 953 | short __w03, short __w02, short __w01, short __w00) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 954 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 955 | return (__m256i)(__v16hi){ __w00, __w01, __w02, __w03, __w04, __w05, __w06, |
| 956 | __w07, __w08, __w09, __w10, __w11, __w12, __w13, __w14, __w15 }; |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 957 | } |
| 958 | |
| 959 | static __inline __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 960 | _mm256_set_epi8(char __b31, char __b30, char __b29, char __b28, |
Craig Topper | 9fee8ab | 2015-01-31 06:33:59 +0000 | [diff] [blame^] | 961 | char __b27, char __b26, char __b25, char __b24, |
| 962 | char __b23, char __b22, char __b21, char __b20, |
| 963 | char __b19, char __b18, char __b17, char __b16, |
| 964 | char __b15, char __b14, char __b13, char __b12, |
| 965 | char __b11, char __b10, char __b09, char __b08, |
| 966 | char __b07, char __b06, char __b05, char __b04, |
| 967 | char __b03, char __b02, char __b01, char __b00) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 968 | { |
| 969 | return (__m256i)(__v32qi){ |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 970 | __b00, __b01, __b02, __b03, __b04, __b05, __b06, __b07, |
| 971 | __b08, __b09, __b10, __b11, __b12, __b13, __b14, __b15, |
| 972 | __b16, __b17, __b18, __b19, __b20, __b21, __b22, __b23, |
| 973 | __b24, __b25, __b26, __b27, __b28, __b29, __b30, __b31 |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 974 | }; |
| 975 | } |
| 976 | |
| 977 | static __inline __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 978 | _mm256_set_epi64x(long long __a, long long __b, long long __c, long long __d) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 979 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 980 | return (__m256i)(__v4di){ __d, __c, __b, __a }; |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 981 | } |
| 982 | |
| 983 | /* Create vectors with elements in reverse order */ |
| 984 | static __inline __m256d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 985 | _mm256_setr_pd(double __a, double __b, double __c, double __d) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 986 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 987 | return (__m256d){ __a, __b, __c, __d }; |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 988 | } |
| 989 | |
| 990 | static __inline __m256 __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 991 | _mm256_setr_ps(float __a, float __b, float __c, float __d, |
Craig Topper | 9fee8ab | 2015-01-31 06:33:59 +0000 | [diff] [blame^] | 992 | float __e, float __f, float __g, float __h) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 993 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 994 | return (__m256){ __a, __b, __c, __d, __e, __f, __g, __h }; |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 995 | } |
| 996 | |
| 997 | static __inline __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 998 | _mm256_setr_epi32(int __i0, int __i1, int __i2, int __i3, |
Craig Topper | 9fee8ab | 2015-01-31 06:33:59 +0000 | [diff] [blame^] | 999 | int __i4, int __i5, int __i6, int __i7) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 1000 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1001 | return (__m256i)(__v8si){ __i0, __i1, __i2, __i3, __i4, __i5, __i6, __i7 }; |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 1002 | } |
| 1003 | |
| 1004 | static __inline __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1005 | _mm256_setr_epi16(short __w15, short __w14, short __w13, short __w12, |
Craig Topper | 9fee8ab | 2015-01-31 06:33:59 +0000 | [diff] [blame^] | 1006 | short __w11, short __w10, short __w09, short __w08, |
| 1007 | short __w07, short __w06, short __w05, short __w04, |
| 1008 | short __w03, short __w02, short __w01, short __w00) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 1009 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1010 | return (__m256i)(__v16hi){ __w15, __w14, __w13, __w12, __w11, __w10, __w09, |
| 1011 | __w08, __w07, __w06, __w05, __w04, __w03, __w02, __w01, __w00 }; |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 1012 | } |
| 1013 | |
| 1014 | static __inline __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1015 | _mm256_setr_epi8(char __b31, char __b30, char __b29, char __b28, |
Craig Topper | 9fee8ab | 2015-01-31 06:33:59 +0000 | [diff] [blame^] | 1016 | char __b27, char __b26, char __b25, char __b24, |
| 1017 | char __b23, char __b22, char __b21, char __b20, |
| 1018 | char __b19, char __b18, char __b17, char __b16, |
| 1019 | char __b15, char __b14, char __b13, char __b12, |
| 1020 | char __b11, char __b10, char __b09, char __b08, |
| 1021 | char __b07, char __b06, char __b05, char __b04, |
| 1022 | char __b03, char __b02, char __b01, char __b00) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 1023 | { |
| 1024 | return (__m256i)(__v32qi){ |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1025 | __b31, __b30, __b29, __b28, __b27, __b26, __b25, __b24, |
Craig Topper | 9fee8ab | 2015-01-31 06:33:59 +0000 | [diff] [blame^] | 1026 | __b23, __b22, __b21, __b20, __b19, __b18, __b17, __b16, |
| 1027 | __b15, __b14, __b13, __b12, __b11, __b10, __b09, __b08, |
| 1028 | __b07, __b06, __b05, __b04, __b03, __b02, __b01, __b00 }; |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 1029 | } |
| 1030 | |
| 1031 | static __inline __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1032 | _mm256_setr_epi64x(long long __a, long long __b, long long __c, long long __d) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 1033 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1034 | return (__m256i)(__v4di){ __a, __b, __c, __d }; |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 1035 | } |
| 1036 | |
| 1037 | /* Create vectors with repeated elements */ |
| 1038 | static __inline __m256d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1039 | _mm256_set1_pd(double __w) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 1040 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1041 | return (__m256d){ __w, __w, __w, __w }; |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 1042 | } |
| 1043 | |
| 1044 | static __inline __m256 __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1045 | _mm256_set1_ps(float __w) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 1046 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1047 | return (__m256){ __w, __w, __w, __w, __w, __w, __w, __w }; |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 1048 | } |
| 1049 | |
| 1050 | static __inline __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1051 | _mm256_set1_epi32(int __i) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 1052 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1053 | return (__m256i)(__v8si){ __i, __i, __i, __i, __i, __i, __i, __i }; |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 1054 | } |
| 1055 | |
| 1056 | static __inline __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1057 | _mm256_set1_epi16(short __w) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 1058 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1059 | return (__m256i)(__v16hi){ __w, __w, __w, __w, __w, __w, __w, __w, __w, __w, |
| 1060 | __w, __w, __w, __w, __w, __w }; |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 1061 | } |
| 1062 | |
| 1063 | static __inline __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1064 | _mm256_set1_epi8(char __b) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 1065 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1066 | return (__m256i)(__v32qi){ __b, __b, __b, __b, __b, __b, __b, __b, __b, __b, |
| 1067 | __b, __b, __b, __b, __b, __b, __b, __b, __b, __b, __b, __b, __b, __b, __b, |
| 1068 | __b, __b, __b, __b, __b, __b, __b }; |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 1069 | } |
| 1070 | |
| 1071 | static __inline __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1072 | _mm256_set1_epi64x(long long __q) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 1073 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1074 | return (__m256i)(__v4di){ __q, __q, __q, __q }; |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 1075 | } |
| 1076 | |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1077 | /* Create __zeroed vectors */ |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 1078 | static __inline __m256d __attribute__((__always_inline__, __nodebug__)) |
| 1079 | _mm256_setzero_pd(void) |
| 1080 | { |
| 1081 | return (__m256d){ 0, 0, 0, 0 }; |
| 1082 | } |
| 1083 | |
| 1084 | static __inline __m256 __attribute__((__always_inline__, __nodebug__)) |
| 1085 | _mm256_setzero_ps(void) |
| 1086 | { |
| 1087 | return (__m256){ 0, 0, 0, 0, 0, 0, 0, 0 }; |
| 1088 | } |
| 1089 | |
| 1090 | static __inline __m256i __attribute__((__always_inline__, __nodebug__)) |
| 1091 | _mm256_setzero_si256(void) |
| 1092 | { |
| 1093 | return (__m256i){ 0LL, 0LL, 0LL, 0LL }; |
| 1094 | } |
| 1095 | |
| 1096 | /* Cast between vector types */ |
| 1097 | static __inline __m256 __attribute__((__always_inline__, __nodebug__)) |
Reid Kleckner | 7ab75b3 | 2013-04-19 17:00:14 +0000 | [diff] [blame] | 1098 | _mm256_castpd_ps(__m256d __a) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 1099 | { |
Reid Kleckner | 7ab75b3 | 2013-04-19 17:00:14 +0000 | [diff] [blame] | 1100 | return (__m256)__a; |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 1101 | } |
| 1102 | |
| 1103 | static __inline __m256i __attribute__((__always_inline__, __nodebug__)) |
Reid Kleckner | 7ab75b3 | 2013-04-19 17:00:14 +0000 | [diff] [blame] | 1104 | _mm256_castpd_si256(__m256d __a) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 1105 | { |
Reid Kleckner | 7ab75b3 | 2013-04-19 17:00:14 +0000 | [diff] [blame] | 1106 | return (__m256i)__a; |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 1107 | } |
| 1108 | |
| 1109 | static __inline __m256d __attribute__((__always_inline__, __nodebug__)) |
Reid Kleckner | 7ab75b3 | 2013-04-19 17:00:14 +0000 | [diff] [blame] | 1110 | _mm256_castps_pd(__m256 __a) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 1111 | { |
Reid Kleckner | 7ab75b3 | 2013-04-19 17:00:14 +0000 | [diff] [blame] | 1112 | return (__m256d)__a; |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 1113 | } |
| 1114 | |
| 1115 | static __inline __m256i __attribute__((__always_inline__, __nodebug__)) |
Reid Kleckner | 7ab75b3 | 2013-04-19 17:00:14 +0000 | [diff] [blame] | 1116 | _mm256_castps_si256(__m256 __a) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 1117 | { |
Reid Kleckner | 7ab75b3 | 2013-04-19 17:00:14 +0000 | [diff] [blame] | 1118 | return (__m256i)__a; |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 1119 | } |
| 1120 | |
| 1121 | static __inline __m256 __attribute__((__always_inline__, __nodebug__)) |
Reid Kleckner | 7ab75b3 | 2013-04-19 17:00:14 +0000 | [diff] [blame] | 1122 | _mm256_castsi256_ps(__m256i __a) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 1123 | { |
Reid Kleckner | 7ab75b3 | 2013-04-19 17:00:14 +0000 | [diff] [blame] | 1124 | return (__m256)__a; |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 1125 | } |
| 1126 | |
| 1127 | static __inline __m256d __attribute__((__always_inline__, __nodebug__)) |
Reid Kleckner | 7ab75b3 | 2013-04-19 17:00:14 +0000 | [diff] [blame] | 1128 | _mm256_castsi256_pd(__m256i __a) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 1129 | { |
Reid Kleckner | 7ab75b3 | 2013-04-19 17:00:14 +0000 | [diff] [blame] | 1130 | return (__m256d)__a; |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 1131 | } |
| 1132 | |
| 1133 | static __inline __m128d __attribute__((__always_inline__, __nodebug__)) |
Reid Kleckner | 7ab75b3 | 2013-04-19 17:00:14 +0000 | [diff] [blame] | 1134 | _mm256_castpd256_pd128(__m256d __a) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 1135 | { |
Reid Kleckner | 7ab75b3 | 2013-04-19 17:00:14 +0000 | [diff] [blame] | 1136 | return __builtin_shufflevector(__a, __a, 0, 1); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 1137 | } |
| 1138 | |
| 1139 | static __inline __m128 __attribute__((__always_inline__, __nodebug__)) |
Reid Kleckner | 7ab75b3 | 2013-04-19 17:00:14 +0000 | [diff] [blame] | 1140 | _mm256_castps256_ps128(__m256 __a) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 1141 | { |
Reid Kleckner | 7ab75b3 | 2013-04-19 17:00:14 +0000 | [diff] [blame] | 1142 | return __builtin_shufflevector(__a, __a, 0, 1, 2, 3); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 1143 | } |
| 1144 | |
| 1145 | static __inline __m128i __attribute__((__always_inline__, __nodebug__)) |
Reid Kleckner | 7ab75b3 | 2013-04-19 17:00:14 +0000 | [diff] [blame] | 1146 | _mm256_castsi256_si128(__m256i __a) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 1147 | { |
Reid Kleckner | 7ab75b3 | 2013-04-19 17:00:14 +0000 | [diff] [blame] | 1148 | return __builtin_shufflevector(__a, __a, 0, 1); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 1149 | } |
| 1150 | |
| 1151 | static __inline __m256d __attribute__((__always_inline__, __nodebug__)) |
Reid Kleckner | 7ab75b3 | 2013-04-19 17:00:14 +0000 | [diff] [blame] | 1152 | _mm256_castpd128_pd256(__m128d __a) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 1153 | { |
Craig Topper | c524451 | 2013-08-05 06:17:21 +0000 | [diff] [blame] | 1154 | return __builtin_shufflevector(__a, __a, 0, 1, -1, -1); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 1155 | } |
| 1156 | |
| 1157 | static __inline __m256 __attribute__((__always_inline__, __nodebug__)) |
Reid Kleckner | 7ab75b3 | 2013-04-19 17:00:14 +0000 | [diff] [blame] | 1158 | _mm256_castps128_ps256(__m128 __a) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 1159 | { |
Craig Topper | c524451 | 2013-08-05 06:17:21 +0000 | [diff] [blame] | 1160 | return __builtin_shufflevector(__a, __a, 0, 1, 2, 3, -1, -1, -1, -1); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 1161 | } |
| 1162 | |
| 1163 | static __inline __m256i __attribute__((__always_inline__, __nodebug__)) |
Reid Kleckner | 7ab75b3 | 2013-04-19 17:00:14 +0000 | [diff] [blame] | 1164 | _mm256_castsi128_si256(__m128i __a) |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 1165 | { |
Craig Topper | c524451 | 2013-08-05 06:17:21 +0000 | [diff] [blame] | 1166 | return __builtin_shufflevector(__a, __a, 0, 1, -1, -1); |
Bruno Cardoso Lopes | 7c4b513 | 2010-08-04 22:03:36 +0000 | [diff] [blame] | 1167 | } |
Chad Rosier | f8df4f4 | 2012-03-20 16:40:00 +0000 | [diff] [blame] | 1168 | |
| 1169 | /* SIMD load ops (unaligned) */ |
| 1170 | static __inline __m256 __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1171 | _mm256_loadu2_m128(float const *__addr_hi, float const *__addr_lo) |
Chad Rosier | f8df4f4 | 2012-03-20 16:40:00 +0000 | [diff] [blame] | 1172 | { |
| 1173 | struct __loadu_ps { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1174 | __m128 __v; |
Chad Rosier | f8df4f4 | 2012-03-20 16:40:00 +0000 | [diff] [blame] | 1175 | } __attribute__((__packed__, __may_alias__)); |
| 1176 | |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1177 | __m256 __v256 = _mm256_castps128_ps256(((struct __loadu_ps*)__addr_lo)->__v); |
| 1178 | return _mm256_insertf128_ps(__v256, ((struct __loadu_ps*)__addr_hi)->__v, 1); |
Chad Rosier | f8df4f4 | 2012-03-20 16:40:00 +0000 | [diff] [blame] | 1179 | } |
| 1180 | |
| 1181 | static __inline __m256d __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1182 | _mm256_loadu2_m128d(double const *__addr_hi, double const *__addr_lo) |
Chad Rosier | f8df4f4 | 2012-03-20 16:40:00 +0000 | [diff] [blame] | 1183 | { |
| 1184 | struct __loadu_pd { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1185 | __m128d __v; |
Chad Rosier | f8df4f4 | 2012-03-20 16:40:00 +0000 | [diff] [blame] | 1186 | } __attribute__((__packed__, __may_alias__)); |
| 1187 | |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1188 | __m256d __v256 = _mm256_castpd128_pd256(((struct __loadu_pd*)__addr_lo)->__v); |
| 1189 | return _mm256_insertf128_pd(__v256, ((struct __loadu_pd*)__addr_hi)->__v, 1); |
Chad Rosier | f8df4f4 | 2012-03-20 16:40:00 +0000 | [diff] [blame] | 1190 | } |
| 1191 | |
| 1192 | static __inline __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1193 | _mm256_loadu2_m128i(__m128i const *__addr_hi, __m128i const *__addr_lo) |
Chad Rosier | f8df4f4 | 2012-03-20 16:40:00 +0000 | [diff] [blame] | 1194 | { |
| 1195 | struct __loadu_si128 { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1196 | __m128i __v; |
Chad Rosier | f8df4f4 | 2012-03-20 16:40:00 +0000 | [diff] [blame] | 1197 | } __attribute__((packed, may_alias)); |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1198 | __m256i __v256 = _mm256_castsi128_si256( |
| 1199 | ((struct __loadu_si128*)__addr_lo)->__v); |
| 1200 | return _mm256_insertf128_si256(__v256, |
| 1201 | ((struct __loadu_si128*)__addr_hi)->__v, 1); |
Chad Rosier | f8df4f4 | 2012-03-20 16:40:00 +0000 | [diff] [blame] | 1202 | } |
| 1203 | |
| 1204 | /* SIMD store ops (unaligned) */ |
| 1205 | static __inline void __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1206 | _mm256_storeu2_m128(float *__addr_hi, float *__addr_lo, __m256 __a) |
Chad Rosier | f8df4f4 | 2012-03-20 16:40:00 +0000 | [diff] [blame] | 1207 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1208 | __m128 __v128; |
Chad Rosier | f8df4f4 | 2012-03-20 16:40:00 +0000 | [diff] [blame] | 1209 | |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1210 | __v128 = _mm256_castps256_ps128(__a); |
| 1211 | __builtin_ia32_storeups(__addr_lo, __v128); |
| 1212 | __v128 = _mm256_extractf128_ps(__a, 1); |
| 1213 | __builtin_ia32_storeups(__addr_hi, __v128); |
Chad Rosier | f8df4f4 | 2012-03-20 16:40:00 +0000 | [diff] [blame] | 1214 | } |
| 1215 | |
| 1216 | static __inline void __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1217 | _mm256_storeu2_m128d(double *__addr_hi, double *__addr_lo, __m256d __a) |
Chad Rosier | f8df4f4 | 2012-03-20 16:40:00 +0000 | [diff] [blame] | 1218 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1219 | __m128d __v128; |
Chad Rosier | f8df4f4 | 2012-03-20 16:40:00 +0000 | [diff] [blame] | 1220 | |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1221 | __v128 = _mm256_castpd256_pd128(__a); |
| 1222 | __builtin_ia32_storeupd(__addr_lo, __v128); |
| 1223 | __v128 = _mm256_extractf128_pd(__a, 1); |
| 1224 | __builtin_ia32_storeupd(__addr_hi, __v128); |
Chad Rosier | f8df4f4 | 2012-03-20 16:40:00 +0000 | [diff] [blame] | 1225 | } |
| 1226 | |
| 1227 | static __inline void __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1228 | _mm256_storeu2_m128i(__m128i *__addr_hi, __m128i *__addr_lo, __m256i __a) |
Chad Rosier | f8df4f4 | 2012-03-20 16:40:00 +0000 | [diff] [blame] | 1229 | { |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1230 | __m128i __v128; |
Chad Rosier | f8df4f4 | 2012-03-20 16:40:00 +0000 | [diff] [blame] | 1231 | |
David Blaikie | 3302f2b | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 1232 | __v128 = _mm256_castsi256_si128(__a); |
| 1233 | __builtin_ia32_storedqu((char *)__addr_lo, (__v16qi)__v128); |
| 1234 | __v128 = _mm256_extractf128_si256(__a, 1); |
| 1235 | __builtin_ia32_storedqu((char *)__addr_hi, (__v16qi)__v128); |
Chad Rosier | f8df4f4 | 2012-03-20 16:40:00 +0000 | [diff] [blame] | 1236 | } |
Richard Smith | 49e5644 | 2013-07-14 05:41:45 +0000 | [diff] [blame] | 1237 | |
| 1238 | #endif /* __AVXINTRIN_H */ |