Benjamin Kramer | 0930b6e | 2010-08-20 16:47:17 +0000 | [diff] [blame] | 1 | /*===---- emmintrin.h - SSE2 intrinsics ------------------------------------=== |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 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 | */ |
Benjamin Kramer | 0930b6e | 2010-08-20 16:47:17 +0000 | [diff] [blame] | 23 | |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 24 | #ifndef __EMMINTRIN_H |
| 25 | #define __EMMINTRIN_H |
| 26 | |
| 27 | #ifndef __SSE2__ |
| 28 | #error "SSE2 instruction set not enabled" |
| 29 | #else |
| 30 | |
| 31 | #include <xmmintrin.h> |
| 32 | |
| 33 | typedef double __m128d __attribute__((__vector_size__(16))); |
| 34 | typedef long long __m128i __attribute__((__vector_size__(16))); |
| 35 | |
Eric Christopher | faf9404 | 2010-08-26 02:09:25 +0000 | [diff] [blame] | 36 | /* Type defines. */ |
| 37 | typedef double __v2df __attribute__ ((__vector_size__ (16))); |
| 38 | typedef long long __v2di __attribute__ ((__vector_size__ (16))); |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 39 | typedef short __v8hi __attribute__((__vector_size__(16))); |
Anders Carlsson | 4bf4e30 | 2009-09-18 19:18:19 +0000 | [diff] [blame] | 40 | typedef char __v16qi __attribute__((__vector_size__(16))); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 41 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 42 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 43 | _mm_add_sd(__m128d a, __m128d b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 44 | { |
Eli Friedman | 80c8004 | 2009-06-06 02:13:04 +0000 | [diff] [blame] | 45 | a[0] += b[0]; |
| 46 | return a; |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 47 | } |
| 48 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 49 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 50 | _mm_add_pd(__m128d a, __m128d b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 51 | { |
| 52 | return a + b; |
| 53 | } |
| 54 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 55 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 56 | _mm_sub_sd(__m128d a, __m128d b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 57 | { |
Eli Friedman | 80c8004 | 2009-06-06 02:13:04 +0000 | [diff] [blame] | 58 | a[0] -= b[0]; |
| 59 | return a; |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 60 | } |
| 61 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 62 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 63 | _mm_sub_pd(__m128d a, __m128d b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 64 | { |
| 65 | return a - b; |
| 66 | } |
| 67 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 68 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 69 | _mm_mul_sd(__m128d a, __m128d b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 70 | { |
Eli Friedman | 80c8004 | 2009-06-06 02:13:04 +0000 | [diff] [blame] | 71 | a[0] *= b[0]; |
| 72 | return a; |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 73 | } |
| 74 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 75 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 76 | _mm_mul_pd(__m128d a, __m128d b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 77 | { |
| 78 | return a * b; |
| 79 | } |
| 80 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 81 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 82 | _mm_div_sd(__m128d a, __m128d b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 83 | { |
Eli Friedman | 80c8004 | 2009-06-06 02:13:04 +0000 | [diff] [blame] | 84 | a[0] /= b[0]; |
| 85 | return a; |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 86 | } |
| 87 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 88 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 89 | _mm_div_pd(__m128d a, __m128d b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 90 | { |
| 91 | return a / b; |
| 92 | } |
| 93 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 94 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 95 | _mm_sqrt_sd(__m128d a, __m128d b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 96 | { |
| 97 | __m128d c = __builtin_ia32_sqrtsd(b); |
| 98 | return (__m128d) { c[0], a[1] }; |
| 99 | } |
| 100 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 101 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 102 | _mm_sqrt_pd(__m128d a) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 103 | { |
| 104 | return __builtin_ia32_sqrtpd(a); |
| 105 | } |
| 106 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 107 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 108 | _mm_min_sd(__m128d a, __m128d b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 109 | { |
| 110 | return __builtin_ia32_minsd(a, b); |
| 111 | } |
| 112 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 113 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 114 | _mm_min_pd(__m128d a, __m128d b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 115 | { |
| 116 | return __builtin_ia32_minpd(a, b); |
| 117 | } |
| 118 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 119 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 120 | _mm_max_sd(__m128d a, __m128d b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 121 | { |
| 122 | return __builtin_ia32_maxsd(a, b); |
| 123 | } |
| 124 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 125 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 126 | _mm_max_pd(__m128d a, __m128d b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 127 | { |
| 128 | return __builtin_ia32_maxpd(a, b); |
| 129 | } |
| 130 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 131 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 132 | _mm_and_pd(__m128d a, __m128d b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 133 | { |
Eli Friedman | 17d2e3a | 2009-06-06 03:45:06 +0000 | [diff] [blame] | 134 | return (__m128d)((__v4si)a & (__v4si)b); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 135 | } |
| 136 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 137 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 138 | _mm_andnot_pd(__m128d a, __m128d b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 139 | { |
Eli Friedman | 17d2e3a | 2009-06-06 03:45:06 +0000 | [diff] [blame] | 140 | return (__m128d)(~(__v4si)a & (__v4si)b); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 141 | } |
| 142 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 143 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 144 | _mm_or_pd(__m128d a, __m128d b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 145 | { |
Eli Friedman | 17d2e3a | 2009-06-06 03:45:06 +0000 | [diff] [blame] | 146 | return (__m128d)((__v4si)a | (__v4si)b); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 147 | } |
| 148 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 149 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 150 | _mm_xor_pd(__m128d a, __m128d b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 151 | { |
Eli Friedman | 17d2e3a | 2009-06-06 03:45:06 +0000 | [diff] [blame] | 152 | return (__m128d)((__v4si)a ^ (__v4si)b); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 153 | } |
| 154 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 155 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 156 | _mm_cmpeq_pd(__m128d a, __m128d b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 157 | { |
Anders Carlsson | 79dcf5f | 2009-05-18 19:16:46 +0000 | [diff] [blame] | 158 | return (__m128d)__builtin_ia32_cmppd(a, b, 0); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 159 | } |
| 160 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 161 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 162 | _mm_cmplt_pd(__m128d a, __m128d b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 163 | { |
Anders Carlsson | 79dcf5f | 2009-05-18 19:16:46 +0000 | [diff] [blame] | 164 | return (__m128d)__builtin_ia32_cmppd(a, b, 1); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 165 | } |
| 166 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 167 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 168 | _mm_cmple_pd(__m128d a, __m128d b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 169 | { |
Anders Carlsson | 79dcf5f | 2009-05-18 19:16:46 +0000 | [diff] [blame] | 170 | return (__m128d)__builtin_ia32_cmppd(a, b, 2); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 171 | } |
| 172 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 173 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 174 | _mm_cmpgt_pd(__m128d a, __m128d b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 175 | { |
Anders Carlsson | 79dcf5f | 2009-05-18 19:16:46 +0000 | [diff] [blame] | 176 | return (__m128d)__builtin_ia32_cmppd(b, a, 1); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 177 | } |
| 178 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 179 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 180 | _mm_cmpge_pd(__m128d a, __m128d b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 181 | { |
Anders Carlsson | 79dcf5f | 2009-05-18 19:16:46 +0000 | [diff] [blame] | 182 | return (__m128d)__builtin_ia32_cmppd(b, a, 2); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 183 | } |
| 184 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 185 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 186 | _mm_cmpord_pd(__m128d a, __m128d b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 187 | { |
Anders Carlsson | 79dcf5f | 2009-05-18 19:16:46 +0000 | [diff] [blame] | 188 | return (__m128d)__builtin_ia32_cmppd(a, b, 7); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 189 | } |
| 190 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 191 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 192 | _mm_cmpunord_pd(__m128d a, __m128d b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 193 | { |
Anders Carlsson | 79dcf5f | 2009-05-18 19:16:46 +0000 | [diff] [blame] | 194 | return (__m128d)__builtin_ia32_cmppd(a, b, 3); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 195 | } |
| 196 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 197 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 198 | _mm_cmpneq_pd(__m128d a, __m128d b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 199 | { |
Anders Carlsson | 79dcf5f | 2009-05-18 19:16:46 +0000 | [diff] [blame] | 200 | return (__m128d)__builtin_ia32_cmppd(a, b, 4); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 201 | } |
| 202 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 203 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 204 | _mm_cmpnlt_pd(__m128d a, __m128d b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 205 | { |
Anders Carlsson | 79dcf5f | 2009-05-18 19:16:46 +0000 | [diff] [blame] | 206 | return (__m128d)__builtin_ia32_cmppd(a, b, 5); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 207 | } |
| 208 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 209 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 210 | _mm_cmpnle_pd(__m128d a, __m128d b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 211 | { |
Anders Carlsson | 79dcf5f | 2009-05-18 19:16:46 +0000 | [diff] [blame] | 212 | return (__m128d)__builtin_ia32_cmppd(a, b, 6); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 213 | } |
| 214 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 215 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 216 | _mm_cmpngt_pd(__m128d a, __m128d b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 217 | { |
Anders Carlsson | 79dcf5f | 2009-05-18 19:16:46 +0000 | [diff] [blame] | 218 | return (__m128d)__builtin_ia32_cmppd(b, a, 5); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 219 | } |
| 220 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 221 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 222 | _mm_cmpnge_pd(__m128d a, __m128d b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 223 | { |
Anders Carlsson | 79dcf5f | 2009-05-18 19:16:46 +0000 | [diff] [blame] | 224 | return (__m128d)__builtin_ia32_cmppd(b, a, 6); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 225 | } |
| 226 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 227 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 228 | _mm_cmpeq_sd(__m128d a, __m128d b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 229 | { |
Anders Carlsson | 79dcf5f | 2009-05-18 19:16:46 +0000 | [diff] [blame] | 230 | return (__m128d)__builtin_ia32_cmpsd(a, b, 0); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 231 | } |
| 232 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 233 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 234 | _mm_cmplt_sd(__m128d a, __m128d b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 235 | { |
Anders Carlsson | 79dcf5f | 2009-05-18 19:16:46 +0000 | [diff] [blame] | 236 | return (__m128d)__builtin_ia32_cmpsd(a, b, 1); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 237 | } |
| 238 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 239 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 240 | _mm_cmple_sd(__m128d a, __m128d b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 241 | { |
Anders Carlsson | 79dcf5f | 2009-05-18 19:16:46 +0000 | [diff] [blame] | 242 | return (__m128d)__builtin_ia32_cmpsd(a, b, 2); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 243 | } |
| 244 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 245 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 246 | _mm_cmpgt_sd(__m128d a, __m128d b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 247 | { |
Anders Carlsson | 79dcf5f | 2009-05-18 19:16:46 +0000 | [diff] [blame] | 248 | return (__m128d)__builtin_ia32_cmpsd(b, a, 1); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 249 | } |
| 250 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 251 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 252 | _mm_cmpge_sd(__m128d a, __m128d b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 253 | { |
Anders Carlsson | 79dcf5f | 2009-05-18 19:16:46 +0000 | [diff] [blame] | 254 | return (__m128d)__builtin_ia32_cmpsd(b, a, 2); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 255 | } |
| 256 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 257 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 258 | _mm_cmpord_sd(__m128d a, __m128d b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 259 | { |
Anders Carlsson | 79dcf5f | 2009-05-18 19:16:46 +0000 | [diff] [blame] | 260 | return (__m128d)__builtin_ia32_cmpsd(a, b, 7); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 261 | } |
| 262 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 263 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 264 | _mm_cmpunord_sd(__m128d a, __m128d b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 265 | { |
Anders Carlsson | 79dcf5f | 2009-05-18 19:16:46 +0000 | [diff] [blame] | 266 | return (__m128d)__builtin_ia32_cmpsd(a, b, 3); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 267 | } |
| 268 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 269 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 270 | _mm_cmpneq_sd(__m128d a, __m128d b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 271 | { |
Anders Carlsson | 79dcf5f | 2009-05-18 19:16:46 +0000 | [diff] [blame] | 272 | return (__m128d)__builtin_ia32_cmpsd(a, b, 4); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 273 | } |
| 274 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 275 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 276 | _mm_cmpnlt_sd(__m128d a, __m128d b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 277 | { |
Anders Carlsson | 79dcf5f | 2009-05-18 19:16:46 +0000 | [diff] [blame] | 278 | return (__m128d)__builtin_ia32_cmpsd(a, b, 5); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 279 | } |
| 280 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 281 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 282 | _mm_cmpnle_sd(__m128d a, __m128d b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 283 | { |
Anders Carlsson | 79dcf5f | 2009-05-18 19:16:46 +0000 | [diff] [blame] | 284 | return (__m128d)__builtin_ia32_cmpsd(a, b, 6); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 285 | } |
| 286 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 287 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 288 | _mm_cmpngt_sd(__m128d a, __m128d b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 289 | { |
Anders Carlsson | 79dcf5f | 2009-05-18 19:16:46 +0000 | [diff] [blame] | 290 | return (__m128d)__builtin_ia32_cmpsd(b, a, 5); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 291 | } |
| 292 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 293 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 294 | _mm_cmpnge_sd(__m128d a, __m128d b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 295 | { |
Anders Carlsson | 79dcf5f | 2009-05-18 19:16:46 +0000 | [diff] [blame] | 296 | return (__m128d)__builtin_ia32_cmpsd(b, a, 6); |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 297 | } |
| 298 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 299 | static __inline__ int __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 300 | _mm_comieq_sd(__m128d a, __m128d b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 301 | { |
| 302 | return __builtin_ia32_comisdeq(a, b); |
| 303 | } |
| 304 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 305 | static __inline__ int __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 306 | _mm_comilt_sd(__m128d a, __m128d b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 307 | { |
| 308 | return __builtin_ia32_comisdlt(a, b); |
| 309 | } |
| 310 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 311 | static __inline__ int __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 312 | _mm_comile_sd(__m128d a, __m128d b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 313 | { |
| 314 | return __builtin_ia32_comisdle(a, b); |
| 315 | } |
| 316 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 317 | static __inline__ int __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 318 | _mm_comigt_sd(__m128d a, __m128d b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 319 | { |
| 320 | return __builtin_ia32_comisdgt(a, b); |
| 321 | } |
| 322 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 323 | static __inline__ int __attribute__((__always_inline__, __nodebug__)) |
Eli Friedman | 8052a4f | 2011-10-06 20:31:50 +0000 | [diff] [blame] | 324 | _mm_comige_sd(__m128d a, __m128d b) |
| 325 | { |
| 326 | return __builtin_ia32_comisdge(a, b); |
| 327 | } |
| 328 | |
| 329 | static __inline__ int __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 330 | _mm_comineq_sd(__m128d a, __m128d b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 331 | { |
| 332 | return __builtin_ia32_comisdneq(a, b); |
| 333 | } |
| 334 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 335 | static __inline__ int __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 336 | _mm_ucomieq_sd(__m128d a, __m128d b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 337 | { |
| 338 | return __builtin_ia32_ucomisdeq(a, b); |
| 339 | } |
| 340 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 341 | static __inline__ int __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 342 | _mm_ucomilt_sd(__m128d a, __m128d b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 343 | { |
| 344 | return __builtin_ia32_ucomisdlt(a, b); |
| 345 | } |
| 346 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 347 | static __inline__ int __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 348 | _mm_ucomile_sd(__m128d a, __m128d b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 349 | { |
| 350 | return __builtin_ia32_ucomisdle(a, b); |
| 351 | } |
| 352 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 353 | static __inline__ int __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 354 | _mm_ucomigt_sd(__m128d a, __m128d b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 355 | { |
| 356 | return __builtin_ia32_ucomisdgt(a, b); |
| 357 | } |
| 358 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 359 | static __inline__ int __attribute__((__always_inline__, __nodebug__)) |
Eli Friedman | ef534ce | 2011-08-29 21:26:24 +0000 | [diff] [blame] | 360 | _mm_ucomige_sd(__m128d a, __m128d b) |
| 361 | { |
| 362 | return __builtin_ia32_ucomisdge(a, b); |
| 363 | } |
| 364 | |
| 365 | static __inline__ int __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 366 | _mm_ucomineq_sd(__m128d a, __m128d b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 367 | { |
| 368 | return __builtin_ia32_ucomisdneq(a, b); |
| 369 | } |
| 370 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 371 | static __inline__ __m128 __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 372 | _mm_cvtpd_ps(__m128d a) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 373 | { |
| 374 | return __builtin_ia32_cvtpd2ps(a); |
| 375 | } |
| 376 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 377 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 378 | _mm_cvtps_pd(__m128 a) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 379 | { |
| 380 | return __builtin_ia32_cvtps2pd(a); |
| 381 | } |
| 382 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 383 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 384 | _mm_cvtepi32_pd(__m128i a) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 385 | { |
| 386 | return __builtin_ia32_cvtdq2pd((__v4si)a); |
| 387 | } |
| 388 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 389 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 390 | _mm_cvtpd_epi32(__m128d a) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 391 | { |
| 392 | return __builtin_ia32_cvtpd2dq(a); |
| 393 | } |
| 394 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 395 | static __inline__ int __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 396 | _mm_cvtsd_si32(__m128d a) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 397 | { |
| 398 | return __builtin_ia32_cvtsd2si(a); |
| 399 | } |
| 400 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 401 | static __inline__ __m128 __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 402 | _mm_cvtsd_ss(__m128 a, __m128d b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 403 | { |
Eli Friedman | 80c8004 | 2009-06-06 02:13:04 +0000 | [diff] [blame] | 404 | a[0] = b[0]; |
| 405 | return a; |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 406 | } |
| 407 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 408 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 409 | _mm_cvtsi32_sd(__m128d a, int b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 410 | { |
Eli Friedman | 098136a | 2009-06-06 08:08:06 +0000 | [diff] [blame] | 411 | a[0] = b; |
| 412 | return a; |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 413 | } |
| 414 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 415 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 416 | _mm_cvtss_sd(__m128d a, __m128 b) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 417 | { |
Eli Friedman | 80c8004 | 2009-06-06 02:13:04 +0000 | [diff] [blame] | 418 | a[0] = b[0]; |
| 419 | return a; |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 420 | } |
| 421 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 422 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 423 | _mm_cvttpd_epi32(__m128d a) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 424 | { |
| 425 | return (__m128i)__builtin_ia32_cvttpd2dq(a); |
| 426 | } |
| 427 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 428 | static __inline__ int __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 429 | _mm_cvttsd_si32(__m128d a) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 430 | { |
Eli Friedman | 80c8004 | 2009-06-06 02:13:04 +0000 | [diff] [blame] | 431 | return a[0]; |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 432 | } |
| 433 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 434 | static __inline__ __m64 __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 435 | _mm_cvtpd_pi32(__m128d a) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 436 | { |
| 437 | return (__m64)__builtin_ia32_cvtpd2pi(a); |
| 438 | } |
| 439 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 440 | static __inline__ __m64 __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 441 | _mm_cvttpd_pi32(__m128d a) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 442 | { |
| 443 | return (__m64)__builtin_ia32_cvttpd2pi(a); |
| 444 | } |
| 445 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 446 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 447 | _mm_cvtpi32_pd(__m64 a) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 448 | { |
| 449 | return __builtin_ia32_cvtpi2pd((__v2si)a); |
| 450 | } |
| 451 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 452 | static __inline__ double __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 453 | _mm_cvtsd_f64(__m128d a) |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 454 | { |
| 455 | return a[0]; |
| 456 | } |
| 457 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 458 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 459 | _mm_load_pd(double const *dp) |
Anders Carlsson | 445afa0 | 2008-12-24 02:11:54 +0000 | [diff] [blame] | 460 | { |
| 461 | return *(__m128d*)dp; |
| 462 | } |
| 463 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 464 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 465 | _mm_load1_pd(double const *dp) |
Anders Carlsson | 445afa0 | 2008-12-24 02:11:54 +0000 | [diff] [blame] | 466 | { |
Eli Friedman | 7c06f6b | 2011-09-15 23:15:27 +0000 | [diff] [blame] | 467 | struct __mm_load1_pd_struct { |
| 468 | double u; |
| 469 | } __attribute__((__packed__, __may_alias__)); |
| 470 | double u = ((struct __mm_load1_pd_struct*)dp)->u; |
| 471 | return (__m128d){ u, u }; |
Anders Carlsson | 445afa0 | 2008-12-24 02:11:54 +0000 | [diff] [blame] | 472 | } |
| 473 | |
Eli Friedman | db7351a | 2009-06-02 05:55:48 +0000 | [diff] [blame] | 474 | #define _mm_load_pd1(dp) _mm_load1_pd(dp) |
| 475 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 476 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 477 | _mm_loadr_pd(double const *dp) |
Anders Carlsson | 445afa0 | 2008-12-24 02:11:54 +0000 | [diff] [blame] | 478 | { |
Eli Friedman | 7c06f6b | 2011-09-15 23:15:27 +0000 | [diff] [blame] | 479 | __m128d u = *(__m128d*)dp; |
| 480 | return __builtin_shufflevector(u, u, 1, 0); |
Anders Carlsson | 445afa0 | 2008-12-24 02:11:54 +0000 | [diff] [blame] | 481 | } |
| 482 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 483 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 484 | _mm_loadu_pd(double const *dp) |
Anders Carlsson | 445afa0 | 2008-12-24 02:11:54 +0000 | [diff] [blame] | 485 | { |
Bill Wendling | eed92a1 | 2011-05-13 00:11:39 +0000 | [diff] [blame] | 486 | struct __loadu_pd { |
| 487 | __m128d v; |
Bill Wendling | 8e3ec9c | 2011-05-13 01:24:00 +0000 | [diff] [blame] | 488 | } __attribute__((packed, may_alias)); |
Bill Wendling | eed92a1 | 2011-05-13 00:11:39 +0000 | [diff] [blame] | 489 | return ((struct __loadu_pd*)dp)->v; |
Anders Carlsson | 445afa0 | 2008-12-24 02:11:54 +0000 | [diff] [blame] | 490 | } |
| 491 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 492 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 493 | _mm_load_sd(double const *dp) |
Anders Carlsson | 445afa0 | 2008-12-24 02:11:54 +0000 | [diff] [blame] | 494 | { |
Eli Friedman | 7c06f6b | 2011-09-15 23:15:27 +0000 | [diff] [blame] | 495 | struct __mm_load_sd_struct { |
| 496 | double u; |
| 497 | } __attribute__((__packed__, __may_alias__)); |
| 498 | double u = ((struct __mm_load_sd_struct*)dp)->u; |
| 499 | return (__m128d){ u, 0 }; |
Anders Carlsson | 445afa0 | 2008-12-24 02:11:54 +0000 | [diff] [blame] | 500 | } |
| 501 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 502 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 503 | _mm_loadh_pd(__m128d a, double const *dp) |
Anders Carlsson | 445afa0 | 2008-12-24 02:11:54 +0000 | [diff] [blame] | 504 | { |
Eli Friedman | 7c06f6b | 2011-09-15 23:15:27 +0000 | [diff] [blame] | 505 | struct __mm_loadh_pd_struct { |
| 506 | double u; |
| 507 | } __attribute__((__packed__, __may_alias__)); |
| 508 | double u = ((struct __mm_loadh_pd_struct*)dp)->u; |
| 509 | return (__m128d){ a[0], u }; |
Anders Carlsson | 445afa0 | 2008-12-24 02:11:54 +0000 | [diff] [blame] | 510 | } |
| 511 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 512 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 513 | _mm_loadl_pd(__m128d a, double const *dp) |
Anders Carlsson | 445afa0 | 2008-12-24 02:11:54 +0000 | [diff] [blame] | 514 | { |
Eli Friedman | 7c06f6b | 2011-09-15 23:15:27 +0000 | [diff] [blame] | 515 | struct __mm_loadl_pd_struct { |
| 516 | double u; |
| 517 | } __attribute__((__packed__, __may_alias__)); |
| 518 | double u = ((struct __mm_loadl_pd_struct*)dp)->u; |
| 519 | return (__m128d){ u, a[1] }; |
Anders Carlsson | 445afa0 | 2008-12-24 02:11:54 +0000 | [diff] [blame] | 520 | } |
| 521 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 522 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 523 | _mm_set_sd(double w) |
Anders Carlsson | 445afa0 | 2008-12-24 02:11:54 +0000 | [diff] [blame] | 524 | { |
| 525 | return (__m128d){ w, 0 }; |
| 526 | } |
| 527 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 528 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 529 | _mm_set1_pd(double w) |
Anders Carlsson | 445afa0 | 2008-12-24 02:11:54 +0000 | [diff] [blame] | 530 | { |
| 531 | return (__m128d){ w, w }; |
| 532 | } |
| 533 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 534 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 535 | _mm_set_pd(double w, double x) |
Anders Carlsson | 445afa0 | 2008-12-24 02:11:54 +0000 | [diff] [blame] | 536 | { |
Anders Carlsson | 9436ed5 | 2009-09-18 17:03:55 +0000 | [diff] [blame] | 537 | return (__m128d){ x, w }; |
Anders Carlsson | 445afa0 | 2008-12-24 02:11:54 +0000 | [diff] [blame] | 538 | } |
| 539 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 540 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 541 | _mm_setr_pd(double w, double x) |
Anders Carlsson | 445afa0 | 2008-12-24 02:11:54 +0000 | [diff] [blame] | 542 | { |
Anders Carlsson | 9436ed5 | 2009-09-18 17:03:55 +0000 | [diff] [blame] | 543 | return (__m128d){ w, x }; |
Anders Carlsson | 445afa0 | 2008-12-24 02:11:54 +0000 | [diff] [blame] | 544 | } |
| 545 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 546 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 547 | _mm_setzero_pd(void) |
Anders Carlsson | 445afa0 | 2008-12-24 02:11:54 +0000 | [diff] [blame] | 548 | { |
| 549 | return (__m128d){ 0, 0 }; |
| 550 | } |
| 551 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 552 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 553 | _mm_move_sd(__m128d a, __m128d b) |
Anders Carlsson | 445afa0 | 2008-12-24 02:11:54 +0000 | [diff] [blame] | 554 | { |
| 555 | return (__m128d){ b[0], a[1] }; |
| 556 | } |
| 557 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 558 | static __inline__ void __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 559 | _mm_store_sd(double *dp, __m128d a) |
Anders Carlsson | 445afa0 | 2008-12-24 02:11:54 +0000 | [diff] [blame] | 560 | { |
Eli Friedman | 7c06f6b | 2011-09-15 23:15:27 +0000 | [diff] [blame] | 561 | struct __mm_store_sd_struct { |
| 562 | double u; |
| 563 | } __attribute__((__packed__, __may_alias__)); |
| 564 | ((struct __mm_store_sd_struct*)dp)->u = a[0]; |
Anders Carlsson | 445afa0 | 2008-12-24 02:11:54 +0000 | [diff] [blame] | 565 | } |
| 566 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 567 | static __inline__ void __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 568 | _mm_store1_pd(double *dp, __m128d a) |
Anders Carlsson | 445afa0 | 2008-12-24 02:11:54 +0000 | [diff] [blame] | 569 | { |
Eli Friedman | 7c06f6b | 2011-09-15 23:15:27 +0000 | [diff] [blame] | 570 | struct __mm_store1_pd_struct { |
| 571 | double u[2]; |
| 572 | } __attribute__((__packed__, __may_alias__)); |
| 573 | ((struct __mm_store1_pd_struct*)dp)->u[0] = a[0]; |
| 574 | ((struct __mm_store1_pd_struct*)dp)->u[1] = a[0]; |
Anders Carlsson | 445afa0 | 2008-12-24 02:11:54 +0000 | [diff] [blame] | 575 | } |
| 576 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 577 | static __inline__ void __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 578 | _mm_store_pd(double *dp, __m128d a) |
Anders Carlsson | 445afa0 | 2008-12-24 02:11:54 +0000 | [diff] [blame] | 579 | { |
| 580 | *(__m128d *)dp = a; |
| 581 | } |
| 582 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 583 | static __inline__ void __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 584 | _mm_storeu_pd(double *dp, __m128d a) |
Anders Carlsson | 445afa0 | 2008-12-24 02:11:54 +0000 | [diff] [blame] | 585 | { |
| 586 | __builtin_ia32_storeupd(dp, a); |
| 587 | } |
| 588 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 589 | static __inline__ void __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 590 | _mm_storer_pd(double *dp, __m128d a) |
Anders Carlsson | 445afa0 | 2008-12-24 02:11:54 +0000 | [diff] [blame] | 591 | { |
Eli Friedman | 7c06f6b | 2011-09-15 23:15:27 +0000 | [diff] [blame] | 592 | a = __builtin_shufflevector(a, a, 1, 0); |
| 593 | *(__m128d *)dp = a; |
Anders Carlsson | 445afa0 | 2008-12-24 02:11:54 +0000 | [diff] [blame] | 594 | } |
| 595 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 596 | static __inline__ void __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 597 | _mm_storeh_pd(double *dp, __m128d a) |
Anders Carlsson | 445afa0 | 2008-12-24 02:11:54 +0000 | [diff] [blame] | 598 | { |
Eli Friedman | 7c06f6b | 2011-09-15 23:15:27 +0000 | [diff] [blame] | 599 | struct __mm_storeh_pd_struct { |
| 600 | double u; |
| 601 | } __attribute__((__packed__, __may_alias__)); |
| 602 | ((struct __mm_storeh_pd_struct*)dp)->u = a[1]; |
Anders Carlsson | 445afa0 | 2008-12-24 02:11:54 +0000 | [diff] [blame] | 603 | } |
| 604 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 605 | static __inline__ void __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 606 | _mm_storel_pd(double *dp, __m128d a) |
Anders Carlsson | 445afa0 | 2008-12-24 02:11:54 +0000 | [diff] [blame] | 607 | { |
Eli Friedman | 7c06f6b | 2011-09-15 23:15:27 +0000 | [diff] [blame] | 608 | struct __mm_storeh_pd_struct { |
| 609 | double u; |
| 610 | } __attribute__((__packed__, __may_alias__)); |
| 611 | ((struct __mm_storeh_pd_struct*)dp)->u = a[0]; |
Anders Carlsson | 445afa0 | 2008-12-24 02:11:54 +0000 | [diff] [blame] | 612 | } |
| 613 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 614 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 615 | _mm_add_epi8(__m128i a, __m128i b) |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 616 | { |
| 617 | return (__m128i)((__v16qi)a + (__v16qi)b); |
| 618 | } |
| 619 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 620 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 621 | _mm_add_epi16(__m128i a, __m128i b) |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 622 | { |
| 623 | return (__m128i)((__v8hi)a + (__v8hi)b); |
| 624 | } |
| 625 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 626 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 627 | _mm_add_epi32(__m128i a, __m128i b) |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 628 | { |
| 629 | return (__m128i)((__v4si)a + (__v4si)b); |
| 630 | } |
| 631 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 632 | static __inline__ __m64 __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 633 | _mm_add_si64(__m64 a, __m64 b) |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 634 | { |
| 635 | return a + b; |
| 636 | } |
| 637 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 638 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 639 | _mm_add_epi64(__m128i a, __m128i b) |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 640 | { |
| 641 | return a + b; |
| 642 | } |
| 643 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 644 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 645 | _mm_adds_epi8(__m128i a, __m128i b) |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 646 | { |
| 647 | return (__m128i)__builtin_ia32_paddsb128((__v16qi)a, (__v16qi)b); |
| 648 | } |
| 649 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 650 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 651 | _mm_adds_epi16(__m128i a, __m128i b) |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 652 | { |
| 653 | return (__m128i)__builtin_ia32_paddsw128((__v8hi)a, (__v8hi)b); |
| 654 | } |
| 655 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 656 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 657 | _mm_adds_epu8(__m128i a, __m128i b) |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 658 | { |
| 659 | return (__m128i)__builtin_ia32_paddusb128((__v16qi)a, (__v16qi)b); |
| 660 | } |
| 661 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 662 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 663 | _mm_adds_epu16(__m128i a, __m128i b) |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 664 | { |
| 665 | return (__m128i)__builtin_ia32_paddusw128((__v8hi)a, (__v8hi)b); |
| 666 | } |
| 667 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 668 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 669 | _mm_avg_epu8(__m128i a, __m128i b) |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 670 | { |
| 671 | return (__m128i)__builtin_ia32_pavgb128((__v16qi)a, (__v16qi)b); |
| 672 | } |
| 673 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 674 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 675 | _mm_avg_epu16(__m128i a, __m128i b) |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 676 | { |
| 677 | return (__m128i)__builtin_ia32_pavgw128((__v8hi)a, (__v8hi)b); |
| 678 | } |
| 679 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 680 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 681 | _mm_madd_epi16(__m128i a, __m128i b) |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 682 | { |
| 683 | return (__m128i)__builtin_ia32_pmaddwd128((__v8hi)a, (__v8hi)b); |
| 684 | } |
| 685 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 686 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 687 | _mm_max_epi16(__m128i a, __m128i b) |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 688 | { |
| 689 | return (__m128i)__builtin_ia32_pmaxsw128((__v8hi)a, (__v8hi)b); |
| 690 | } |
| 691 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 692 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 693 | _mm_max_epu8(__m128i a, __m128i b) |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 694 | { |
| 695 | return (__m128i)__builtin_ia32_pmaxub128((__v16qi)a, (__v16qi)b); |
| 696 | } |
| 697 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 698 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 699 | _mm_min_epi16(__m128i a, __m128i b) |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 700 | { |
| 701 | return (__m128i)__builtin_ia32_pminsw128((__v8hi)a, (__v8hi)b); |
| 702 | } |
| 703 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 704 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 705 | _mm_min_epu8(__m128i a, __m128i b) |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 706 | { |
| 707 | return (__m128i)__builtin_ia32_pminub128((__v16qi)a, (__v16qi)b); |
| 708 | } |
| 709 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 710 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 711 | _mm_mulhi_epi16(__m128i a, __m128i b) |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 712 | { |
| 713 | return (__m128i)__builtin_ia32_pmulhw128((__v8hi)a, (__v8hi)b); |
| 714 | } |
| 715 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 716 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 717 | _mm_mulhi_epu16(__m128i a, __m128i b) |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 718 | { |
| 719 | return (__m128i)__builtin_ia32_pmulhuw128((__v8hi)a, (__v8hi)b); |
| 720 | } |
| 721 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 722 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 723 | _mm_mullo_epi16(__m128i a, __m128i b) |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 724 | { |
Eli Friedman | 098136a | 2009-06-06 08:08:06 +0000 | [diff] [blame] | 725 | return (__m128i)((__v8hi)a * (__v8hi)b); |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 726 | } |
| 727 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 728 | static __inline__ __m64 __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 729 | _mm_mul_su32(__m64 a, __m64 b) |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 730 | { |
| 731 | return __builtin_ia32_pmuludq((__v2si)a, (__v2si)b); |
| 732 | } |
| 733 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 734 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 735 | _mm_mul_epu32(__m128i a, __m128i b) |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 736 | { |
| 737 | return __builtin_ia32_pmuludq128((__v4si)a, (__v4si)b); |
| 738 | } |
| 739 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 740 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Anders Carlsson | ae8ecdd | 2009-04-06 21:55:22 +0000 | [diff] [blame] | 741 | _mm_sad_epu8(__m128i a, __m128i b) |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 742 | { |
| 743 | return __builtin_ia32_psadbw128((__v16qi)a, (__v16qi)b); |
| 744 | } |
| 745 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 746 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 747 | _mm_sub_epi8(__m128i a, __m128i b) |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 748 | { |
| 749 | return (__m128i)((__v16qi)a - (__v16qi)b); |
| 750 | } |
| 751 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 752 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 753 | _mm_sub_epi16(__m128i a, __m128i b) |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 754 | { |
| 755 | return (__m128i)((__v8hi)a - (__v8hi)b); |
| 756 | } |
| 757 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 758 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 759 | _mm_sub_epi32(__m128i a, __m128i b) |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 760 | { |
| 761 | return (__m128i)((__v4si)a - (__v4si)b); |
| 762 | } |
| 763 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 764 | static __inline__ __m64 __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 765 | _mm_sub_si64(__m64 a, __m64 b) |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 766 | { |
| 767 | return a - b; |
| 768 | } |
| 769 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 770 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 771 | _mm_sub_epi64(__m128i a, __m128i b) |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 772 | { |
| 773 | return a - b; |
| 774 | } |
| 775 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 776 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 777 | _mm_subs_epi8(__m128i a, __m128i b) |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 778 | { |
| 779 | return (__m128i)__builtin_ia32_psubsb128((__v16qi)a, (__v16qi)b); |
| 780 | } |
| 781 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 782 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 783 | _mm_subs_epi16(__m128i a, __m128i b) |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 784 | { |
| 785 | return (__m128i)__builtin_ia32_psubsw128((__v8hi)a, (__v8hi)b); |
| 786 | } |
| 787 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 788 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 789 | _mm_subs_epu8(__m128i a, __m128i b) |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 790 | { |
| 791 | return (__m128i)__builtin_ia32_psubusb128((__v16qi)a, (__v16qi)b); |
| 792 | } |
| 793 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 794 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 795 | _mm_subs_epu16(__m128i a, __m128i b) |
Anders Carlsson | 07603aa | 2008-12-24 02:41:00 +0000 | [diff] [blame] | 796 | { |
| 797 | return (__m128i)__builtin_ia32_psubusw128((__v8hi)a, (__v8hi)b); |
| 798 | } |
| 799 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 800 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 801 | _mm_and_si128(__m128i a, __m128i b) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 802 | { |
Eli Friedman | 80c8004 | 2009-06-06 02:13:04 +0000 | [diff] [blame] | 803 | return a & b; |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 804 | } |
| 805 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 806 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 807 | _mm_andnot_si128(__m128i a, __m128i b) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 808 | { |
Eli Friedman | 80c8004 | 2009-06-06 02:13:04 +0000 | [diff] [blame] | 809 | return ~a & b; |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 810 | } |
| 811 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 812 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 813 | _mm_or_si128(__m128i a, __m128i b) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 814 | { |
Eli Friedman | 80c8004 | 2009-06-06 02:13:04 +0000 | [diff] [blame] | 815 | return a | b; |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 816 | } |
| 817 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 818 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 819 | _mm_xor_si128(__m128i a, __m128i b) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 820 | { |
Eli Friedman | 80c8004 | 2009-06-06 02:13:04 +0000 | [diff] [blame] | 821 | return a ^ b; |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 822 | } |
| 823 | |
Bob Wilson | 32bae37 | 2011-11-05 06:08:06 +0000 | [diff] [blame] | 824 | #define _mm_slli_si128(a, count) __extension__ ({ \ |
| 825 | __m128i __a = (a); \ |
| 826 | (__m128i)__builtin_ia32_pslldqi128(__a, (count)*8); }) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 827 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 828 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 829 | _mm_slli_epi16(__m128i a, int count) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 830 | { |
| 831 | return (__m128i)__builtin_ia32_psllwi128((__v8hi)a, count); |
| 832 | } |
| 833 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 834 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 835 | _mm_sll_epi16(__m128i a, __m128i count) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 836 | { |
| 837 | return (__m128i)__builtin_ia32_psllw128((__v8hi)a, (__v8hi)count); |
| 838 | } |
| 839 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 840 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 841 | _mm_slli_epi32(__m128i a, int count) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 842 | { |
| 843 | return (__m128i)__builtin_ia32_pslldi128((__v4si)a, count); |
| 844 | } |
| 845 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 846 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 847 | _mm_sll_epi32(__m128i a, __m128i count) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 848 | { |
| 849 | return (__m128i)__builtin_ia32_pslld128((__v4si)a, (__v4si)count); |
| 850 | } |
| 851 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 852 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 853 | _mm_slli_epi64(__m128i a, int count) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 854 | { |
| 855 | return __builtin_ia32_psllqi128(a, count); |
| 856 | } |
| 857 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 858 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 859 | _mm_sll_epi64(__m128i a, __m128i count) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 860 | { |
| 861 | return __builtin_ia32_psllq128(a, count); |
| 862 | } |
| 863 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 864 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 865 | _mm_srai_epi16(__m128i a, int count) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 866 | { |
| 867 | return (__m128i)__builtin_ia32_psrawi128((__v8hi)a, count); |
| 868 | } |
| 869 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 870 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 871 | _mm_sra_epi16(__m128i a, __m128i count) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 872 | { |
| 873 | return (__m128i)__builtin_ia32_psraw128((__v8hi)a, (__v8hi)count); |
| 874 | } |
| 875 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 876 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 877 | _mm_srai_epi32(__m128i a, int count) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 878 | { |
| 879 | return (__m128i)__builtin_ia32_psradi128((__v4si)a, count); |
| 880 | } |
| 881 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 882 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 883 | _mm_sra_epi32(__m128i a, __m128i count) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 884 | { |
| 885 | return (__m128i)__builtin_ia32_psrad128((__v4si)a, (__v4si)count); |
| 886 | } |
| 887 | |
Chris Lattner | fcb0b25 | 2010-10-01 06:58:49 +0000 | [diff] [blame] | 888 | |
Bob Wilson | 32bae37 | 2011-11-05 06:08:06 +0000 | [diff] [blame] | 889 | #define _mm_srli_si128(a, count) __extension__ ({ \ |
| 890 | __m128i __a = (a); \ |
| 891 | (__m128i)__builtin_ia32_psrldqi128(__a, (count)*8); }) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 892 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 893 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 894 | _mm_srli_epi16(__m128i a, int count) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 895 | { |
| 896 | return (__m128i)__builtin_ia32_psrlwi128((__v8hi)a, count); |
| 897 | } |
| 898 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 899 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 900 | _mm_srl_epi16(__m128i a, __m128i count) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 901 | { |
| 902 | return (__m128i)__builtin_ia32_psrlw128((__v8hi)a, (__v8hi)count); |
| 903 | } |
| 904 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 905 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 906 | _mm_srli_epi32(__m128i a, int count) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 907 | { |
| 908 | return (__m128i)__builtin_ia32_psrldi128((__v4si)a, count); |
| 909 | } |
| 910 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 911 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 912 | _mm_srl_epi32(__m128i a, __m128i count) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 913 | { |
| 914 | return (__m128i)__builtin_ia32_psrld128((__v4si)a, (__v4si)count); |
| 915 | } |
| 916 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 917 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 918 | _mm_srli_epi64(__m128i a, int count) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 919 | { |
| 920 | return __builtin_ia32_psrlqi128(a, count); |
| 921 | } |
| 922 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 923 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 924 | _mm_srl_epi64(__m128i a, __m128i count) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 925 | { |
| 926 | return __builtin_ia32_psrlq128(a, count); |
| 927 | } |
| 928 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 929 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 930 | _mm_cmpeq_epi8(__m128i a, __m128i b) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 931 | { |
Eli Friedman | 3a266f2 | 2009-07-22 17:08:01 +0000 | [diff] [blame] | 932 | return (__m128i)((__v16qi)a == (__v16qi)b); |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 933 | } |
| 934 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 935 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 936 | _mm_cmpeq_epi16(__m128i a, __m128i b) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 937 | { |
Eli Friedman | 3a266f2 | 2009-07-22 17:08:01 +0000 | [diff] [blame] | 938 | return (__m128i)((__v8hi)a == (__v8hi)b); |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 939 | } |
| 940 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 941 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 942 | _mm_cmpeq_epi32(__m128i a, __m128i b) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 943 | { |
Eli Friedman | 3a266f2 | 2009-07-22 17:08:01 +0000 | [diff] [blame] | 944 | return (__m128i)((__v4si)a == (__v4si)b); |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 945 | } |
| 946 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 947 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 948 | _mm_cmpgt_epi8(__m128i a, __m128i b) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 949 | { |
Nick Lewycky | 279114c | 2012-02-04 02:16:48 +0000 | [diff] [blame] | 950 | /* This function always performs a signed comparison, but __v16qi is a char |
| 951 | which may be signed or unsigned. */ |
Nick Lewycky | f42f85c | 2012-02-03 23:57:48 +0000 | [diff] [blame] | 952 | typedef signed char __v16qs __attribute__((__vector_size__(16))); |
| 953 | return (__m128i)((__v16qs)a > (__v16qs)b); |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 954 | } |
| 955 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 956 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 957 | _mm_cmpgt_epi16(__m128i a, __m128i b) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 958 | { |
Eli Friedman | 3a266f2 | 2009-07-22 17:08:01 +0000 | [diff] [blame] | 959 | return (__m128i)((__v8hi)a > (__v8hi)b); |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 960 | } |
| 961 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 962 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 963 | _mm_cmpgt_epi32(__m128i a, __m128i b) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 964 | { |
Eli Friedman | 3a266f2 | 2009-07-22 17:08:01 +0000 | [diff] [blame] | 965 | return (__m128i)((__v4si)a > (__v4si)b); |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 966 | } |
| 967 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 968 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 969 | _mm_cmplt_epi8(__m128i a, __m128i b) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 970 | { |
Eli Friedman | 3a266f2 | 2009-07-22 17:08:01 +0000 | [diff] [blame] | 971 | return _mm_cmpgt_epi8(b,a); |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 972 | } |
| 973 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 974 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 975 | _mm_cmplt_epi16(__m128i a, __m128i b) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 976 | { |
Eli Friedman | 3a266f2 | 2009-07-22 17:08:01 +0000 | [diff] [blame] | 977 | return _mm_cmpgt_epi16(b,a); |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 978 | } |
| 979 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 980 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 981 | _mm_cmplt_epi32(__m128i a, __m128i b) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 982 | { |
Eli Friedman | 3a266f2 | 2009-07-22 17:08:01 +0000 | [diff] [blame] | 983 | return _mm_cmpgt_epi32(b,a); |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 984 | } |
| 985 | |
| 986 | #ifdef __x86_64__ |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 987 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 988 | _mm_cvtsi64_sd(__m128d a, long long b) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 989 | { |
Eli Friedman | 80c8004 | 2009-06-06 02:13:04 +0000 | [diff] [blame] | 990 | a[0] = b; |
| 991 | return a; |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 992 | } |
| 993 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 994 | static __inline__ long long __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 995 | _mm_cvtsd_si64(__m128d a) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 996 | { |
| 997 | return __builtin_ia32_cvtsd2si64(a); |
| 998 | } |
| 999 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1000 | static __inline__ long long __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 1001 | _mm_cvttsd_si64(__m128d a) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1002 | { |
Eli Friedman | 80c8004 | 2009-06-06 02:13:04 +0000 | [diff] [blame] | 1003 | return a[0]; |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1004 | } |
| 1005 | #endif |
| 1006 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1007 | static __inline__ __m128 __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 1008 | _mm_cvtepi32_ps(__m128i a) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1009 | { |
| 1010 | return __builtin_ia32_cvtdq2ps((__v4si)a); |
| 1011 | } |
| 1012 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1013 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 1014 | _mm_cvtps_epi32(__m128 a) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1015 | { |
| 1016 | return (__m128i)__builtin_ia32_cvtps2dq(a); |
| 1017 | } |
| 1018 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1019 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 1020 | _mm_cvttps_epi32(__m128 a) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1021 | { |
| 1022 | return (__m128i)__builtin_ia32_cvttps2dq(a); |
| 1023 | } |
| 1024 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1025 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 1026 | _mm_cvtsi32_si128(int a) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1027 | { |
| 1028 | return (__m128i)(__v4si){ a, 0, 0, 0 }; |
| 1029 | } |
| 1030 | |
| 1031 | #ifdef __x86_64__ |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1032 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 1033 | _mm_cvtsi64_si128(long long a) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1034 | { |
| 1035 | return (__m128i){ a, 0 }; |
| 1036 | } |
| 1037 | #endif |
| 1038 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1039 | static __inline__ int __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 1040 | _mm_cvtsi128_si32(__m128i a) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1041 | { |
| 1042 | __v4si b = (__v4si)a; |
| 1043 | return b[0]; |
| 1044 | } |
| 1045 | |
| 1046 | #ifdef __x86_64__ |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1047 | static __inline__ long long __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 1048 | _mm_cvtsi128_si64(__m128i a) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1049 | { |
| 1050 | return a[0]; |
| 1051 | } |
| 1052 | #endif |
| 1053 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1054 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 1055 | _mm_load_si128(__m128i const *p) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1056 | { |
| 1057 | return *p; |
| 1058 | } |
| 1059 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1060 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 1061 | _mm_loadu_si128(__m128i const *p) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1062 | { |
Bill Wendling | eed92a1 | 2011-05-13 00:11:39 +0000 | [diff] [blame] | 1063 | struct __loadu_si128 { |
| 1064 | __m128i v; |
Bill Wendling | 8e3ec9c | 2011-05-13 01:24:00 +0000 | [diff] [blame] | 1065 | } __attribute__((packed, may_alias)); |
Bill Wendling | eed92a1 | 2011-05-13 00:11:39 +0000 | [diff] [blame] | 1066 | return ((struct __loadu_si128*)p)->v; |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1067 | } |
| 1068 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1069 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 1070 | _mm_loadl_epi64(__m128i const *p) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1071 | { |
Eli Friedman | 7c06f6b | 2011-09-15 23:15:27 +0000 | [diff] [blame] | 1072 | struct __mm_loadl_epi64_struct { |
| 1073 | long long u; |
| 1074 | } __attribute__((__packed__, __may_alias__)); |
| 1075 | return (__m128i) { ((struct __mm_loadl_epi64_struct*)p)->u, 0}; |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1076 | } |
| 1077 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1078 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Anders Carlsson | 9436ed5 | 2009-09-18 17:03:55 +0000 | [diff] [blame] | 1079 | _mm_set_epi64x(long long q1, long long q0) |
| 1080 | { |
| 1081 | return (__m128i){ q0, q1 }; |
| 1082 | } |
| 1083 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1084 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 1085 | _mm_set_epi64(__m64 q1, __m64 q0) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1086 | { |
| 1087 | return (__m128i){ (long long)q0, (long long)q1 }; |
| 1088 | } |
| 1089 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1090 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 1091 | _mm_set_epi32(int i3, int i2, int i1, int i0) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1092 | { |
| 1093 | return (__m128i)(__v4si){ i0, i1, i2, i3}; |
| 1094 | } |
| 1095 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1096 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 1097 | _mm_set_epi16(short w7, short w6, short w5, short w4, short w3, short w2, short w1, short w0) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1098 | { |
| 1099 | return (__m128i)(__v8hi){ w0, w1, w2, w3, w4, w5, w6, w7 }; |
| 1100 | } |
| 1101 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1102 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 1103 | _mm_set_epi8(char b15, char b14, char b13, char b12, char b11, char b10, char b9, char b8, char b7, char b6, char b5, char b4, char b3, char b2, char b1, char b0) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1104 | { |
| 1105 | return (__m128i)(__v16qi){ b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15 }; |
| 1106 | } |
| 1107 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1108 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Anders Carlsson | 9436ed5 | 2009-09-18 17:03:55 +0000 | [diff] [blame] | 1109 | _mm_set1_epi64x(long long q) |
| 1110 | { |
| 1111 | return (__m128i){ q, q }; |
| 1112 | } |
| 1113 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1114 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 1115 | _mm_set1_epi64(__m64 q) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1116 | { |
| 1117 | return (__m128i){ (long long)q, (long long)q }; |
| 1118 | } |
| 1119 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1120 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 1121 | _mm_set1_epi32(int i) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1122 | { |
| 1123 | return (__m128i)(__v4si){ i, i, i, i }; |
| 1124 | } |
| 1125 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1126 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 1127 | _mm_set1_epi16(short w) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1128 | { |
| 1129 | return (__m128i)(__v8hi){ w, w, w, w, w, w, w, w }; |
| 1130 | } |
| 1131 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1132 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 1133 | _mm_set1_epi8(char b) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1134 | { |
| 1135 | return (__m128i)(__v16qi){ b, b, b, b, b, b, b, b, b, b, b, b, b, b, b, b }; |
| 1136 | } |
| 1137 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1138 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 1139 | _mm_setr_epi64(__m64 q0, __m64 q1) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1140 | { |
| 1141 | return (__m128i){ (long long)q0, (long long)q1 }; |
| 1142 | } |
| 1143 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1144 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 1145 | _mm_setr_epi32(int i0, int i1, int i2, int i3) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1146 | { |
| 1147 | return (__m128i)(__v4si){ i0, i1, i2, i3}; |
| 1148 | } |
| 1149 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1150 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 1151 | _mm_setr_epi16(short w0, short w1, short w2, short w3, short w4, short w5, short w6, short w7) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1152 | { |
| 1153 | return (__m128i)(__v8hi){ w0, w1, w2, w3, w4, w5, w6, w7 }; |
| 1154 | } |
| 1155 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1156 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 1157 | _mm_setr_epi8(char b0, char b1, char b2, char b3, char b4, char b5, char b6, char b7, char b8, char b9, char b10, char b11, char b12, char b13, char b14, char b15) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1158 | { |
| 1159 | return (__m128i)(__v16qi){ b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15 }; |
| 1160 | } |
| 1161 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1162 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 1163 | _mm_setzero_si128(void) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1164 | { |
| 1165 | return (__m128i){ 0LL, 0LL }; |
| 1166 | } |
| 1167 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1168 | static __inline__ void __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 1169 | _mm_store_si128(__m128i *p, __m128i b) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1170 | { |
| 1171 | *p = b; |
| 1172 | } |
| 1173 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1174 | static __inline__ void __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 1175 | _mm_storeu_si128(__m128i *p, __m128i b) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1176 | { |
| 1177 | __builtin_ia32_storedqu((char *)p, (__v16qi)b); |
| 1178 | } |
| 1179 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1180 | static __inline__ void __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 1181 | _mm_maskmoveu_si128(__m128i d, __m128i n, char *p) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1182 | { |
| 1183 | __builtin_ia32_maskmovdqu((__v16qi)d, (__v16qi)n, p); |
| 1184 | } |
| 1185 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1186 | static __inline__ void __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 1187 | _mm_storel_epi64(__m128i *p, __m128i a) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1188 | { |
| 1189 | __builtin_ia32_storelv4si((__v2si *)p, a); |
| 1190 | } |
| 1191 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1192 | static __inline__ void __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 1193 | _mm_stream_pd(double *p, __m128d a) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1194 | { |
| 1195 | __builtin_ia32_movntpd(p, a); |
| 1196 | } |
| 1197 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1198 | static __inline__ void __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 1199 | _mm_stream_si128(__m128i *p, __m128i a) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1200 | { |
| 1201 | __builtin_ia32_movntdq(p, a); |
| 1202 | } |
| 1203 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1204 | static __inline__ void __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 1205 | _mm_stream_si32(int *p, int a) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1206 | { |
| 1207 | __builtin_ia32_movnti(p, a); |
| 1208 | } |
| 1209 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1210 | static __inline__ void __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 1211 | _mm_clflush(void const *p) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1212 | { |
| 1213 | __builtin_ia32_clflush(p); |
| 1214 | } |
| 1215 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1216 | static __inline__ void __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 1217 | _mm_lfence(void) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1218 | { |
| 1219 | __builtin_ia32_lfence(); |
| 1220 | } |
| 1221 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1222 | static __inline__ void __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 1223 | _mm_mfence(void) |
Anders Carlsson | 0727df0 | 2008-12-25 23:48:58 +0000 | [diff] [blame] | 1224 | { |
| 1225 | __builtin_ia32_mfence(); |
| 1226 | } |
| 1227 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1228 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 1229 | _mm_packs_epi16(__m128i a, __m128i b) |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1230 | { |
| 1231 | return (__m128i)__builtin_ia32_packsswb128((__v8hi)a, (__v8hi)b); |
| 1232 | } |
| 1233 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1234 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 1235 | _mm_packs_epi32(__m128i a, __m128i b) |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1236 | { |
| 1237 | return (__m128i)__builtin_ia32_packssdw128((__v4si)a, (__v4si)b); |
| 1238 | } |
| 1239 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1240 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 1241 | _mm_packus_epi16(__m128i a, __m128i b) |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1242 | { |
| 1243 | return (__m128i)__builtin_ia32_packuswb128((__v8hi)a, (__v8hi)b); |
| 1244 | } |
| 1245 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1246 | static __inline__ int __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 1247 | _mm_extract_epi16(__m128i a, int imm) |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1248 | { |
| 1249 | __v8hi b = (__v8hi)a; |
Chris Lattner | d6b84b9 | 2010-08-20 16:08:33 +0000 | [diff] [blame] | 1250 | return (unsigned short)b[imm]; |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1251 | } |
| 1252 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1253 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 1254 | _mm_insert_epi16(__m128i a, int b, int imm) |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1255 | { |
Eli Friedman | 80c8004 | 2009-06-06 02:13:04 +0000 | [diff] [blame] | 1256 | __v8hi c = (__v8hi)a; |
| 1257 | c[imm & 7] = b; |
Eli Friedman | 17d2e3a | 2009-06-06 03:45:06 +0000 | [diff] [blame] | 1258 | return (__m128i)c; |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1259 | } |
| 1260 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1261 | static __inline__ int __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 1262 | _mm_movemask_epi8(__m128i a) |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1263 | { |
| 1264 | return __builtin_ia32_pmovmskb128((__v16qi)a); |
| 1265 | } |
| 1266 | |
Bob Wilson | 32bae37 | 2011-11-05 06:08:06 +0000 | [diff] [blame] | 1267 | #define _mm_shuffle_epi32(a, imm) __extension__ ({ \ |
| 1268 | __m128i __a = (a); \ |
| 1269 | (__m128i)__builtin_shufflevector((__v4si)__a, (__v4si) _mm_set1_epi32(0), \ |
| 1270 | (imm) & 0x3, ((imm) & 0xc) >> 2, \ |
| 1271 | ((imm) & 0x30) >> 4, ((imm) & 0xc0) >> 6); }) |
Chris Lattner | 85e59d7 | 2011-04-25 20:42:40 +0000 | [diff] [blame] | 1272 | |
Bob Wilson | 32bae37 | 2011-11-05 06:08:06 +0000 | [diff] [blame] | 1273 | #define _mm_shufflelo_epi16(a, imm) __extension__ ({ \ |
| 1274 | __m128i __a = (a); \ |
| 1275 | (__m128i)__builtin_shufflevector((__v8hi)__a, (__v8hi) _mm_set1_epi16(0), \ |
| 1276 | (imm) & 0x3, ((imm) & 0xc) >> 2, \ |
| 1277 | ((imm) & 0x30) >> 4, ((imm) & 0xc0) >> 6, \ |
| 1278 | 4, 5, 6, 7); }) |
Chris Lattner | 85e59d7 | 2011-04-25 20:42:40 +0000 | [diff] [blame] | 1279 | |
Bob Wilson | 32bae37 | 2011-11-05 06:08:06 +0000 | [diff] [blame] | 1280 | #define _mm_shufflehi_epi16(a, imm) __extension__ ({ \ |
| 1281 | __m128i __a = (a); \ |
| 1282 | (__m128i)__builtin_shufflevector((__v8hi)__a, (__v8hi) _mm_set1_epi16(0), \ |
| 1283 | 0, 1, 2, 3, \ |
| 1284 | 4 + (((imm) & 0x03) >> 0), \ |
| 1285 | 4 + (((imm) & 0x0c) >> 2), \ |
| 1286 | 4 + (((imm) & 0x30) >> 4), \ |
| 1287 | 4 + (((imm) & 0xc0) >> 6)); }) |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1288 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1289 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 1290 | _mm_unpackhi_epi8(__m128i a, __m128i b) |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1291 | { |
Anders Carlsson | 92d6686 | 2008-12-26 00:50:47 +0000 | [diff] [blame] | 1292 | return (__m128i)__builtin_shufflevector((__v16qi)a, (__v16qi)b, 8, 16+8, 9, 16+9, 10, 16+10, 11, 16+11, 12, 16+12, 13, 16+13, 14, 16+14, 15, 16+15); |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1293 | } |
| 1294 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1295 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 1296 | _mm_unpackhi_epi16(__m128i a, __m128i b) |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1297 | { |
Anders Carlsson | 92d6686 | 2008-12-26 00:50:47 +0000 | [diff] [blame] | 1298 | return (__m128i)__builtin_shufflevector((__v8hi)a, (__v8hi)b, 4, 8+4, 5, 8+5, 6, 8+6, 7, 8+7); |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1299 | } |
| 1300 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1301 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 1302 | _mm_unpackhi_epi32(__m128i a, __m128i b) |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1303 | { |
Anders Carlsson | 92d6686 | 2008-12-26 00:50:47 +0000 | [diff] [blame] | 1304 | return (__m128i)__builtin_shufflevector((__v4si)a, (__v4si)b, 2, 4+2, 3, 4+3); |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1305 | } |
| 1306 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1307 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 1308 | _mm_unpackhi_epi64(__m128i a, __m128i b) |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1309 | { |
Anders Carlsson | 92d6686 | 2008-12-26 00:50:47 +0000 | [diff] [blame] | 1310 | return (__m128i)__builtin_shufflevector(a, b, 1, 2+1); |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1311 | } |
| 1312 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1313 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 1314 | _mm_unpacklo_epi8(__m128i a, __m128i b) |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1315 | { |
Anders Carlsson | 92d6686 | 2008-12-26 00:50:47 +0000 | [diff] [blame] | 1316 | return (__m128i)__builtin_shufflevector((__v16qi)a, (__v16qi)b, 0, 16+0, 1, 16+1, 2, 16+2, 3, 16+3, 4, 16+4, 5, 16+5, 6, 16+6, 7, 16+7); |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1317 | } |
| 1318 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1319 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 1320 | _mm_unpacklo_epi16(__m128i a, __m128i b) |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1321 | { |
Anders Carlsson | 92d6686 | 2008-12-26 00:50:47 +0000 | [diff] [blame] | 1322 | return (__m128i)__builtin_shufflevector((__v8hi)a, (__v8hi)b, 0, 8+0, 1, 8+1, 2, 8+2, 3, 8+3); |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1323 | } |
| 1324 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1325 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 1326 | _mm_unpacklo_epi32(__m128i a, __m128i b) |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1327 | { |
Anders Carlsson | 92d6686 | 2008-12-26 00:50:47 +0000 | [diff] [blame] | 1328 | return (__m128i)__builtin_shufflevector((__v4si)a, (__v4si)b, 0, 4+0, 1, 4+1); |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1329 | } |
| 1330 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1331 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 1332 | _mm_unpacklo_epi64(__m128i a, __m128i b) |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1333 | { |
Anders Carlsson | 92d6686 | 2008-12-26 00:50:47 +0000 | [diff] [blame] | 1334 | return (__m128i)__builtin_shufflevector(a, b, 0, 2+0); |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1335 | } |
| 1336 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1337 | static __inline__ __m64 __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 1338 | _mm_movepi64_pi64(__m128i a) |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1339 | { |
| 1340 | return (__m64)a[0]; |
| 1341 | } |
| 1342 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1343 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 1344 | _mm_movpi64_pi64(__m64 a) |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1345 | { |
| 1346 | return (__m128i){ (long long)a, 0 }; |
| 1347 | } |
| 1348 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1349 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 1350 | _mm_move_epi64(__m128i a) |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1351 | { |
Eli Friedman | 80c8004 | 2009-06-06 02:13:04 +0000 | [diff] [blame] | 1352 | return __builtin_shufflevector(a, (__m128i){ 0 }, 0, 2); |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1353 | } |
| 1354 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1355 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 1356 | _mm_unpackhi_pd(__m128d a, __m128d b) |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1357 | { |
Anders Carlsson | 92d6686 | 2008-12-26 00:50:47 +0000 | [diff] [blame] | 1358 | return __builtin_shufflevector(a, b, 1, 2+1); |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1359 | } |
| 1360 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1361 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 1362 | _mm_unpacklo_pd(__m128d a, __m128d b) |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1363 | { |
Anders Carlsson | 92d6686 | 2008-12-26 00:50:47 +0000 | [diff] [blame] | 1364 | return __builtin_shufflevector(a, b, 0, 2+0); |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1365 | } |
| 1366 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1367 | static __inline__ int __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 1368 | _mm_movemask_pd(__m128d a) |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1369 | { |
| 1370 | return __builtin_ia32_movmskpd(a); |
| 1371 | } |
| 1372 | |
Bob Wilson | 32bae37 | 2011-11-05 06:08:06 +0000 | [diff] [blame] | 1373 | #define _mm_shuffle_pd(a, b, i) __extension__ ({ \ |
| 1374 | __m128d __a = (a); \ |
| 1375 | __m128d __b = (b); \ |
| 1376 | __builtin_shufflevector(__a, __b, (i) & 1, (((i) & 2) >> 1) + 2); }) |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1377 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1378 | static __inline__ __m128 __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 1379 | _mm_castpd_ps(__m128d in) |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1380 | { |
| 1381 | return (__m128)in; |
| 1382 | } |
| 1383 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1384 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 1385 | _mm_castpd_si128(__m128d in) |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1386 | { |
| 1387 | return (__m128i)in; |
| 1388 | } |
| 1389 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1390 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 1391 | _mm_castps_pd(__m128 in) |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1392 | { |
| 1393 | return (__m128d)in; |
| 1394 | } |
| 1395 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1396 | static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 1397 | _mm_castps_si128(__m128 in) |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1398 | { |
| 1399 | return (__m128i)in; |
| 1400 | } |
| 1401 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1402 | static __inline__ __m128 __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 1403 | _mm_castsi128_ps(__m128i in) |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1404 | { |
| 1405 | return (__m128)in; |
| 1406 | } |
| 1407 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1408 | static __inline__ __m128d __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 1409 | _mm_castsi128_pd(__m128i in) |
Anders Carlsson | 4547075 | 2008-12-26 00:45:50 +0000 | [diff] [blame] | 1410 | { |
| 1411 | return (__m128d)in; |
| 1412 | } |
| 1413 | |
Chris Lattner | 1bddbcb | 2010-03-22 18:14:12 +0000 | [diff] [blame] | 1414 | static __inline__ void __attribute__((__always_inline__, __nodebug__)) |
Mike Stump | dae4413 | 2009-02-13 14:24:50 +0000 | [diff] [blame] | 1415 | _mm_pause(void) |
Anders Carlsson | f1bc660 | 2008-12-26 00:49:43 +0000 | [diff] [blame] | 1416 | { |
Anders Carlsson | 4bcd44d | 2008-12-26 02:22:10 +0000 | [diff] [blame] | 1417 | __asm__ volatile ("pause"); |
Anders Carlsson | f1bc660 | 2008-12-26 00:49:43 +0000 | [diff] [blame] | 1418 | } |
| 1419 | |
Anders Carlsson | bbd1fa2 | 2009-01-21 01:49:39 +0000 | [diff] [blame] | 1420 | #define _MM_SHUFFLE2(x, y) (((x) << 1) | (y)) |
Anders Carlsson | f1bc660 | 2008-12-26 00:49:43 +0000 | [diff] [blame] | 1421 | |
Anders Carlsson | 37f2f00 | 2008-12-24 01:45:22 +0000 | [diff] [blame] | 1422 | #endif /* __SSE2__ */ |
| 1423 | |
| 1424 | #endif /* __EMMINTRIN_H */ |