| Chandler Carruth | bfc6b95 | 2014-09-03 19:39:10 +0000 | [diff] [blame] | 1 | ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -x86-experimental-vector-shuffle-lowering | FileCheck %s --check-prefix=ALL --check-prefix=SSE2 |
| Chandler Carruth | c1e8ebc | 2014-09-03 20:39:06 +0000 | [diff] [blame] | 2 | ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mattr=+sse4.1 -x86-experimental-vector-shuffle-lowering | FileCheck %s --check-prefix=ALL --check-prefix=SSE41 |
| Chandler Carruth | bfc6b95 | 2014-09-03 19:39:10 +0000 | [diff] [blame] | 3 | ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mattr=+avx -x86-experimental-vector-shuffle-lowering | FileCheck %s --check-prefix=ALL --check-prefix=AVX1 |
| Chandler Carruth | 83860cf | 2014-06-27 11:23:44 +0000 | [diff] [blame] | 4 | |
| 5 | target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" |
| 6 | target triple = "x86_64-unknown-unknown" |
| 7 | |
| 8 | define <4 x i32> @shuffle_v4i32_0001(<4 x i32> %a, <4 x i32> %b) { |
| Chandler Carruth | bfc6b95 | 2014-09-03 19:39:10 +0000 | [diff] [blame] | 9 | ; ALL-LABEL: @shuffle_v4i32_0001 |
| 10 | ; ALL: pshufd {{.*}} # xmm0 = xmm0[0,0,0,1] |
| 11 | ; ALL-NEXT: retq |
| Chandler Carruth | 83860cf | 2014-06-27 11:23:44 +0000 | [diff] [blame] | 12 | %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0, i32 0, i32 0, i32 1> |
| 13 | ret <4 x i32> %shuffle |
| 14 | } |
| 15 | define <4 x i32> @shuffle_v4i32_0020(<4 x i32> %a, <4 x i32> %b) { |
| Chandler Carruth | bfc6b95 | 2014-09-03 19:39:10 +0000 | [diff] [blame] | 16 | ; ALL-LABEL: @shuffle_v4i32_0020 |
| 17 | ; ALL: pshufd {{.*}} # xmm0 = xmm0[0,0,2,0] |
| 18 | ; ALL-NEXT: retq |
| Chandler Carruth | 83860cf | 2014-06-27 11:23:44 +0000 | [diff] [blame] | 19 | %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0, i32 0, i32 2, i32 0> |
| 20 | ret <4 x i32> %shuffle |
| 21 | } |
| Chandler Carruth | 2704675 | 2014-08-07 08:11:31 +0000 | [diff] [blame] | 22 | define <4 x i32> @shuffle_v4i32_0112(<4 x i32> %a, <4 x i32> %b) { |
| Chandler Carruth | bfc6b95 | 2014-09-03 19:39:10 +0000 | [diff] [blame] | 23 | ; ALL-LABEL: @shuffle_v4i32_0112 |
| 24 | ; ALL: pshufd {{.*}} # xmm0 = xmm0[0,1,1,2] |
| 25 | ; ALL-NEXT: retq |
| Chandler Carruth | 2704675 | 2014-08-07 08:11:31 +0000 | [diff] [blame] | 26 | %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0, i32 1, i32 1, i32 2> |
| 27 | ret <4 x i32> %shuffle |
| 28 | } |
| Chandler Carruth | 83860cf | 2014-06-27 11:23:44 +0000 | [diff] [blame] | 29 | define <4 x i32> @shuffle_v4i32_0300(<4 x i32> %a, <4 x i32> %b) { |
| Chandler Carruth | bfc6b95 | 2014-09-03 19:39:10 +0000 | [diff] [blame] | 30 | ; ALL-LABEL: @shuffle_v4i32_0300 |
| 31 | ; ALL: pshufd {{.*}} # xmm0 = xmm0[0,3,0,0] |
| 32 | ; ALL-NEXT: retq |
| Chandler Carruth | 83860cf | 2014-06-27 11:23:44 +0000 | [diff] [blame] | 33 | %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0, i32 3, i32 0, i32 0> |
| 34 | ret <4 x i32> %shuffle |
| 35 | } |
| 36 | define <4 x i32> @shuffle_v4i32_1000(<4 x i32> %a, <4 x i32> %b) { |
| Chandler Carruth | bfc6b95 | 2014-09-03 19:39:10 +0000 | [diff] [blame] | 37 | ; ALL-LABEL: @shuffle_v4i32_1000 |
| 38 | ; ALL: pshufd {{.*}} # xmm0 = xmm0[1,0,0,0] |
| 39 | ; ALL-NEXT: retq |
| Chandler Carruth | 83860cf | 2014-06-27 11:23:44 +0000 | [diff] [blame] | 40 | %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 1, i32 0, i32 0, i32 0> |
| 41 | ret <4 x i32> %shuffle |
| 42 | } |
| 43 | define <4 x i32> @shuffle_v4i32_2200(<4 x i32> %a, <4 x i32> %b) { |
| Chandler Carruth | bfc6b95 | 2014-09-03 19:39:10 +0000 | [diff] [blame] | 44 | ; ALL-LABEL: @shuffle_v4i32_2200 |
| 45 | ; ALL: pshufd {{.*}} # xmm0 = xmm0[2,2,0,0] |
| 46 | ; ALL-NEXT: retq |
| Chandler Carruth | 83860cf | 2014-06-27 11:23:44 +0000 | [diff] [blame] | 47 | %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 2, i32 2, i32 0, i32 0> |
| 48 | ret <4 x i32> %shuffle |
| 49 | } |
| 50 | define <4 x i32> @shuffle_v4i32_3330(<4 x i32> %a, <4 x i32> %b) { |
| Chandler Carruth | bfc6b95 | 2014-09-03 19:39:10 +0000 | [diff] [blame] | 51 | ; ALL-LABEL: @shuffle_v4i32_3330 |
| 52 | ; ALL: pshufd {{.*}} # xmm0 = xmm0[3,3,3,0] |
| 53 | ; ALL-NEXT: retq |
| Chandler Carruth | 83860cf | 2014-06-27 11:23:44 +0000 | [diff] [blame] | 54 | %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 3, i32 3, i32 3, i32 0> |
| 55 | ret <4 x i32> %shuffle |
| 56 | } |
| 57 | define <4 x i32> @shuffle_v4i32_3210(<4 x i32> %a, <4 x i32> %b) { |
| Chandler Carruth | bfc6b95 | 2014-09-03 19:39:10 +0000 | [diff] [blame] | 58 | ; ALL-LABEL: @shuffle_v4i32_3210 |
| 59 | ; ALL: pshufd {{.*}} # xmm0 = xmm0[3,2,1,0] |
| 60 | ; ALL-NEXT: retq |
| Chandler Carruth | 83860cf | 2014-06-27 11:23:44 +0000 | [diff] [blame] | 61 | %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 3, i32 2, i32 1, i32 0> |
| 62 | ret <4 x i32> %shuffle |
| 63 | } |
| 64 | |
| Chandler Carruth | 17fd848 | 2014-08-15 03:54:49 +0000 | [diff] [blame] | 65 | define <4 x i32> @shuffle_v4i32_2121(<4 x i32> %a, <4 x i32> %b) { |
| Chandler Carruth | bfc6b95 | 2014-09-03 19:39:10 +0000 | [diff] [blame] | 66 | ; ALL-LABEL: @shuffle_v4i32_2121 |
| 67 | ; ALL: pshufd {{.*}} # xmm0 = xmm0[2,1,2,1] |
| 68 | ; ALL-NEXT: retq |
| Chandler Carruth | 17fd848 | 2014-08-15 03:54:49 +0000 | [diff] [blame] | 69 | %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 2, i32 1, i32 2, i32 1> |
| 70 | ret <4 x i32> %shuffle |
| 71 | } |
| 72 | |
| Chandler Carruth | 83860cf | 2014-06-27 11:23:44 +0000 | [diff] [blame] | 73 | define <4 x float> @shuffle_v4f32_0001(<4 x float> %a, <4 x float> %b) { |
| Chandler Carruth | bfc6b95 | 2014-09-03 19:39:10 +0000 | [diff] [blame] | 74 | ; ALL-LABEL: @shuffle_v4f32_0001 |
| 75 | ; ALL: shufps {{.*}} # xmm0 = xmm0[0,0,0,1] |
| 76 | ; ALL-NEXT: retq |
| Chandler Carruth | 83860cf | 2014-06-27 11:23:44 +0000 | [diff] [blame] | 77 | %shuffle = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 0, i32 0, i32 0, i32 1> |
| 78 | ret <4 x float> %shuffle |
| 79 | } |
| 80 | define <4 x float> @shuffle_v4f32_0020(<4 x float> %a, <4 x float> %b) { |
| Chandler Carruth | bfc6b95 | 2014-09-03 19:39:10 +0000 | [diff] [blame] | 81 | ; ALL-LABEL: @shuffle_v4f32_0020 |
| 82 | ; ALL: shufps {{.*}} # xmm0 = xmm0[0,0,2,0] |
| 83 | ; ALL-NEXT: retq |
| Chandler Carruth | 83860cf | 2014-06-27 11:23:44 +0000 | [diff] [blame] | 84 | %shuffle = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 0, i32 0, i32 2, i32 0> |
| 85 | ret <4 x float> %shuffle |
| 86 | } |
| 87 | define <4 x float> @shuffle_v4f32_0300(<4 x float> %a, <4 x float> %b) { |
| Chandler Carruth | bfc6b95 | 2014-09-03 19:39:10 +0000 | [diff] [blame] | 88 | ; ALL-LABEL: @shuffle_v4f32_0300 |
| 89 | ; ALL: shufps {{.*}} # xmm0 = xmm0[0,3,0,0] |
| 90 | ; ALL-NEXT: retq |
| Chandler Carruth | 83860cf | 2014-06-27 11:23:44 +0000 | [diff] [blame] | 91 | %shuffle = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 0, i32 3, i32 0, i32 0> |
| 92 | ret <4 x float> %shuffle |
| 93 | } |
| 94 | define <4 x float> @shuffle_v4f32_1000(<4 x float> %a, <4 x float> %b) { |
| Chandler Carruth | bfc6b95 | 2014-09-03 19:39:10 +0000 | [diff] [blame] | 95 | ; ALL-LABEL: @shuffle_v4f32_1000 |
| 96 | ; ALL: shufps {{.*}} # xmm0 = xmm0[1,0,0,0] |
| 97 | ; ALL-NEXT: retq |
| Chandler Carruth | 83860cf | 2014-06-27 11:23:44 +0000 | [diff] [blame] | 98 | %shuffle = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 1, i32 0, i32 0, i32 0> |
| 99 | ret <4 x float> %shuffle |
| 100 | } |
| 101 | define <4 x float> @shuffle_v4f32_2200(<4 x float> %a, <4 x float> %b) { |
| Chandler Carruth | bfc6b95 | 2014-09-03 19:39:10 +0000 | [diff] [blame] | 102 | ; ALL-LABEL: @shuffle_v4f32_2200 |
| 103 | ; ALL: shufps {{.*}} # xmm0 = xmm0[2,2,0,0] |
| 104 | ; ALL-NEXT: retq |
| Chandler Carruth | 83860cf | 2014-06-27 11:23:44 +0000 | [diff] [blame] | 105 | %shuffle = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 2, i32 2, i32 0, i32 0> |
| 106 | ret <4 x float> %shuffle |
| 107 | } |
| 108 | define <4 x float> @shuffle_v4f32_3330(<4 x float> %a, <4 x float> %b) { |
| Chandler Carruth | bfc6b95 | 2014-09-03 19:39:10 +0000 | [diff] [blame] | 109 | ; ALL-LABEL: @shuffle_v4f32_3330 |
| 110 | ; ALL: shufps {{.*}} # xmm0 = xmm0[3,3,3,0] |
| 111 | ; ALL-NEXT: retq |
| Chandler Carruth | 83860cf | 2014-06-27 11:23:44 +0000 | [diff] [blame] | 112 | %shuffle = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 3, i32 3, i32 3, i32 0> |
| 113 | ret <4 x float> %shuffle |
| 114 | } |
| 115 | define <4 x float> @shuffle_v4f32_3210(<4 x float> %a, <4 x float> %b) { |
| Chandler Carruth | bfc6b95 | 2014-09-03 19:39:10 +0000 | [diff] [blame] | 116 | ; ALL-LABEL: @shuffle_v4f32_3210 |
| 117 | ; ALL: shufps {{.*}} # xmm0 = xmm0[3,2,1,0] |
| 118 | ; ALL-NEXT: retq |
| Chandler Carruth | 83860cf | 2014-06-27 11:23:44 +0000 | [diff] [blame] | 119 | %shuffle = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 3, i32 2, i32 1, i32 0> |
| 120 | ret <4 x float> %shuffle |
| 121 | } |
| 122 | |
| 123 | define <4 x i32> @shuffle_v4i32_0124(<4 x i32> %a, <4 x i32> %b) { |
| Chandler Carruth | dad5400 | 2014-09-03 22:48:34 +0000 | [diff] [blame^] | 124 | ; SSE2-LABEL: @shuffle_v4i32_0124 |
| 125 | ; SSE2: shufps {{.*}} # xmm1 = xmm1[0,0],xmm0[2,0] |
| 126 | ; SSE2-NEXT: shufps {{.*}} # xmm0 = xmm0[0,1],xmm1[2,0] |
| 127 | ; SSE2-NEXT: retq |
| 128 | ; |
| 129 | ; SSE41-LABEL: @shuffle_v4i32_0124 |
| 130 | ; SSE41: insertps {{.*}} # xmm0 = xmm0[0,1,2],xmm1[0] |
| 131 | ; SSE41-NEXT: retq |
| 132 | ; |
| 133 | ; AVX1-LABEL: @shuffle_v4i32_0124 |
| 134 | ; AVX1: vinsertps {{.*}} # xmm0 = xmm0[0,1,2],xmm1[0] |
| 135 | ; AVX1-NEXT: retq |
| Chandler Carruth | 83860cf | 2014-06-27 11:23:44 +0000 | [diff] [blame] | 136 | %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0, i32 1, i32 2, i32 4> |
| 137 | ret <4 x i32> %shuffle |
| 138 | } |
| 139 | define <4 x i32> @shuffle_v4i32_0142(<4 x i32> %a, <4 x i32> %b) { |
| Chandler Carruth | bfc6b95 | 2014-09-03 19:39:10 +0000 | [diff] [blame] | 140 | ; ALL-LABEL: @shuffle_v4i32_0142 |
| 141 | ; ALL: shufps {{.*}} # xmm1 = xmm1[0,0],xmm0[2,0] |
| 142 | ; ALL-NEXT: shufps {{.*}} # xmm0 = xmm0[0,1],xmm1[0,2] |
| 143 | ; ALL-NEXT: retq |
| Chandler Carruth | 83860cf | 2014-06-27 11:23:44 +0000 | [diff] [blame] | 144 | %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0, i32 1, i32 4, i32 2> |
| 145 | ret <4 x i32> %shuffle |
| 146 | } |
| 147 | define <4 x i32> @shuffle_v4i32_0412(<4 x i32> %a, <4 x i32> %b) { |
| Chandler Carruth | bfc6b95 | 2014-09-03 19:39:10 +0000 | [diff] [blame] | 148 | ; SSE2-LABEL: @shuffle_v4i32_0412 |
| 149 | ; SSE2: shufps {{.*}} # xmm1 = xmm1[0,0],xmm0[0,0] |
| 150 | ; SSE2-NEXT: shufps {{.*}} # xmm1 = xmm1[2,0],xmm0[1,2] |
| 151 | ; SSE2-NEXT: movaps %xmm1, %xmm0 |
| 152 | ; SSE2-NEXT: retq |
| 153 | ; |
| 154 | ; AVX1-LABEL: @shuffle_v4i32_0412 |
| 155 | ; AVX1: vshufps {{.*}} # xmm1 = xmm1[0,0],xmm0[0,0] |
| 156 | ; AVX1-NEXT: vshufps {{.*}} # xmm0 = xmm1[2,0],xmm0[1,2] |
| 157 | ; AVX1-NEXT: retq |
| Chandler Carruth | 83860cf | 2014-06-27 11:23:44 +0000 | [diff] [blame] | 158 | %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0, i32 4, i32 1, i32 2> |
| 159 | ret <4 x i32> %shuffle |
| 160 | } |
| 161 | define <4 x i32> @shuffle_v4i32_4012(<4 x i32> %a, <4 x i32> %b) { |
| Chandler Carruth | bfc6b95 | 2014-09-03 19:39:10 +0000 | [diff] [blame] | 162 | ; SSE2-LABEL: @shuffle_v4i32_4012 |
| 163 | ; SSE2: shufps {{.*}} # xmm1 = xmm1[0,0],xmm0[0,0] |
| 164 | ; SSE2-NEXT: shufps {{.*}} # xmm1 = xmm1[0,2],xmm0[1,2] |
| 165 | ; SSE2-NEXT: movaps %xmm1, %xmm0 |
| 166 | ; SSE2-NEXT: retq |
| 167 | ; |
| 168 | ; AVX1-LABEL: @shuffle_v4i32_4012 |
| 169 | ; AVX1: vshufps {{.*}} # xmm1 = xmm1[0,0],xmm0[0,0] |
| 170 | ; AVX1-NEXT: vshufps {{.*}} # xmm0 = xmm1[0,2],xmm0[1,2] |
| 171 | ; AVX1-NEXT: retq |
| Chandler Carruth | 83860cf | 2014-06-27 11:23:44 +0000 | [diff] [blame] | 172 | %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 4, i32 0, i32 1, i32 2> |
| 173 | ret <4 x i32> %shuffle |
| 174 | } |
| 175 | define <4 x i32> @shuffle_v4i32_0145(<4 x i32> %a, <4 x i32> %b) { |
| Chandler Carruth | bfc6b95 | 2014-09-03 19:39:10 +0000 | [diff] [blame] | 176 | ; ALL-LABEL: @shuffle_v4i32_0145 |
| 177 | ; ALL: punpcklqdq {{.*}} # xmm0 = xmm0[0],xmm1[0] |
| 178 | ; ALL-NEXT: retq |
| Chandler Carruth | 83860cf | 2014-06-27 11:23:44 +0000 | [diff] [blame] | 179 | %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0, i32 1, i32 4, i32 5> |
| 180 | ret <4 x i32> %shuffle |
| 181 | } |
| 182 | define <4 x i32> @shuffle_v4i32_0451(<4 x i32> %a, <4 x i32> %b) { |
| Chandler Carruth | bfc6b95 | 2014-09-03 19:39:10 +0000 | [diff] [blame] | 183 | ; ALL-LABEL: @shuffle_v4i32_0451 |
| 184 | ; ALL: shufps {{.*}} # xmm0 = xmm0[0,1],xmm1[0,1] |
| 185 | ; ALL-NEXT: shufps {{.*}} # xmm0 = xmm0[0,2,3,1] |
| 186 | ; ALL-NEXT: retq |
| Chandler Carruth | 83860cf | 2014-06-27 11:23:44 +0000 | [diff] [blame] | 187 | %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0, i32 4, i32 5, i32 1> |
| 188 | ret <4 x i32> %shuffle |
| 189 | } |
| 190 | define <4 x i32> @shuffle_v4i32_4501(<4 x i32> %a, <4 x i32> %b) { |
| Chandler Carruth | bfc6b95 | 2014-09-03 19:39:10 +0000 | [diff] [blame] | 191 | ; SSE2-LABEL: @shuffle_v4i32_4501 |
| 192 | ; SSE2: punpcklqdq {{.*}} # xmm1 = xmm1[0],xmm0[0] |
| 193 | ; SSE2-NEXT: movdqa %xmm1, %xmm0 |
| 194 | ; SSE2-NEXT: retq |
| 195 | ; |
| 196 | ; AVX1-LABEL: @shuffle_v4i32_4501 |
| 197 | ; AVX1: punpcklqdq {{.*}} # xmm0 = xmm1[0],xmm0[0] |
| 198 | ; AVX1-NEXT: retq |
| Chandler Carruth | 83860cf | 2014-06-27 11:23:44 +0000 | [diff] [blame] | 199 | %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 4, i32 5, i32 0, i32 1> |
| 200 | ret <4 x i32> %shuffle |
| 201 | } |
| 202 | define <4 x i32> @shuffle_v4i32_4015(<4 x i32> %a, <4 x i32> %b) { |
| Chandler Carruth | bfc6b95 | 2014-09-03 19:39:10 +0000 | [diff] [blame] | 203 | ; ALL-LABEL: @shuffle_v4i32_4015 |
| 204 | ; ALL: shufps {{.*}} # xmm0 = xmm0[0,1],xmm1[0,1] |
| 205 | ; ALL-NEXT: shufps {{.*}} # xmm0 = xmm0[2,0,1,3] |
| 206 | ; ALL-NEXT: retq |
| Chandler Carruth | 83860cf | 2014-06-27 11:23:44 +0000 | [diff] [blame] | 207 | %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 4, i32 0, i32 1, i32 5> |
| 208 | ret <4 x i32> %shuffle |
| 209 | } |