Craig Topper | 925be54 | 2011-12-19 05:04:33 +0000 | [diff] [blame] | 1 | /*===---- avx2intrin.h - AVX2 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 <avx2intrin.h> directly; include <immintrin.h> instead." |
| 26 | #endif |
| 27 | |
| 28 | /* SSE4 Multiple Packed Sums of Absolute Difference. */ |
| 29 | #define _mm256_mpsadbw_epu8(X, Y, M) __builtin_ia32_mpsadbw256((X), (Y), (M)) |
| 30 | |
| 31 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 32 | _mm256_abs_epi8(__m256i __a) |
Craig Topper | 925be54 | 2011-12-19 05:04:33 +0000 | [diff] [blame] | 33 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 34 | return (__m256i)__builtin_ia32_pabsb256((__v32qi)__a); |
Craig Topper | 925be54 | 2011-12-19 05:04:33 +0000 | [diff] [blame] | 35 | } |
| 36 | |
| 37 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 38 | _mm256_abs_epi16(__m256i __a) |
Craig Topper | 925be54 | 2011-12-19 05:04:33 +0000 | [diff] [blame] | 39 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 40 | return (__m256i)__builtin_ia32_pabsw256((__v16hi)__a); |
Craig Topper | 925be54 | 2011-12-19 05:04:33 +0000 | [diff] [blame] | 41 | } |
| 42 | |
| 43 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 44 | _mm256_abs_epi32(__m256i __a) |
Craig Topper | 925be54 | 2011-12-19 05:04:33 +0000 | [diff] [blame] | 45 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 46 | return (__m256i)__builtin_ia32_pabsd256((__v8si)__a); |
Craig Topper | 925be54 | 2011-12-19 05:04:33 +0000 | [diff] [blame] | 47 | } |
| 48 | |
| 49 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 50 | _mm256_packs_epi16(__m256i __a, __m256i __b) |
Craig Topper | 925be54 | 2011-12-19 05:04:33 +0000 | [diff] [blame] | 51 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 52 | return (__m256i)__builtin_ia32_packsswb256((__v16hi)__a, (__v16hi)__b); |
Craig Topper | 925be54 | 2011-12-19 05:04:33 +0000 | [diff] [blame] | 53 | } |
| 54 | |
| 55 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 56 | _mm256_packs_epi32(__m256i __a, __m256i __b) |
Craig Topper | 925be54 | 2011-12-19 05:04:33 +0000 | [diff] [blame] | 57 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 58 | return (__m256i)__builtin_ia32_packssdw256((__v8si)__a, (__v8si)__b); |
Craig Topper | 925be54 | 2011-12-19 05:04:33 +0000 | [diff] [blame] | 59 | } |
| 60 | |
| 61 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 62 | _mm256_packus_epi16(__m256i __a, __m256i __b) |
Craig Topper | 925be54 | 2011-12-19 05:04:33 +0000 | [diff] [blame] | 63 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 64 | return (__m256i)__builtin_ia32_packuswb256((__v16hi)__a, (__v16hi)__b); |
Craig Topper | 925be54 | 2011-12-19 05:04:33 +0000 | [diff] [blame] | 65 | } |
| 66 | |
| 67 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
| 68 | _mm256_packus_epi32(__m256i __V1, __m256i __V2) |
| 69 | { |
| 70 | return (__m256i) __builtin_ia32_packusdw256((__v8si)__V1, (__v8si)__V2); |
| 71 | } |
| 72 | |
| 73 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 74 | _mm256_add_epi8(__m256i __a, __m256i __b) |
Craig Topper | 925be54 | 2011-12-19 05:04:33 +0000 | [diff] [blame] | 75 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 76 | return (__m256i)((__v32qi)__a + (__v32qi)__b); |
Craig Topper | 925be54 | 2011-12-19 05:04:33 +0000 | [diff] [blame] | 77 | } |
| 78 | |
| 79 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 80 | _mm256_add_epi16(__m256i __a, __m256i __b) |
Craig Topper | 925be54 | 2011-12-19 05:04:33 +0000 | [diff] [blame] | 81 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 82 | return (__m256i)((__v16hi)__a + (__v16hi)__b); |
Craig Topper | 925be54 | 2011-12-19 05:04:33 +0000 | [diff] [blame] | 83 | } |
| 84 | |
| 85 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 86 | _mm256_add_epi32(__m256i __a, __m256i __b) |
Craig Topper | 925be54 | 2011-12-19 05:04:33 +0000 | [diff] [blame] | 87 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 88 | return (__m256i)((__v8si)__a + (__v8si)__b); |
Craig Topper | 925be54 | 2011-12-19 05:04:33 +0000 | [diff] [blame] | 89 | } |
| 90 | |
| 91 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 92 | _mm256_add_epi64(__m256i __a, __m256i __b) |
Craig Topper | 925be54 | 2011-12-19 05:04:33 +0000 | [diff] [blame] | 93 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 94 | return __a + __b; |
Craig Topper | 925be54 | 2011-12-19 05:04:33 +0000 | [diff] [blame] | 95 | } |
| 96 | |
| 97 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 98 | _mm256_adds_epi8(__m256i __a, __m256i __b) |
Craig Topper | 9c2ffd8 | 2011-12-19 07:03:25 +0000 | [diff] [blame] | 99 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 100 | return (__m256i)__builtin_ia32_paddsb256((__v32qi)__a, (__v32qi)__b); |
Craig Topper | 9c2ffd8 | 2011-12-19 07:03:25 +0000 | [diff] [blame] | 101 | } |
| 102 | |
| 103 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 104 | _mm256_adds_epi16(__m256i __a, __m256i __b) |
Craig Topper | 9c2ffd8 | 2011-12-19 07:03:25 +0000 | [diff] [blame] | 105 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 106 | return (__m256i)__builtin_ia32_paddsw256((__v16hi)__a, (__v16hi)__b); |
Craig Topper | 9c2ffd8 | 2011-12-19 07:03:25 +0000 | [diff] [blame] | 107 | } |
| 108 | |
| 109 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 110 | _mm256_adds_epu8(__m256i __a, __m256i __b) |
Craig Topper | 9c2ffd8 | 2011-12-19 07:03:25 +0000 | [diff] [blame] | 111 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 112 | return (__m256i)__builtin_ia32_paddusb256((__v32qi)__a, (__v32qi)__b); |
Craig Topper | 9c2ffd8 | 2011-12-19 07:03:25 +0000 | [diff] [blame] | 113 | } |
| 114 | |
| 115 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 116 | _mm256_adds_epu16(__m256i __a, __m256i __b) |
Craig Topper | 9c2ffd8 | 2011-12-19 07:03:25 +0000 | [diff] [blame] | 117 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 118 | return (__m256i)__builtin_ia32_paddusw256((__v16hi)__a, (__v16hi)__b); |
Craig Topper | 9c2ffd8 | 2011-12-19 07:03:25 +0000 | [diff] [blame] | 119 | } |
| 120 | |
| 121 | #define _mm256_alignr_epi8(a, b, n) __extension__ ({ \ |
| 122 | __m256i __a = (a); \ |
| 123 | __m256i __b = (b); \ |
| 124 | (__m256i)__builtin_ia32_palignr256((__v32qi)__a, (__v32qi)__b, (n)); }) |
| 125 | |
| 126 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 127 | _mm256_and_si256(__m256i __a, __m256i __b) |
Craig Topper | 735ceaa | 2011-12-19 09:03:48 +0000 | [diff] [blame] | 128 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 129 | return __a & __b; |
Craig Topper | 735ceaa | 2011-12-19 09:03:48 +0000 | [diff] [blame] | 130 | } |
| 131 | |
| 132 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 133 | _mm256_andnot_si256(__m256i __a, __m256i __b) |
Craig Topper | 735ceaa | 2011-12-19 09:03:48 +0000 | [diff] [blame] | 134 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 135 | return ~__a & __b; |
Craig Topper | 735ceaa | 2011-12-19 09:03:48 +0000 | [diff] [blame] | 136 | } |
| 137 | |
| 138 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 139 | _mm256_avg_epu8(__m256i __a, __m256i __b) |
Craig Topper | 4c07c5d | 2011-12-20 09:55:26 +0000 | [diff] [blame] | 140 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 141 | return (__m256i)__builtin_ia32_pavgb256((__v32qi)__a, (__v32qi)__b); |
Craig Topper | 4c07c5d | 2011-12-20 09:55:26 +0000 | [diff] [blame] | 142 | } |
| 143 | |
| 144 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 145 | _mm256_avg_epu16(__m256i __a, __m256i __b) |
Craig Topper | 4c07c5d | 2011-12-20 09:55:26 +0000 | [diff] [blame] | 146 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 147 | return (__m256i)__builtin_ia32_pavgw256((__v16hi)__a, (__v16hi)__b); |
Craig Topper | 4c07c5d | 2011-12-20 09:55:26 +0000 | [diff] [blame] | 148 | } |
| 149 | |
| 150 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
| 151 | _mm256_blendv_epi8(__m256i __V1, __m256i __V2, __m256i __M) |
| 152 | { |
| 153 | return (__m256i)__builtin_ia32_pblendvb256((__v32qi)__V1, (__v32qi)__V2, |
| 154 | (__v32qi)__M); |
| 155 | } |
| 156 | |
| 157 | #define _mm256_blend_epi16(V1, V2, M) __extension__ ({ \ |
| 158 | __m256i __V1 = (V1); \ |
| 159 | __m256i __V2 = (V2); \ |
Craig Topper | 5aeaca3 | 2012-03-30 07:01:17 +0000 | [diff] [blame] | 160 | (__m256i)__builtin_ia32_pblendw256((__v16hi)__V1, (__v16hi)__V2, (M)); }) |
Craig Topper | 4c07c5d | 2011-12-20 09:55:26 +0000 | [diff] [blame] | 161 | |
| 162 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 163 | _mm256_cmpeq_epi8(__m256i __a, __m256i __b) |
Craig Topper | 4c07c5d | 2011-12-20 09:55:26 +0000 | [diff] [blame] | 164 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 165 | return (__m256i)((__v32qi)__a == (__v32qi)__b); |
Craig Topper | 4c07c5d | 2011-12-20 09:55:26 +0000 | [diff] [blame] | 166 | } |
| 167 | |
| 168 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 169 | _mm256_cmpeq_epi16(__m256i __a, __m256i __b) |
Craig Topper | 4c07c5d | 2011-12-20 09:55:26 +0000 | [diff] [blame] | 170 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 171 | return (__m256i)((__v16hi)__a == (__v16hi)__b); |
Craig Topper | 4c07c5d | 2011-12-20 09:55:26 +0000 | [diff] [blame] | 172 | } |
| 173 | |
| 174 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 175 | _mm256_cmpeq_epi32(__m256i __a, __m256i __b) |
Craig Topper | 4c07c5d | 2011-12-20 09:55:26 +0000 | [diff] [blame] | 176 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 177 | return (__m256i)((__v8si)__a == (__v8si)__b); |
Craig Topper | 4c07c5d | 2011-12-20 09:55:26 +0000 | [diff] [blame] | 178 | } |
| 179 | |
| 180 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 181 | _mm256_cmpeq_epi64(__m256i __a, __m256i __b) |
Craig Topper | 4c07c5d | 2011-12-20 09:55:26 +0000 | [diff] [blame] | 182 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 183 | return (__m256i)(__a == __b); |
Craig Topper | 4c07c5d | 2011-12-20 09:55:26 +0000 | [diff] [blame] | 184 | } |
| 185 | |
| 186 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 187 | _mm256_cmpgt_epi8(__m256i __a, __m256i __b) |
Craig Topper | 4c07c5d | 2011-12-20 09:55:26 +0000 | [diff] [blame] | 188 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 189 | return (__m256i)((__v32qi)__a > (__v32qi)__b); |
Craig Topper | 4c07c5d | 2011-12-20 09:55:26 +0000 | [diff] [blame] | 190 | } |
| 191 | |
| 192 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 193 | _mm256_cmpgt_epi16(__m256i __a, __m256i __b) |
Craig Topper | 4c07c5d | 2011-12-20 09:55:26 +0000 | [diff] [blame] | 194 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 195 | return (__m256i)((__v16hi)__a > (__v16hi)__b); |
Craig Topper | 4c07c5d | 2011-12-20 09:55:26 +0000 | [diff] [blame] | 196 | } |
| 197 | |
| 198 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 199 | _mm256_cmpgt_epi32(__m256i __a, __m256i __b) |
Craig Topper | 4c07c5d | 2011-12-20 09:55:26 +0000 | [diff] [blame] | 200 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 201 | return (__m256i)((__v8si)__a > (__v8si)__b); |
Craig Topper | 4c07c5d | 2011-12-20 09:55:26 +0000 | [diff] [blame] | 202 | } |
| 203 | |
| 204 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 205 | _mm256_cmpgt_epi64(__m256i __a, __m256i __b) |
Craig Topper | 4c07c5d | 2011-12-20 09:55:26 +0000 | [diff] [blame] | 206 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 207 | return (__m256i)(__a > __b); |
Craig Topper | 4c07c5d | 2011-12-20 09:55:26 +0000 | [diff] [blame] | 208 | } |
| 209 | |
| 210 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 211 | _mm256_hadd_epi16(__m256i __a, __m256i __b) |
Craig Topper | 318e460 | 2011-12-21 08:17:40 +0000 | [diff] [blame] | 212 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 213 | return (__m256i)__builtin_ia32_phaddw256((__v16hi)__a, (__v16hi)__b); |
Craig Topper | 318e460 | 2011-12-21 08:17:40 +0000 | [diff] [blame] | 214 | } |
| 215 | |
| 216 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 217 | _mm256_hadd_epi32(__m256i __a, __m256i __b) |
Craig Topper | 318e460 | 2011-12-21 08:17:40 +0000 | [diff] [blame] | 218 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 219 | return (__m256i)__builtin_ia32_phaddd256((__v8si)__a, (__v8si)__b); |
Craig Topper | 318e460 | 2011-12-21 08:17:40 +0000 | [diff] [blame] | 220 | } |
| 221 | |
| 222 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 223 | _mm256_hadds_epi16(__m256i __a, __m256i __b) |
Craig Topper | 318e460 | 2011-12-21 08:17:40 +0000 | [diff] [blame] | 224 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 225 | return (__m256i)__builtin_ia32_phaddsw256((__v16hi)__a, (__v16hi)__b); |
Craig Topper | 318e460 | 2011-12-21 08:17:40 +0000 | [diff] [blame] | 226 | } |
| 227 | |
| 228 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 229 | _mm256_hsub_epi16(__m256i __a, __m256i __b) |
Craig Topper | 318e460 | 2011-12-21 08:17:40 +0000 | [diff] [blame] | 230 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 231 | return (__m256i)__builtin_ia32_phsubw256((__v16hi)__a, (__v16hi)__b); |
Craig Topper | 318e460 | 2011-12-21 08:17:40 +0000 | [diff] [blame] | 232 | } |
| 233 | |
| 234 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 235 | _mm256_hsub_epi32(__m256i __a, __m256i __b) |
Craig Topper | 318e460 | 2011-12-21 08:17:40 +0000 | [diff] [blame] | 236 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 237 | return (__m256i)__builtin_ia32_phsubd256((__v8si)__a, (__v8si)__b); |
Craig Topper | 318e460 | 2011-12-21 08:17:40 +0000 | [diff] [blame] | 238 | } |
| 239 | |
| 240 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 241 | _mm256_hsubs_epi16(__m256i __a, __m256i __b) |
Craig Topper | 318e460 | 2011-12-21 08:17:40 +0000 | [diff] [blame] | 242 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 243 | return (__m256i)__builtin_ia32_phsubsw256((__v16hi)__a, (__v16hi)__b); |
Craig Topper | 318e460 | 2011-12-21 08:17:40 +0000 | [diff] [blame] | 244 | } |
| 245 | |
| 246 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 247 | _mm256_maddubs_epi16(__m256i __a, __m256i __b) |
Craig Topper | 4a4f25a | 2011-12-21 08:35:05 +0000 | [diff] [blame] | 248 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 249 | return (__m256i)__builtin_ia32_pmaddubsw256((__v32qi)__a, (__v32qi)__b); |
Craig Topper | 4a4f25a | 2011-12-21 08:35:05 +0000 | [diff] [blame] | 250 | } |
| 251 | |
| 252 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 253 | _mm256_madd_epi16(__m256i __a, __m256i __b) |
Craig Topper | 4a4f25a | 2011-12-21 08:35:05 +0000 | [diff] [blame] | 254 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 255 | return (__m256i)__builtin_ia32_pmaddwd256((__v16hi)__a, (__v16hi)__b); |
Craig Topper | 4a4f25a | 2011-12-21 08:35:05 +0000 | [diff] [blame] | 256 | } |
| 257 | |
| 258 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 259 | _mm256_max_epi8(__m256i __a, __m256i __b) |
Craig Topper | 231f793 | 2011-12-22 09:18:58 +0000 | [diff] [blame] | 260 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 261 | return (__m256i)__builtin_ia32_pmaxsb256((__v32qi)__a, (__v32qi)__b); |
Craig Topper | 231f793 | 2011-12-22 09:18:58 +0000 | [diff] [blame] | 262 | } |
| 263 | |
| 264 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 265 | _mm256_max_epi16(__m256i __a, __m256i __b) |
Craig Topper | 231f793 | 2011-12-22 09:18:58 +0000 | [diff] [blame] | 266 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 267 | return (__m256i)__builtin_ia32_pmaxsw256((__v16hi)__a, (__v16hi)__b); |
Craig Topper | 231f793 | 2011-12-22 09:18:58 +0000 | [diff] [blame] | 268 | } |
| 269 | |
| 270 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 271 | _mm256_max_epi32(__m256i __a, __m256i __b) |
Craig Topper | 231f793 | 2011-12-22 09:18:58 +0000 | [diff] [blame] | 272 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 273 | return (__m256i)__builtin_ia32_pmaxsd256((__v8si)__a, (__v8si)__b); |
Craig Topper | 231f793 | 2011-12-22 09:18:58 +0000 | [diff] [blame] | 274 | } |
| 275 | |
| 276 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 277 | _mm256_max_epu8(__m256i __a, __m256i __b) |
Craig Topper | 231f793 | 2011-12-22 09:18:58 +0000 | [diff] [blame] | 278 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 279 | return (__m256i)__builtin_ia32_pmaxub256((__v32qi)__a, (__v32qi)__b); |
Craig Topper | 231f793 | 2011-12-22 09:18:58 +0000 | [diff] [blame] | 280 | } |
| 281 | |
| 282 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 283 | _mm256_max_epu16(__m256i __a, __m256i __b) |
Craig Topper | 231f793 | 2011-12-22 09:18:58 +0000 | [diff] [blame] | 284 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 285 | return (__m256i)__builtin_ia32_pmaxuw256((__v16hi)__a, (__v16hi)__b); |
Craig Topper | 231f793 | 2011-12-22 09:18:58 +0000 | [diff] [blame] | 286 | } |
| 287 | |
| 288 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 289 | _mm256_max_epu32(__m256i __a, __m256i __b) |
Craig Topper | 231f793 | 2011-12-22 09:18:58 +0000 | [diff] [blame] | 290 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 291 | return (__m256i)__builtin_ia32_pmaxud256((__v8si)__a, (__v8si)__b); |
Craig Topper | 231f793 | 2011-12-22 09:18:58 +0000 | [diff] [blame] | 292 | } |
| 293 | |
| 294 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 295 | _mm256_min_epi8(__m256i __a, __m256i __b) |
Craig Topper | 231f793 | 2011-12-22 09:18:58 +0000 | [diff] [blame] | 296 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 297 | return (__m256i)__builtin_ia32_pminsb256((__v32qi)__a, (__v32qi)__b); |
Craig Topper | 231f793 | 2011-12-22 09:18:58 +0000 | [diff] [blame] | 298 | } |
| 299 | |
| 300 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 301 | _mm256_min_epi16(__m256i __a, __m256i __b) |
Craig Topper | 231f793 | 2011-12-22 09:18:58 +0000 | [diff] [blame] | 302 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 303 | return (__m256i)__builtin_ia32_pminsw256((__v16hi)__a, (__v16hi)__b); |
Craig Topper | 231f793 | 2011-12-22 09:18:58 +0000 | [diff] [blame] | 304 | } |
| 305 | |
| 306 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 307 | _mm256_min_epi32(__m256i __a, __m256i __b) |
Craig Topper | 231f793 | 2011-12-22 09:18:58 +0000 | [diff] [blame] | 308 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 309 | return (__m256i)__builtin_ia32_pminsd256((__v8si)__a, (__v8si)__b); |
Craig Topper | 231f793 | 2011-12-22 09:18:58 +0000 | [diff] [blame] | 310 | } |
| 311 | |
| 312 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 313 | _mm256_min_epu8(__m256i __a, __m256i __b) |
Craig Topper | 231f793 | 2011-12-22 09:18:58 +0000 | [diff] [blame] | 314 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 315 | return (__m256i)__builtin_ia32_pminub256((__v32qi)__a, (__v32qi)__b); |
Craig Topper | 231f793 | 2011-12-22 09:18:58 +0000 | [diff] [blame] | 316 | } |
| 317 | |
| 318 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 319 | _mm256_min_epu16(__m256i __a, __m256i __b) |
Craig Topper | 231f793 | 2011-12-22 09:18:58 +0000 | [diff] [blame] | 320 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 321 | return (__m256i)__builtin_ia32_pminuw256 ((__v16hi)__a, (__v16hi)__b); |
Craig Topper | 231f793 | 2011-12-22 09:18:58 +0000 | [diff] [blame] | 322 | } |
| 323 | |
| 324 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 325 | _mm256_min_epu32(__m256i __a, __m256i __b) |
Craig Topper | 231f793 | 2011-12-22 09:18:58 +0000 | [diff] [blame] | 326 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 327 | return (__m256i)__builtin_ia32_pminud256((__v8si)__a, (__v8si)__b); |
Craig Topper | 231f793 | 2011-12-22 09:18:58 +0000 | [diff] [blame] | 328 | } |
| 329 | |
| 330 | static __inline__ int __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 331 | _mm256_movemask_epi8(__m256i __a) |
Craig Topper | 231f793 | 2011-12-22 09:18:58 +0000 | [diff] [blame] | 332 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 333 | return __builtin_ia32_pmovmskb256((__v32qi)__a); |
Craig Topper | 231f793 | 2011-12-22 09:18:58 +0000 | [diff] [blame] | 334 | } |
| 335 | |
| 336 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
| 337 | _mm256_cvtepi8_epi16(__m128i __V) |
| 338 | { |
| 339 | return (__m256i)__builtin_ia32_pmovsxbw256((__v16qi)__V); |
| 340 | } |
| 341 | |
| 342 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
| 343 | _mm256_cvtepi8_epi32(__m128i __V) |
| 344 | { |
| 345 | return (__m256i)__builtin_ia32_pmovsxbd256((__v16qi)__V); |
| 346 | } |
| 347 | |
| 348 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
| 349 | _mm256_cvtepi8_epi64(__m128i __V) |
| 350 | { |
| 351 | return (__m256i)__builtin_ia32_pmovsxbq256((__v16qi)__V); |
| 352 | } |
| 353 | |
| 354 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
| 355 | _mm256_cvtepi16_epi32(__m128i __V) |
| 356 | { |
| 357 | return (__m256i)__builtin_ia32_pmovsxwd256((__v8hi)__V); |
| 358 | } |
| 359 | |
| 360 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
| 361 | _mm256_cvtepi16_epi64(__m128i __V) |
| 362 | { |
| 363 | return (__m256i)__builtin_ia32_pmovsxwq256((__v8hi)__V); |
| 364 | } |
| 365 | |
| 366 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
| 367 | _mm256_cvtepi32_epi64(__m128i __V) |
| 368 | { |
| 369 | return (__m256i)__builtin_ia32_pmovsxdq256((__v4si)__V); |
| 370 | } |
| 371 | |
| 372 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
| 373 | _mm256_cvtepu8_epi16(__m128i __V) |
| 374 | { |
| 375 | return (__m256i)__builtin_ia32_pmovzxbw256((__v16qi)__V); |
| 376 | } |
| 377 | |
| 378 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
| 379 | _mm256_cvtepu8_epi32(__m128i __V) |
| 380 | { |
| 381 | return (__m256i)__builtin_ia32_pmovzxbd256((__v16qi)__V); |
| 382 | } |
| 383 | |
| 384 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
| 385 | _mm256_cvtepu8_epi64(__m128i __V) |
| 386 | { |
| 387 | return (__m256i)__builtin_ia32_pmovzxbq256((__v16qi)__V); |
| 388 | } |
| 389 | |
| 390 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
| 391 | _mm256_cvtepu16_epi32(__m128i __V) |
| 392 | { |
| 393 | return (__m256i)__builtin_ia32_pmovzxwd256((__v8hi)__V); |
| 394 | } |
| 395 | |
| 396 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
| 397 | _mm256_cvtepu16_epi64(__m128i __V) |
| 398 | { |
| 399 | return (__m256i)__builtin_ia32_pmovzxwq256((__v8hi)__V); |
| 400 | } |
| 401 | |
| 402 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
| 403 | _mm256_cvtepu32_epi64(__m128i __V) |
| 404 | { |
| 405 | return (__m256i)__builtin_ia32_pmovzxdq256((__v4si)__V); |
| 406 | } |
| 407 | |
Craig Topper | 28a324a | 2011-12-23 08:31:16 +0000 | [diff] [blame] | 408 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 409 | _mm256_mul_epi32(__m256i __a, __m256i __b) |
Craig Topper | 28a324a | 2011-12-23 08:31:16 +0000 | [diff] [blame] | 410 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 411 | return (__m256i)__builtin_ia32_pmuldq256((__v8si)__a, (__v8si)__b); |
Craig Topper | 28a324a | 2011-12-23 08:31:16 +0000 | [diff] [blame] | 412 | } |
| 413 | |
| 414 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 415 | _mm256_mulhrs_epi16(__m256i __a, __m256i __b) |
Craig Topper | 28a324a | 2011-12-23 08:31:16 +0000 | [diff] [blame] | 416 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 417 | return (__m256i)__builtin_ia32_pmulhrsw256((__v16hi)__a, (__v16hi)__b); |
Craig Topper | 28a324a | 2011-12-23 08:31:16 +0000 | [diff] [blame] | 418 | } |
| 419 | |
| 420 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 421 | _mm256_mulhi_epu16(__m256i __a, __m256i __b) |
Craig Topper | 28a324a | 2011-12-23 08:31:16 +0000 | [diff] [blame] | 422 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 423 | return (__m256i)__builtin_ia32_pmulhuw256((__v16hi)__a, (__v16hi)__b); |
Craig Topper | 28a324a | 2011-12-23 08:31:16 +0000 | [diff] [blame] | 424 | } |
| 425 | |
| 426 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 427 | _mm256_mulhi_epi16(__m256i __a, __m256i __b) |
Craig Topper | 28a324a | 2011-12-23 08:31:16 +0000 | [diff] [blame] | 428 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 429 | return (__m256i)__builtin_ia32_pmulhw256((__v16hi)__a, (__v16hi)__b); |
Craig Topper | 28a324a | 2011-12-23 08:31:16 +0000 | [diff] [blame] | 430 | } |
| 431 | |
| 432 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 433 | _mm256_mullo_epi16(__m256i __a, __m256i __b) |
Craig Topper | 28a324a | 2011-12-23 08:31:16 +0000 | [diff] [blame] | 434 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 435 | return (__m256i)((__v16hi)__a * (__v16hi)__b); |
Craig Topper | 28a324a | 2011-12-23 08:31:16 +0000 | [diff] [blame] | 436 | } |
| 437 | |
| 438 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 439 | _mm256_mullo_epi32 (__m256i __a, __m256i __b) |
Craig Topper | 28a324a | 2011-12-23 08:31:16 +0000 | [diff] [blame] | 440 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 441 | return (__m256i)((__v8si)__a * (__v8si)__b); |
Craig Topper | 28a324a | 2011-12-23 08:31:16 +0000 | [diff] [blame] | 442 | } |
| 443 | |
| 444 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 445 | _mm256_mul_epu32(__m256i __a, __m256i __b) |
Craig Topper | 28a324a | 2011-12-23 08:31:16 +0000 | [diff] [blame] | 446 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 447 | return __builtin_ia32_pmuludq256((__v8si)__a, (__v8si)__b); |
Craig Topper | 28a324a | 2011-12-23 08:31:16 +0000 | [diff] [blame] | 448 | } |
| 449 | |
Craig Topper | 231f793 | 2011-12-22 09:18:58 +0000 | [diff] [blame] | 450 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 451 | _mm256_or_si256(__m256i __a, __m256i __b) |
Craig Topper | 735ceaa | 2011-12-19 09:03:48 +0000 | [diff] [blame] | 452 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 453 | return __a | __b; |
Craig Topper | 735ceaa | 2011-12-19 09:03:48 +0000 | [diff] [blame] | 454 | } |
| 455 | |
| 456 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 457 | _mm256_sad_epu8(__m256i __a, __m256i __b) |
Craig Topper | cbe627b | 2011-12-24 03:28:57 +0000 | [diff] [blame] | 458 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 459 | return __builtin_ia32_psadbw256((__v32qi)__a, (__v32qi)__b); |
Craig Topper | cbe627b | 2011-12-24 03:28:57 +0000 | [diff] [blame] | 460 | } |
| 461 | |
| 462 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 463 | _mm256_shuffle_epi8(__m256i __a, __m256i __b) |
Craig Topper | cbe627b | 2011-12-24 03:28:57 +0000 | [diff] [blame] | 464 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 465 | return (__m256i)__builtin_ia32_pshufb256((__v32qi)__a, (__v32qi)__b); |
Craig Topper | cbe627b | 2011-12-24 03:28:57 +0000 | [diff] [blame] | 466 | } |
| 467 | |
| 468 | #define _mm256_shuffle_epi32(a, imm) __extension__ ({ \ |
| 469 | __m256i __a = (a); \ |
| 470 | (__m256i)__builtin_shufflevector((__v8si)__a, (__v8si)_mm256_set1_epi32(0), \ |
| 471 | (imm) & 0x3, ((imm) & 0xc) >> 2, \ |
| 472 | ((imm) & 0x30) >> 4, ((imm) & 0xc0) >> 6, \ |
| 473 | 4 + (((imm) & 0x03) >> 0), \ |
| 474 | 4 + (((imm) & 0x0c) >> 2), \ |
| 475 | 4 + (((imm) & 0x30) >> 4), \ |
| 476 | 4 + (((imm) & 0xc0) >> 6)); }) |
| 477 | |
| 478 | #define _mm256_shufflehi_epi16(a, imm) __extension__ ({ \ |
| 479 | __m256i __a = (a); \ |
| 480 | (__m256i)__builtin_shufflevector((__v16hi)__a, (__v16hi)_mm256_set1_epi16(0), \ |
| 481 | 0, 1, 2, 3, \ |
| 482 | 4 + (((imm) & 0x03) >> 0), \ |
| 483 | 4 + (((imm) & 0x0c) >> 2), \ |
| 484 | 4 + (((imm) & 0x30) >> 4), \ |
| 485 | 4 + (((imm) & 0xc0) >> 6), \ |
| 486 | 8, 9, 10, 11, \ |
| 487 | 12 + (((imm) & 0x03) >> 0), \ |
| 488 | 12 + (((imm) & 0x0c) >> 2), \ |
| 489 | 12 + (((imm) & 0x30) >> 4), \ |
| 490 | 12 + (((imm) & 0xc0) >> 6)); }) |
| 491 | |
| 492 | #define _mm256_shufflelo_epi16(a, imm) __extension__ ({ \ |
| 493 | __m256i __a = (a); \ |
| 494 | (__m256i)__builtin_shufflevector((__v16hi)__a, (__v16hi)_mm256_set1_epi16(0), \ |
| 495 | (imm) & 0x3,((imm) & 0xc) >> 2, \ |
| 496 | ((imm) & 0x30) >> 4, ((imm) & 0xc0) >> 6, \ |
| 497 | 4, 5, 6, 7, \ |
| 498 | 8 + (((imm) & 0x03) >> 0), \ |
| 499 | 8 + (((imm) & 0x0c) >> 2), \ |
| 500 | 8 + (((imm) & 0x30) >> 4), \ |
| 501 | 8 + (((imm) & 0xc0) >> 6), \ |
| 502 | 12, 13, 14, 15); }) |
| 503 | |
| 504 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 505 | _mm256_sign_epi8(__m256i __a, __m256i __b) |
Craig Topper | cbe627b | 2011-12-24 03:28:57 +0000 | [diff] [blame] | 506 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 507 | return (__m256i)__builtin_ia32_psignb256((__v32qi)__a, (__v32qi)__b); |
Craig Topper | cbe627b | 2011-12-24 03:28:57 +0000 | [diff] [blame] | 508 | } |
| 509 | |
| 510 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 511 | _mm256_sign_epi16(__m256i __a, __m256i __b) |
Craig Topper | cbe627b | 2011-12-24 03:28:57 +0000 | [diff] [blame] | 512 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 513 | return (__m256i)__builtin_ia32_psignw256((__v16hi)__a, (__v16hi)__b); |
Craig Topper | cbe627b | 2011-12-24 03:28:57 +0000 | [diff] [blame] | 514 | } |
| 515 | |
| 516 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 517 | _mm256_sign_epi32(__m256i __a, __m256i __b) |
Craig Topper | cbe627b | 2011-12-24 03:28:57 +0000 | [diff] [blame] | 518 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 519 | return (__m256i)__builtin_ia32_psignd256((__v8si)__a, (__v8si)__b); |
Craig Topper | cbe627b | 2011-12-24 03:28:57 +0000 | [diff] [blame] | 520 | } |
| 521 | |
| 522 | #define _mm256_slli_si256(a, count) __extension__ ({ \ |
| 523 | __m256i __a = (a); \ |
| 524 | (__m256i)__builtin_ia32_pslldqi256(__a, (count)*8); }) |
| 525 | |
| 526 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 527 | _mm256_slli_epi16(__m256i __a, int __count) |
Craig Topper | cbe627b | 2011-12-24 03:28:57 +0000 | [diff] [blame] | 528 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 529 | return (__m256i)__builtin_ia32_psllwi256((__v16hi)__a, __count); |
Craig Topper | cbe627b | 2011-12-24 03:28:57 +0000 | [diff] [blame] | 530 | } |
| 531 | |
| 532 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 533 | _mm256_sll_epi16(__m256i __a, __m128i __count) |
Craig Topper | cbe627b | 2011-12-24 03:28:57 +0000 | [diff] [blame] | 534 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 535 | return (__m256i)__builtin_ia32_psllw256((__v16hi)__a, (__v8hi)__count); |
Craig Topper | cbe627b | 2011-12-24 03:28:57 +0000 | [diff] [blame] | 536 | } |
| 537 | |
| 538 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 539 | _mm256_slli_epi32(__m256i __a, int __count) |
Craig Topper | cbe627b | 2011-12-24 03:28:57 +0000 | [diff] [blame] | 540 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 541 | return (__m256i)__builtin_ia32_pslldi256((__v8si)__a, __count); |
Craig Topper | cbe627b | 2011-12-24 03:28:57 +0000 | [diff] [blame] | 542 | } |
| 543 | |
| 544 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 545 | _mm256_sll_epi32(__m256i __a, __m128i __count) |
Craig Topper | cbe627b | 2011-12-24 03:28:57 +0000 | [diff] [blame] | 546 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 547 | return (__m256i)__builtin_ia32_pslld256((__v8si)__a, (__v4si)__count); |
Craig Topper | cbe627b | 2011-12-24 03:28:57 +0000 | [diff] [blame] | 548 | } |
| 549 | |
| 550 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 551 | _mm256_slli_epi64(__m256i __a, int __count) |
Craig Topper | cbe627b | 2011-12-24 03:28:57 +0000 | [diff] [blame] | 552 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 553 | return __builtin_ia32_psllqi256(__a, __count); |
Craig Topper | cbe627b | 2011-12-24 03:28:57 +0000 | [diff] [blame] | 554 | } |
| 555 | |
| 556 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 557 | _mm256_sll_epi64(__m256i __a, __m128i __count) |
Craig Topper | cbe627b | 2011-12-24 03:28:57 +0000 | [diff] [blame] | 558 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 559 | return __builtin_ia32_psllq256(__a, __count); |
Craig Topper | cbe627b | 2011-12-24 03:28:57 +0000 | [diff] [blame] | 560 | } |
| 561 | |
| 562 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 563 | _mm256_srai_epi16(__m256i __a, int __count) |
Craig Topper | cbe627b | 2011-12-24 03:28:57 +0000 | [diff] [blame] | 564 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 565 | return (__m256i)__builtin_ia32_psrawi256((__v16hi)__a, __count); |
Craig Topper | cbe627b | 2011-12-24 03:28:57 +0000 | [diff] [blame] | 566 | } |
| 567 | |
| 568 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 569 | _mm256_sra_epi16(__m256i __a, __m128i __count) |
Craig Topper | cbe627b | 2011-12-24 03:28:57 +0000 | [diff] [blame] | 570 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 571 | return (__m256i)__builtin_ia32_psraw256((__v16hi)__a, (__v8hi)__count); |
Craig Topper | cbe627b | 2011-12-24 03:28:57 +0000 | [diff] [blame] | 572 | } |
| 573 | |
| 574 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 575 | _mm256_srai_epi32(__m256i __a, int __count) |
Craig Topper | cbe627b | 2011-12-24 03:28:57 +0000 | [diff] [blame] | 576 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 577 | return (__m256i)__builtin_ia32_psradi256((__v8si)__a, __count); |
Craig Topper | cbe627b | 2011-12-24 03:28:57 +0000 | [diff] [blame] | 578 | } |
| 579 | |
| 580 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 581 | _mm256_sra_epi32(__m256i __a, __m128i __count) |
Craig Topper | cbe627b | 2011-12-24 03:28:57 +0000 | [diff] [blame] | 582 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 583 | return (__m256i)__builtin_ia32_psrad256((__v8si)__a, (__v4si)__count); |
Craig Topper | cbe627b | 2011-12-24 03:28:57 +0000 | [diff] [blame] | 584 | } |
| 585 | |
| 586 | #define _mm256_srli_si256(a, count) __extension__ ({ \ |
| 587 | __m256i __a = (a); \ |
| 588 | (__m256i)__builtin_ia32_psrldqi256(__a, (count)*8); }) |
| 589 | |
| 590 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 591 | _mm256_srli_epi16(__m256i __a, int __count) |
Craig Topper | cbe627b | 2011-12-24 03:28:57 +0000 | [diff] [blame] | 592 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 593 | return (__m256i)__builtin_ia32_psrlwi256((__v16hi)__a, __count); |
Craig Topper | cbe627b | 2011-12-24 03:28:57 +0000 | [diff] [blame] | 594 | } |
| 595 | |
| 596 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 597 | _mm256_srl_epi16(__m256i __a, __m128i __count) |
Craig Topper | cbe627b | 2011-12-24 03:28:57 +0000 | [diff] [blame] | 598 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 599 | return (__m256i)__builtin_ia32_psrlw256((__v16hi)__a, (__v8hi)__count); |
Craig Topper | cbe627b | 2011-12-24 03:28:57 +0000 | [diff] [blame] | 600 | } |
| 601 | |
| 602 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 603 | _mm256_srli_epi32(__m256i __a, int __count) |
Craig Topper | cbe627b | 2011-12-24 03:28:57 +0000 | [diff] [blame] | 604 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 605 | return (__m256i)__builtin_ia32_psrldi256((__v8si)__a, __count); |
Craig Topper | cbe627b | 2011-12-24 03:28:57 +0000 | [diff] [blame] | 606 | } |
| 607 | |
| 608 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 609 | _mm256_srl_epi32(__m256i __a, __m128i __count) |
Craig Topper | cbe627b | 2011-12-24 03:28:57 +0000 | [diff] [blame] | 610 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 611 | return (__m256i)__builtin_ia32_psrld256((__v8si)__a, (__v4si)__count); |
Craig Topper | cbe627b | 2011-12-24 03:28:57 +0000 | [diff] [blame] | 612 | } |
| 613 | |
| 614 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 615 | _mm256_srli_epi64(__m256i __a, int __count) |
Craig Topper | cbe627b | 2011-12-24 03:28:57 +0000 | [diff] [blame] | 616 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 617 | return __builtin_ia32_psrlqi256(__a, __count); |
Craig Topper | cbe627b | 2011-12-24 03:28:57 +0000 | [diff] [blame] | 618 | } |
| 619 | |
| 620 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 621 | _mm256_srl_epi64(__m256i __a, __m128i __count) |
Craig Topper | cbe627b | 2011-12-24 03:28:57 +0000 | [diff] [blame] | 622 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 623 | return __builtin_ia32_psrlq256(__a, __count); |
Craig Topper | cbe627b | 2011-12-24 03:28:57 +0000 | [diff] [blame] | 624 | } |
| 625 | |
| 626 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 627 | _mm256_sub_epi8(__m256i __a, __m256i __b) |
Craig Topper | 925be54 | 2011-12-19 05:04:33 +0000 | [diff] [blame] | 628 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 629 | return (__m256i)((__v32qi)__a - (__v32qi)__b); |
Craig Topper | 925be54 | 2011-12-19 05:04:33 +0000 | [diff] [blame] | 630 | } |
| 631 | |
| 632 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 633 | _mm256_sub_epi16(__m256i __a, __m256i __b) |
Craig Topper | 925be54 | 2011-12-19 05:04:33 +0000 | [diff] [blame] | 634 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 635 | return (__m256i)((__v16hi)__a - (__v16hi)__b); |
Craig Topper | 925be54 | 2011-12-19 05:04:33 +0000 | [diff] [blame] | 636 | } |
| 637 | |
| 638 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 639 | _mm256_sub_epi32(__m256i __a, __m256i __b) |
Craig Topper | 925be54 | 2011-12-19 05:04:33 +0000 | [diff] [blame] | 640 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 641 | return (__m256i)((__v8si)__a - (__v8si)__b); |
Craig Topper | 925be54 | 2011-12-19 05:04:33 +0000 | [diff] [blame] | 642 | } |
| 643 | |
| 644 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 645 | _mm256_sub_epi64(__m256i __a, __m256i __b) |
Craig Topper | 925be54 | 2011-12-19 05:04:33 +0000 | [diff] [blame] | 646 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 647 | return __a - __b; |
Craig Topper | 925be54 | 2011-12-19 05:04:33 +0000 | [diff] [blame] | 648 | } |
Craig Topper | 9c2ffd8 | 2011-12-19 07:03:25 +0000 | [diff] [blame] | 649 | |
| 650 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 651 | _mm256_subs_epi8(__m256i __a, __m256i __b) |
Craig Topper | 9c2ffd8 | 2011-12-19 07:03:25 +0000 | [diff] [blame] | 652 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 653 | return (__m256i)__builtin_ia32_psubsb256((__v32qi)__a, (__v32qi)__b); |
Craig Topper | 9c2ffd8 | 2011-12-19 07:03:25 +0000 | [diff] [blame] | 654 | } |
| 655 | |
| 656 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 657 | _mm256_subs_epi16(__m256i __a, __m256i __b) |
Craig Topper | 9c2ffd8 | 2011-12-19 07:03:25 +0000 | [diff] [blame] | 658 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 659 | return (__m256i)__builtin_ia32_psubsw256((__v16hi)__a, (__v16hi)__b); |
Craig Topper | 9c2ffd8 | 2011-12-19 07:03:25 +0000 | [diff] [blame] | 660 | } |
| 661 | |
| 662 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 663 | _mm256_subs_epu8(__m256i __a, __m256i __b) |
Craig Topper | 9c2ffd8 | 2011-12-19 07:03:25 +0000 | [diff] [blame] | 664 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 665 | return (__m256i)__builtin_ia32_psubusb256((__v32qi)__a, (__v32qi)__b); |
Craig Topper | 9c2ffd8 | 2011-12-19 07:03:25 +0000 | [diff] [blame] | 666 | } |
| 667 | |
| 668 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 669 | _mm256_subs_epu16(__m256i __a, __m256i __b) |
Craig Topper | 9c2ffd8 | 2011-12-19 07:03:25 +0000 | [diff] [blame] | 670 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 671 | return (__m256i)__builtin_ia32_psubusw256((__v16hi)__a, (__v16hi)__b); |
Craig Topper | 9c2ffd8 | 2011-12-19 07:03:25 +0000 | [diff] [blame] | 672 | } |
| 673 | |
Craig Topper | 735ceaa | 2011-12-19 09:03:48 +0000 | [diff] [blame] | 674 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 675 | _mm256_unpackhi_epi8(__m256i __a, __m256i __b) |
Craig Topper | 7f16caa | 2011-12-24 03:58:43 +0000 | [diff] [blame] | 676 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 677 | return (__m256i)__builtin_shufflevector((__v32qi)__a, (__v32qi)__b, 8, 32+8, 9, 32+9, 10, 32+10, 11, 32+11, 12, 32+12, 13, 32+13, 14, 32+14, 15, 32+15, 24, 32+24, 25, 32+25, 26, 32+26, 27, 32+27, 28, 32+28, 29, 32+29, 30, 32+30, 31, 32+31); |
Craig Topper | 7f16caa | 2011-12-24 03:58:43 +0000 | [diff] [blame] | 678 | } |
| 679 | |
| 680 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 681 | _mm256_unpackhi_epi16(__m256i __a, __m256i __b) |
Craig Topper | 7f16caa | 2011-12-24 03:58:43 +0000 | [diff] [blame] | 682 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 683 | return (__m256i)__builtin_shufflevector((__v16hi)__a, (__v16hi)__b, 4, 16+4, 5, 16+5, 6, 16+6, 7, 16+7, 12, 16+12, 13, 16+13, 14, 16+14, 15, 16+15); |
Craig Topper | 7f16caa | 2011-12-24 03:58:43 +0000 | [diff] [blame] | 684 | } |
| 685 | |
| 686 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 687 | _mm256_unpackhi_epi32(__m256i __a, __m256i __b) |
Craig Topper | 7f16caa | 2011-12-24 03:58:43 +0000 | [diff] [blame] | 688 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 689 | return (__m256i)__builtin_shufflevector((__v8si)__a, (__v8si)__b, 2, 8+2, 3, 8+3, 6, 8+6, 7, 8+7); |
Craig Topper | 7f16caa | 2011-12-24 03:58:43 +0000 | [diff] [blame] | 690 | } |
| 691 | |
| 692 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 693 | _mm256_unpackhi_epi64(__m256i __a, __m256i __b) |
Craig Topper | 7f16caa | 2011-12-24 03:58:43 +0000 | [diff] [blame] | 694 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 695 | return (__m256i)__builtin_shufflevector(__a, __b, 1, 4+1, 3, 4+3); |
Craig Topper | 7f16caa | 2011-12-24 03:58:43 +0000 | [diff] [blame] | 696 | } |
| 697 | |
| 698 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 699 | _mm256_unpacklo_epi8(__m256i __a, __m256i __b) |
Craig Topper | 7f16caa | 2011-12-24 03:58:43 +0000 | [diff] [blame] | 700 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 701 | return (__m256i)__builtin_shufflevector((__v32qi)__a, (__v32qi)__b, 0, 32+0, 1, 32+1, 2, 32+2, 3, 32+3, 4, 32+4, 5, 32+5, 6, 32+6, 7, 32+7, 16, 32+16, 17, 32+17, 18, 32+18, 19, 32+19, 20, 32+20, 21, 32+21, 22, 32+22, 23, 32+23); |
Craig Topper | 7f16caa | 2011-12-24 03:58:43 +0000 | [diff] [blame] | 702 | } |
| 703 | |
| 704 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 705 | _mm256_unpacklo_epi16(__m256i __a, __m256i __b) |
Craig Topper | 7f16caa | 2011-12-24 03:58:43 +0000 | [diff] [blame] | 706 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 707 | return (__m256i)__builtin_shufflevector((__v16hi)__a, (__v16hi)__b, 0, 16+0, 1, 16+1, 2, 16+2, 3, 16+3, 8, 16+8, 9, 16+9, 10, 16+10, 11, 16+11); |
Craig Topper | 7f16caa | 2011-12-24 03:58:43 +0000 | [diff] [blame] | 708 | } |
| 709 | |
| 710 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 711 | _mm256_unpacklo_epi32(__m256i __a, __m256i __b) |
Craig Topper | 7f16caa | 2011-12-24 03:58:43 +0000 | [diff] [blame] | 712 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 713 | return (__m256i)__builtin_shufflevector((__v8si)__a, (__v8si)__b, 0, 8+0, 1, 8+1, 4, 8+4, 5, 8+5); |
Craig Topper | 7f16caa | 2011-12-24 03:58:43 +0000 | [diff] [blame] | 714 | } |
| 715 | |
| 716 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 717 | _mm256_unpacklo_epi64(__m256i __a, __m256i __b) |
Craig Topper | 7f16caa | 2011-12-24 03:58:43 +0000 | [diff] [blame] | 718 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 719 | return (__m256i)__builtin_shufflevector(__a, __b, 0, 4+0, 2, 4+2); |
Craig Topper | 7f16caa | 2011-12-24 03:58:43 +0000 | [diff] [blame] | 720 | } |
| 721 | |
| 722 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 723 | _mm256_xor_si256(__m256i __a, __m256i __b) |
Craig Topper | 735ceaa | 2011-12-19 09:03:48 +0000 | [diff] [blame] | 724 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 725 | return __a ^ __b; |
Craig Topper | 735ceaa | 2011-12-19 09:03:48 +0000 | [diff] [blame] | 726 | } |
Craig Topper | ee9b41d | 2011-12-24 05:19:29 +0000 | [diff] [blame] | 727 | |
| 728 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
| 729 | _mm256_stream_load_si256(__m256i *__V) |
| 730 | { |
| 731 | return (__m256i)__builtin_ia32_movntdqa256((__v4di *)__V); |
| 732 | } |
| 733 | |
| 734 | static __inline__ __m128 __attribute__((__always_inline__, __nodebug__)) |
| 735 | _mm_broadcastss_ps(__m128 __X) |
| 736 | { |
| 737 | return (__m128)__builtin_ia32_vbroadcastss_ps((__v4sf)__X); |
| 738 | } |
| 739 | |
| 740 | static __inline__ __m256 __attribute__((__always_inline__, __nodebug__)) |
| 741 | _mm256_broadcastss_ps(__m128 __X) |
| 742 | { |
| 743 | return (__m256)__builtin_ia32_vbroadcastss_ps256((__v4sf)__X); |
| 744 | } |
| 745 | |
| 746 | static __inline__ __m256d __attribute__((__always_inline__, __nodebug__)) |
| 747 | _mm256_broadcastsd_pd(__m128d __X) |
| 748 | { |
| 749 | return (__m256d)__builtin_ia32_vbroadcastsd_pd256((__v2df)__X); |
| 750 | } |
| 751 | |
| 752 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 753 | _mm_broadcastsi128_si256(__m128i const *__a) |
Craig Topper | ee9b41d | 2011-12-24 05:19:29 +0000 | [diff] [blame] | 754 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 755 | return (__m256i)__builtin_ia32_vbroadcastsi256(__a); |
Craig Topper | ee9b41d | 2011-12-24 05:19:29 +0000 | [diff] [blame] | 756 | } |
| 757 | |
| 758 | #define _mm_blend_epi32(V1, V2, M) __extension__ ({ \ |
| 759 | __m128i __V1 = (V1); \ |
| 760 | __m128i __V2 = (V2); \ |
Craig Topper | 34a1da4 | 2011-12-24 07:55:14 +0000 | [diff] [blame] | 761 | (__m128i)__builtin_ia32_pblendd128((__v4si)__V1, (__v4si)__V2, (M)); }) |
Craig Topper | ee9b41d | 2011-12-24 05:19:29 +0000 | [diff] [blame] | 762 | |
| 763 | #define _mm256_blend_epi32(V1, V2, M) __extension__ ({ \ |
| 764 | __m256i __V1 = (V1); \ |
| 765 | __m256i __V2 = (V2); \ |
Craig Topper | 34a1da4 | 2011-12-24 07:55:14 +0000 | [diff] [blame] | 766 | (__m256i)__builtin_ia32_pblendd256((__v8si)__V1, (__v8si)__V2, (M)); }) |
| 767 | |
| 768 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
| 769 | _mm256_broadcastb_epi8(__m128i __X) |
| 770 | { |
| 771 | return (__m256i)__builtin_ia32_pbroadcastb256((__v16qi)__X); |
| 772 | } |
| 773 | |
| 774 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
| 775 | _mm256_broadcastw_epi16(__m128i __X) |
| 776 | { |
| 777 | return (__m256i)__builtin_ia32_pbroadcastw256((__v8hi)__X); |
| 778 | } |
| 779 | |
| 780 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
| 781 | _mm256_broadcastd_epi32(__m128i __X) |
| 782 | { |
| 783 | return (__m256i)__builtin_ia32_pbroadcastd256((__v4si)__X); |
| 784 | } |
| 785 | |
| 786 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
| 787 | _mm256_broadcastq_epi64(__m128i __X) |
| 788 | { |
| 789 | return (__m256i)__builtin_ia32_pbroadcastq256(__X); |
| 790 | } |
| 791 | |
| 792 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
| 793 | _mm_broadcastb_epi8(__m128i __X) |
| 794 | { |
| 795 | return (__m128i)__builtin_ia32_pbroadcastb128((__v16qi)__X); |
| 796 | } |
| 797 | |
| 798 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
| 799 | _mm_broadcastw_epi16(__m128i __X) |
| 800 | { |
| 801 | return (__m128i)__builtin_ia32_pbroadcastw128((__v8hi)__X); |
| 802 | } |
| 803 | |
| 804 | |
| 805 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
| 806 | _mm_broadcastd_epi32(__m128i __X) |
| 807 | { |
| 808 | return (__m128i)__builtin_ia32_pbroadcastd128((__v4si)__X); |
| 809 | } |
| 810 | |
| 811 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
| 812 | _mm_broadcastq_epi64(__m128i __X) |
| 813 | { |
| 814 | return (__m128i)__builtin_ia32_pbroadcastq128(__X); |
| 815 | } |
| 816 | |
| 817 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 818 | _mm256_permutevar8x32_epi32(__m256i __a, __m256i __b) |
Craig Topper | 34a1da4 | 2011-12-24 07:55:14 +0000 | [diff] [blame] | 819 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 820 | return (__m256i)__builtin_ia32_permvarsi256((__v8si)__a, (__v8si)__b); |
Craig Topper | 34a1da4 | 2011-12-24 07:55:14 +0000 | [diff] [blame] | 821 | } |
| 822 | |
| 823 | #define _mm256_permute4x64_pd(V, M) __extension__ ({ \ |
| 824 | __m256d __V = (V); \ |
Craig Topper | b5491f3 | 2012-04-15 22:18:10 +0000 | [diff] [blame] | 825 | (__m256d)__builtin_shufflevector((__v4df)__V, (__v4df) _mm256_setzero_pd(), \ |
| 826 | (M) & 0x3, ((M) & 0xc) >> 2, \ |
| 827 | ((M) & 0x30) >> 4, ((M) & 0xc0) >> 6); }) |
Craig Topper | 34a1da4 | 2011-12-24 07:55:14 +0000 | [diff] [blame] | 828 | |
| 829 | static __inline__ __m256 __attribute__((__always_inline__, __nodebug__)) |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 830 | _mm256_permutevar8x32_ps(__m256 __a, __m256 __b) |
Craig Topper | 34a1da4 | 2011-12-24 07:55:14 +0000 | [diff] [blame] | 831 | { |
David Blaikie | 4f918ae | 2013-01-16 23:08:36 +0000 | [diff] [blame] | 832 | return (__m256)__builtin_ia32_permvarsf256((__v8sf)__a, (__v8sf)__b); |
Craig Topper | 34a1da4 | 2011-12-24 07:55:14 +0000 | [diff] [blame] | 833 | } |
| 834 | |
| 835 | #define _mm256_permute4x64_epi64(V, M) __extension__ ({ \ |
| 836 | __m256i __V = (V); \ |
Craig Topper | b5491f3 | 2012-04-15 22:18:10 +0000 | [diff] [blame] | 837 | (__m256i)__builtin_shufflevector((__v4di)__V, (__v4di) _mm256_setzero_si256(), \ |
| 838 | (M) & 0x3, ((M) & 0xc) >> 2, \ |
| 839 | ((M) & 0x30) >> 4, ((M) & 0xc0) >> 6); }) |
Craig Topper | 34a1da4 | 2011-12-24 07:55:14 +0000 | [diff] [blame] | 840 | |
| 841 | #define _mm256_permute2x128_si256(V1, V2, M) __extension__ ({ \ |
| 842 | __m256i __V1 = (V1); \ |
| 843 | __m256i __V2 = (V2); \ |
Craig Topper | 49a110d | 2012-04-17 05:16:56 +0000 | [diff] [blame] | 844 | (__m256i)__builtin_ia32_permti256(__V1, __V2, (M)); }) |
Craig Topper | 5cbd751 | 2011-12-24 17:20:15 +0000 | [diff] [blame] | 845 | |
| 846 | #define _mm256_extracti128_si256(A, O) __extension__ ({ \ |
| 847 | __m256i __A = (A); \ |
| 848 | (__m128i)__builtin_ia32_extract128i256(__A, (O)); }) |
| 849 | |
| 850 | #define _mm256_inserti128_si256(V1, V2, O) __extension__ ({ \ |
| 851 | __m256i __V1 = (V1); \ |
| 852 | __m128i __V2 = (V2); \ |
| 853 | (__m256i)__builtin_ia32_insert128i256(__V1, __V2, (O)); }) |
| 854 | |
| 855 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
| 856 | _mm256_maskload_epi32(int const *__X, __m256i __M) |
| 857 | { |
| 858 | return (__m256i)__builtin_ia32_maskloadd256((const __v8si *)__X, (__v8si)__M); |
| 859 | } |
| 860 | |
| 861 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
| 862 | _mm256_maskload_epi64(long long const *__X, __m256i __M) |
| 863 | { |
| 864 | return (__m256i)__builtin_ia32_maskloadq256((const __v4di *)__X, __M); |
| 865 | } |
| 866 | |
| 867 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
| 868 | _mm_maskload_epi32(int const *__X, __m128i __M) |
| 869 | { |
| 870 | return (__m128i)__builtin_ia32_maskloadd((const __v4si *)__X, (__v4si)__M); |
| 871 | } |
| 872 | |
| 873 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
| 874 | _mm_maskload_epi64(long long const *__X, __m128i __M) |
| 875 | { |
| 876 | return (__m128i)__builtin_ia32_maskloadq((const __v2di *)__X, (__v2di)__M); |
| 877 | } |
| 878 | |
| 879 | static __inline__ void __attribute__((__always_inline__, __nodebug__)) |
| 880 | _mm256_maskstore_epi32(int *__X, __m256i __M, __m256i __Y) |
| 881 | { |
| 882 | __builtin_ia32_maskstored256((__v8si *)__X, (__v8si)__M, (__v8si)__Y); |
| 883 | } |
| 884 | |
| 885 | static __inline__ void __attribute__((__always_inline__, __nodebug__)) |
| 886 | _mm256_maskstore_epi64(long long *__X, __m256i __M, __m256i __Y) |
| 887 | { |
| 888 | __builtin_ia32_maskstoreq256((__v4di *)__X, __M, __Y); |
| 889 | } |
| 890 | |
| 891 | static __inline__ void __attribute__((__always_inline__, __nodebug__)) |
| 892 | _mm_maskstore_epi32(int *__X, __m128i __M, __m128i __Y) |
| 893 | { |
| 894 | __builtin_ia32_maskstored((__v4si *)__X, (__v4si)__M, (__v4si)__Y); |
| 895 | } |
| 896 | |
| 897 | static __inline__ void __attribute__((__always_inline__, __nodebug__)) |
| 898 | _mm_maskstore_epi64(long long *__X, __m128i __M, __m128i __Y) |
| 899 | { |
| 900 | __builtin_ia32_maskstoreq(( __v2di *)__X, __M, __Y); |
| 901 | } |
| 902 | |
| 903 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
| 904 | _mm256_sllv_epi32(__m256i __X, __m256i __Y) |
| 905 | { |
| 906 | return (__m256i)__builtin_ia32_psllv8si((__v8si)__X, (__v8si)__Y); |
| 907 | } |
| 908 | |
| 909 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
| 910 | _mm_sllv_epi32(__m128i __X, __m128i __Y) |
| 911 | { |
| 912 | return (__m128i)__builtin_ia32_psllv4si((__v4si)__X, (__v4si)__Y); |
| 913 | } |
| 914 | |
| 915 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
| 916 | _mm256_sllv_epi64(__m256i __X, __m256i __Y) |
| 917 | { |
| 918 | return (__m256i)__builtin_ia32_psllv4di(__X, __Y); |
| 919 | } |
| 920 | |
| 921 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
| 922 | _mm_sllv_epi64(__m128i __X, __m128i __Y) |
| 923 | { |
| 924 | return (__m128i)__builtin_ia32_psllv2di(__X, __Y); |
| 925 | } |
| 926 | |
| 927 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
| 928 | _mm256_srav_epi32(__m256i __X, __m256i __Y) |
| 929 | { |
| 930 | return (__m256i)__builtin_ia32_psrav8si((__v8si)__X, (__v8si)__Y); |
| 931 | } |
| 932 | |
| 933 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
| 934 | _mm_srav_epi32(__m128i __X, __m128i __Y) |
| 935 | { |
| 936 | return (__m128i)__builtin_ia32_psrav4si((__v4si)__X, (__v4si)__Y); |
| 937 | } |
| 938 | |
| 939 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
| 940 | _mm256_srlv_epi32(__m256i __X, __m256i __Y) |
| 941 | { |
| 942 | return (__m256i)__builtin_ia32_psrlv8si((__v8si)__X, (__v8si)__Y); |
| 943 | } |
| 944 | |
| 945 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
| 946 | _mm_srlv_epi32(__m128i __X, __m128i __Y) |
| 947 | { |
| 948 | return (__m128i)__builtin_ia32_psrlv4si((__v4si)__X, (__v4si)__Y); |
| 949 | } |
| 950 | |
| 951 | static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) |
| 952 | _mm256_srlv_epi64(__m256i __X, __m256i __Y) |
| 953 | { |
| 954 | return (__m256i)__builtin_ia32_psrlv4di(__X, __Y); |
| 955 | } |
| 956 | |
| 957 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
| 958 | _mm_srlv_epi64(__m128i __X, __m128i __Y) |
| 959 | { |
| 960 | return (__m128i)__builtin_ia32_psrlv2di(__X, __Y); |
| 961 | } |
Manman Ren | 5283c99 | 2012-06-26 19:55:09 +0000 | [diff] [blame] | 962 | |
| 963 | #define _mm_mask_i32gather_pd(a, m, i, mask, s) __extension__ ({ \ |
| 964 | __m128d __a = (a); \ |
| 965 | double const *__m = (m); \ |
| 966 | __m128i __i = (i); \ |
| 967 | __m128d __mask = (mask); \ |
| 968 | (__m128d)__builtin_ia32_gatherd_pd((__v2df)__a, (const __v2df *)__m, \ |
| 969 | (__v4si)__i, (__v2df)__mask, (s)); }) |
| 970 | |
| 971 | #define _mm256_mask_i32gather_pd(a, m, i, mask, s) __extension__ ({ \ |
| 972 | __m256d __a = (a); \ |
| 973 | double const *__m = (m); \ |
Manman Ren | c84804a | 2012-06-29 00:54:35 +0000 | [diff] [blame] | 974 | __m128i __i = (i); \ |
Manman Ren | 5283c99 | 2012-06-26 19:55:09 +0000 | [diff] [blame] | 975 | __m256d __mask = (mask); \ |
| 976 | (__m256d)__builtin_ia32_gatherd_pd256((__v4df)__a, (const __v4df *)__m, \ |
Manman Ren | c84804a | 2012-06-29 00:54:35 +0000 | [diff] [blame] | 977 | (__v4si)__i, (__v4df)__mask, (s)); }) |
Manman Ren | 5283c99 | 2012-06-26 19:55:09 +0000 | [diff] [blame] | 978 | |
| 979 | #define _mm_mask_i64gather_pd(a, m, i, mask, s) __extension__ ({ \ |
| 980 | __m128d __a = (a); \ |
| 981 | double const *__m = (m); \ |
| 982 | __m128i __i = (i); \ |
| 983 | __m128d __mask = (mask); \ |
| 984 | (__m128d)__builtin_ia32_gatherq_pd((__v2df)__a, (const __v2df *)__m, \ |
| 985 | (__v2di)__i, (__v2df)__mask, (s)); }) |
| 986 | |
| 987 | #define _mm256_mask_i64gather_pd(a, m, i, mask, s) __extension__ ({ \ |
| 988 | __m256d __a = (a); \ |
| 989 | double const *__m = (m); \ |
| 990 | __m256i __i = (i); \ |
| 991 | __m256d __mask = (mask); \ |
| 992 | (__m256d)__builtin_ia32_gatherq_pd256((__v4df)__a, (const __v4df *)__m, \ |
| 993 | (__v4di)__i, (__v4df)__mask, (s)); }) |
| 994 | |
| 995 | #define _mm_mask_i32gather_ps(a, m, i, mask, s) __extension__ ({ \ |
| 996 | __m128 __a = (a); \ |
| 997 | float const *__m = (m); \ |
| 998 | __m128i __i = (i); \ |
| 999 | __m128 __mask = (mask); \ |
| 1000 | (__m128)__builtin_ia32_gatherd_ps((__v4sf)__a, (const __v4sf *)__m, \ |
| 1001 | (__v4si)__i, (__v4sf)__mask, (s)); }) |
| 1002 | |
| 1003 | #define _mm256_mask_i32gather_ps(a, m, i, mask, s) __extension__ ({ \ |
| 1004 | __m256 __a = (a); \ |
| 1005 | float const *__m = (m); \ |
| 1006 | __m256i __i = (i); \ |
| 1007 | __m256 __mask = (mask); \ |
| 1008 | (__m256)__builtin_ia32_gatherd_ps256((__v8sf)__a, (const __v8sf *)__m, \ |
| 1009 | (__v8si)__i, (__v8sf)__mask, (s)); }) |
| 1010 | |
| 1011 | #define _mm_mask_i64gather_ps(a, m, i, mask, s) __extension__ ({ \ |
| 1012 | __m128 __a = (a); \ |
| 1013 | float const *__m = (m); \ |
| 1014 | __m128i __i = (i); \ |
| 1015 | __m128 __mask = (mask); \ |
| 1016 | (__m128)__builtin_ia32_gatherq_ps((__v4sf)__a, (const __v4sf *)__m, \ |
| 1017 | (__v2di)__i, (__v4sf)__mask, (s)); }) |
| 1018 | |
| 1019 | #define _mm256_mask_i64gather_ps(a, m, i, mask, s) __extension__ ({ \ |
Manman Ren | c84804a | 2012-06-29 00:54:35 +0000 | [diff] [blame] | 1020 | __m128 __a = (a); \ |
Manman Ren | 5283c99 | 2012-06-26 19:55:09 +0000 | [diff] [blame] | 1021 | float const *__m = (m); \ |
| 1022 | __m256i __i = (i); \ |
Manman Ren | c84804a | 2012-06-29 00:54:35 +0000 | [diff] [blame] | 1023 | __m128 __mask = (mask); \ |
| 1024 | (__m128)__builtin_ia32_gatherq_ps256((__v4sf)__a, (const __v4sf *)__m, \ |
| 1025 | (__v4di)__i, (__v4sf)__mask, (s)); }) |
| 1026 | |
| 1027 | #define _mm_mask_i32gather_epi32(a, m, i, mask, s) __extension__ ({ \ |
| 1028 | __m128i __a = (a); \ |
| 1029 | int const *__m = (m); \ |
| 1030 | __m128i __i = (i); \ |
| 1031 | __m128i __mask = (mask); \ |
| 1032 | (__m128i)__builtin_ia32_gatherd_d((__v4si)__a, (const __v4si *)__m, \ |
| 1033 | (__v4si)__i, (__v4si)__mask, (s)); }) |
| 1034 | |
| 1035 | #define _mm256_mask_i32gather_epi32(a, m, i, mask, s) __extension__ ({ \ |
| 1036 | __m256i __a = (a); \ |
| 1037 | int const *__m = (m); \ |
| 1038 | __m256i __i = (i); \ |
| 1039 | __m256i __mask = (mask); \ |
| 1040 | (__m256i)__builtin_ia32_gatherd_d256((__v8si)__a, (const __v8si *)__m, \ |
| 1041 | (__v8si)__i, (__v8si)__mask, (s)); }) |
| 1042 | |
| 1043 | #define _mm_mask_i64gather_epi32(a, m, i, mask, s) __extension__ ({ \ |
| 1044 | __m128i __a = (a); \ |
| 1045 | int const *__m = (m); \ |
| 1046 | __m128i __i = (i); \ |
| 1047 | __m128i __mask = (mask); \ |
| 1048 | (__m128i)__builtin_ia32_gatherq_d((__v4si)__a, (const __v4si *)__m, \ |
| 1049 | (__v2di)__i, (__v4si)__mask, (s)); }) |
| 1050 | |
| 1051 | #define _mm256_mask_i64gather_epi32(a, m, i, mask, s) __extension__ ({ \ |
| 1052 | __m128i __a = (a); \ |
| 1053 | int const *__m = (m); \ |
| 1054 | __m256i __i = (i); \ |
| 1055 | __m128i __mask = (mask); \ |
| 1056 | (__m128i)__builtin_ia32_gatherq_d256((__v4si)__a, (const __v4si *)__m, \ |
| 1057 | (__v4di)__i, (__v4si)__mask, (s)); }) |
| 1058 | |
| 1059 | #define _mm_mask_i32gather_epi64(a, m, i, mask, s) __extension__ ({ \ |
| 1060 | __m128i __a = (a); \ |
| 1061 | int const *__m = (m); \ |
| 1062 | __m128i __i = (i); \ |
| 1063 | __m128i __mask = (mask); \ |
| 1064 | (__m128i)__builtin_ia32_gatherd_q((__v2di)__a, (const __v2di *)__m, \ |
| 1065 | (__v4si)__i, (__v2di)__mask, (s)); }) |
| 1066 | |
| 1067 | #define _mm256_mask_i32gather_epi64(a, m, i, mask, s) __extension__ ({ \ |
| 1068 | __m256i __a = (a); \ |
| 1069 | int const *__m = (m); \ |
| 1070 | __m128i __i = (i); \ |
| 1071 | __m256i __mask = (mask); \ |
| 1072 | (__m256i)__builtin_ia32_gatherd_q256((__v4di)__a, (const __v4di *)__m, \ |
| 1073 | (__v4si)__i, (__v4di)__mask, (s)); }) |
| 1074 | |
| 1075 | #define _mm_mask_i64gather_epi64(a, m, i, mask, s) __extension__ ({ \ |
| 1076 | __m128i __a = (a); \ |
| 1077 | int const *__m = (m); \ |
| 1078 | __m128i __i = (i); \ |
| 1079 | __m128i __mask = (mask); \ |
| 1080 | (__m128i)__builtin_ia32_gatherq_q((__v2di)__a, (const __v2di *)__m, \ |
| 1081 | (__v2di)__i, (__v2di)__mask, (s)); }) |
| 1082 | |
| 1083 | #define _mm256_mask_i64gather_epi64(a, m, i, mask, s) __extension__ ({ \ |
| 1084 | __m256i __a = (a); \ |
| 1085 | int const *__m = (m); \ |
| 1086 | __m256i __i = (i); \ |
| 1087 | __m256i __mask = (mask); \ |
| 1088 | (__m256i)__builtin_ia32_gatherq_q256((__v4di)__a, (const __v4di *)__m, \ |
| 1089 | (__v4di)__i, (__v4di)__mask, (s)); }) |
Manman Ren | 56c045e | 2012-06-29 05:19:13 +0000 | [diff] [blame] | 1090 | |
| 1091 | #define _mm_i32gather_pd(m, i, s) __extension__ ({ \ |
| 1092 | double const *__m = (m); \ |
| 1093 | __m128i __i = (i); \ |
| 1094 | (__m128d)__builtin_ia32_gatherd_pd((__v2df)_mm_setzero_pd(), \ |
| 1095 | (const __v2df *)__m, (__v4si)__i, \ |
| 1096 | (__v2df)_mm_set1_pd((double)(long long int)-1), (s)); }) |
| 1097 | |
| 1098 | #define _mm256_i32gather_pd(m, i, s) __extension__ ({ \ |
| 1099 | double const *__m = (m); \ |
| 1100 | __m128i __i = (i); \ |
| 1101 | (__m256d)__builtin_ia32_gatherd_pd256((__v4df)_mm256_setzero_pd(), \ |
| 1102 | (const __v4df *)__m, (__v4si)__i, \ |
| 1103 | (__v4df)_mm256_set1_pd((double)(long long int)-1), (s)); }) |
| 1104 | |
| 1105 | #define _mm_i64gather_pd(m, i, s) __extension__ ({ \ |
| 1106 | double const *__m = (m); \ |
| 1107 | __m128i __i = (i); \ |
| 1108 | (__m128d)__builtin_ia32_gatherq_pd((__v2df)_mm_setzero_pd(), \ |
| 1109 | (const __v2df *)__m, (__v2di)__i, \ |
| 1110 | (__v2df)_mm_set1_pd((double)(long long int)-1), (s)); }) |
| 1111 | |
| 1112 | #define _mm256_i64gather_pd(m, i, s) __extension__ ({ \ |
| 1113 | double const *__m = (m); \ |
| 1114 | __m256i __i = (i); \ |
| 1115 | (__m256d)__builtin_ia32_gatherq_pd256((__v4df)_mm256_setzero_pd(), \ |
| 1116 | (const __v4df *)__m, (__v4di)__i, \ |
| 1117 | (__v4df)_mm256_set1_pd((double)(long long int)-1), (s)); }) |
| 1118 | |
| 1119 | #define _mm_i32gather_ps(m, i, s) __extension__ ({ \ |
| 1120 | float const *__m = (m); \ |
| 1121 | __m128i __i = (i); \ |
| 1122 | (__m128)__builtin_ia32_gatherd_ps((__v4sf)_mm_setzero_ps(), \ |
| 1123 | (const __v4sf *)__m, (__v4si)__i, \ |
| 1124 | (__v4sf)_mm_set1_ps((float)(int)-1), (s)); }) |
| 1125 | |
| 1126 | #define _mm256_i32gather_ps(m, i, s) __extension__ ({ \ |
| 1127 | float const *__m = (m); \ |
| 1128 | __m256i __i = (i); \ |
| 1129 | (__m256)__builtin_ia32_gatherd_ps256((__v8sf)_mm256_setzero_ps(), \ |
| 1130 | (const __v8sf *)__m, (__v8si)__i, \ |
| 1131 | (__v8sf)_mm256_set1_ps((float)(int)-1), (s)); }) |
| 1132 | |
| 1133 | #define _mm_i64gather_ps(m, i, s) __extension__ ({ \ |
| 1134 | float const *__m = (m); \ |
| 1135 | __m128i __i = (i); \ |
| 1136 | (__m128)__builtin_ia32_gatherq_ps((__v4sf)_mm_setzero_ps(), \ |
| 1137 | (const __v4sf *)__m, (__v2di)__i, \ |
| 1138 | (__v4sf)_mm_set1_ps((float)(int)-1), (s)); }) |
| 1139 | |
| 1140 | #define _mm256_i64gather_ps(m, i, s) __extension__ ({ \ |
| 1141 | float const *__m = (m); \ |
| 1142 | __m256i __i = (i); \ |
| 1143 | (__m128)__builtin_ia32_gatherq_ps256((__v4sf)_mm_setzero_ps(), \ |
| 1144 | (const __v4sf *)__m, (__v4di)__i, \ |
| 1145 | (__v4sf)_mm_set1_ps((float)(int)-1), (s)); }) |
| 1146 | |
| 1147 | #define _mm_i32gather_epi32(m, i, s) __extension__ ({ \ |
| 1148 | int const *__m = (m); \ |
| 1149 | __m128i __i = (i); \ |
| 1150 | (__m128i)__builtin_ia32_gatherd_d((__v4si)_mm_setzero_si128(), \ |
| 1151 | (const __v4si *)__m, (__v4si)__i, \ |
| 1152 | (__v4si)_mm_set1_epi32(-1), (s)); }) |
| 1153 | |
| 1154 | #define _mm256_i32gather_epi32(m, i, s) __extension__ ({ \ |
| 1155 | int const *__m = (m); \ |
| 1156 | __m256i __i = (i); \ |
| 1157 | (__m256i)__builtin_ia32_gatherd_d256((__v8si)_mm256_setzero_si256(), \ |
| 1158 | (const __v8si *)__m, (__v8si)__i, \ |
| 1159 | (__v8si)_mm256_set1_epi32(-1), (s)); }) |
| 1160 | |
| 1161 | #define _mm_i64gather_epi32(m, i, s) __extension__ ({ \ |
| 1162 | int const *__m = (m); \ |
| 1163 | __m128i __i = (i); \ |
| 1164 | (__m128i)__builtin_ia32_gatherq_d((__v4si)_mm_setzero_si128(), \ |
| 1165 | (const __v4si *)__m, (__v2di)__i, \ |
| 1166 | (__v4si)_mm_set1_epi32(-1), (s)); }) |
| 1167 | |
| 1168 | #define _mm256_i64gather_epi32(m, i, s) __extension__ ({ \ |
| 1169 | int const *__m = (m); \ |
| 1170 | __m256i __i = (i); \ |
| 1171 | (__m128i)__builtin_ia32_gatherq_d256((__v4si)_mm_setzero_si128(), \ |
| 1172 | (const __v4si *)__m, (__v4di)__i, \ |
| 1173 | (__v4si)_mm_set1_epi32(-1), (s)); }) |
| 1174 | |
| 1175 | #define _mm_i32gather_epi64(m, i, s) __extension__ ({ \ |
| 1176 | int const *__m = (m); \ |
| 1177 | __m128i __i = (i); \ |
| 1178 | (__m128i)__builtin_ia32_gatherd_q((__v2di)_mm_setzero_si128(), \ |
| 1179 | (const __v2di *)__m, (__v4si)__i, \ |
| 1180 | (__v2di)_mm_set1_epi64x(-1), (s)); }) |
| 1181 | |
| 1182 | #define _mm256_i32gather_epi64(m, i, s) __extension__ ({ \ |
| 1183 | int const *__m = (m); \ |
| 1184 | __m128i __i = (i); \ |
| 1185 | (__m256i)__builtin_ia32_gatherd_q256((__v4di)_mm256_setzero_si256(), \ |
| 1186 | (const __v4di *)__m, (__v4si)__i, \ |
| 1187 | (__v4di)_mm256_set1_epi64x(-1), (s)); }) |
| 1188 | |
| 1189 | #define _mm_i64gather_epi64(m, i, s) __extension__ ({ \ |
| 1190 | int const *__m = (m); \ |
| 1191 | __m128i __i = (i); \ |
| 1192 | (__m128i)__builtin_ia32_gatherq_q((__v2di)_mm_setzero_si128(), \ |
| 1193 | (const __v2di *)__m, (__v2di)__i, \ |
| 1194 | (__v2di)_mm_set1_epi64x(-1), (s)); }) |
| 1195 | |
| 1196 | #define _mm256_i64gather_epi64(m, i, s) __extension__ ({ \ |
| 1197 | int const *__m = (m); \ |
| 1198 | __m256i __i = (i); \ |
| 1199 | (__m256i)__builtin_ia32_gatherq_q256((__v4di)_mm256_setzero_si256(), \ |
| 1200 | (const __v4di *)__m, (__v4di)__i, \ |
| 1201 | (__v4di)_mm256_set1_epi64x(-1), (s)); }) |