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