1 ; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -mcpu=corei7 | FileCheck %s
3 ; Verify that the DAGCombiner correctly folds all the shufflevector pairs
4 ; into a single shuffle operation.
6 define <4 x float> @test1(<4 x float> %a, <4 x float> %b) {
7 %1 = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 4, i32 1, i32 6, i32 3>
8 %2 = shufflevector <4 x float> %b, <4 x float> %1, <4 x i32> <i32 4, i32 1, i32 6, i32 3>
16 define <4 x float> @test2(<4 x float> %a, <4 x float> %b) {
17 %1 = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 0, i32 5, i32 2, i32 7>
18 %2 = shufflevector <4 x float> %b, <4 x float> %1, <4 x i32> <i32 4, i32 5, i32 2, i32 7>
26 define <4 x float> @test3(<4 x float> %a, <4 x float> %b) {
27 %1 = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 0, i32 5, i32 1, i32 7>
28 %2 = shufflevector <4 x float> %b, <4 x float> %1, <4 x i32> <i32 4, i32 6, i32 0, i32 5>
36 define <4 x float> @test4(<4 x float> %a, <4 x float> %b) {
37 %1 = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 2, i32 3, i32 5, i32 5>
38 %2 = shufflevector <4 x float> %b, <4 x float> %1, <4 x i32> <i32 2, i32 3, i32 4, i32 5>
46 define <4 x float> @test5(<4 x float> %a, <4 x float> %b) {
47 %1 = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 4, i32 1, i32 6, i32 3>
48 %2 = shufflevector <4 x float> %b, <4 x float> %1, <4 x i32> <i32 4, i32 5, i32 6, i32 3>
57 define <4 x i32> @test6(<4 x i32> %a, <4 x i32> %b) {
58 %1 = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 4, i32 1, i32 6, i32 3>
59 %2 = shufflevector <4 x i32> %b, <4 x i32> %1, <4 x i32> <i32 4, i32 1, i32 6, i32 3>
67 define <4 x i32> @test7(<4 x i32> %a, <4 x i32> %b) {
68 %1 = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0, i32 5, i32 2, i32 7>
69 %2 = shufflevector <4 x i32> %b, <4 x i32> %1, <4 x i32> <i32 4, i32 5, i32 2, i32 7>
77 define <4 x i32> @test8(<4 x i32> %a, <4 x i32> %b) {
78 %1 = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0, i32 5, i32 1, i32 7>
79 %2 = shufflevector <4 x i32> %b, <4 x i32> %1, <4 x i32> <i32 4, i32 6, i32 0, i32 5>
87 define <4 x i32> @test9(<4 x i32> %a, <4 x i32> %b) {
88 %1 = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 2, i32 3, i32 5, i32 5>
89 %2 = shufflevector <4 x i32> %b, <4 x i32> %1, <4 x i32> <i32 2, i32 3, i32 4, i32 5>
97 define <4 x i32> @test10(<4 x i32> %a, <4 x i32> %b) {
98 %1 = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 4, i32 1, i32 6, i32 3>
99 %2 = shufflevector <4 x i32> %b, <4 x i32> %1, <4 x i32> <i32 4, i32 5, i32 6, i32 3>
102 ; CHECK-LABEL: test10
107 define <4 x float> @test11(<4 x float> %a, <4 x float> %b) {
108 %1 = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 4, i32 1, i32 6, i32 3>
109 %2 = shufflevector <4 x float> %a, <4 x float> %1, <4 x i32> <i32 0, i32 5, i32 2, i32 7>
112 ; CHECK-LABEL: test11
118 define <4 x float> @test12(<4 x float> %a, <4 x float> %b) {
119 %1 = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 0, i32 5, i32 6, i32 7>
120 %2 = shufflevector <4 x float> %a, <4 x float> %1, <4 x i32> <i32 0, i32 5, i32 6, i32 7>
123 ; CHECK-LABEL: test12
128 define <4 x float> @test13(<4 x float> %a, <4 x float> %b) {
129 %1 = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 0, i32 1, i32 4, i32 5>
130 %2 = shufflevector <4 x float> %a, <4 x float> %1, <4 x i32> <i32 0, i32 1, i32 6, i32 7>
133 ; CHECK-LABEL: test13
138 define <4 x float> @test14(<4 x float> %a, <4 x float> %b) {
139 %1 = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 6, i32 7, i32 5, i32 5>
140 %2 = shufflevector <4 x float> %a, <4 x float> %1, <4 x i32> <i32 2, i32 3, i32 4, i32 5>
143 ; CHECK-LABEL: test14
148 define <4 x float> @test15(<4 x float> %a, <4 x float> %b) {
149 %1 = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 4, i32 1, i32 6, i32 7>
150 %2 = shufflevector <4 x float> %a, <4 x float> %1, <4 x i32> <i32 4, i32 1, i32 6, i32 7>
153 ; CHECK-LABEL: test15
158 define <4 x i32> @test16(<4 x i32> %a, <4 x i32> %b) {
159 %1 = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 4, i32 1, i32 6, i32 3>
160 %2 = shufflevector <4 x i32> %a, <4 x i32> %1, <4 x i32> <i32 0, i32 5, i32 2, i32 7>
163 ; CHECK-LABEL: test16
169 define <4 x i32> @test17(<4 x i32> %a, <4 x i32> %b) {
170 %1 = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0, i32 5, i32 6, i32 7>
171 %2 = shufflevector <4 x i32> %a, <4 x i32> %1, <4 x i32> <i32 0, i32 5, i32 6, i32 7>
174 ; CHECK-LABEL: test17
179 define <4 x i32> @test18(<4 x i32> %a, <4 x i32> %b) {
180 %1 = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0, i32 1, i32 4, i32 5>
181 %2 = shufflevector <4 x i32> %a, <4 x i32> %1, <4 x i32> <i32 0, i32 1, i32 6, i32 7>
184 ; CHECK-LABEL: test18
189 define <4 x i32> @test19(<4 x i32> %a, <4 x i32> %b) {
190 %1 = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 6, i32 7, i32 5, i32 5>
191 %2 = shufflevector <4 x i32> %a, <4 x i32> %1, <4 x i32> <i32 2, i32 3, i32 4, i32 5>
194 ; CHECK-LABEL: test19
199 define <4 x i32> @test20(<4 x i32> %a, <4 x i32> %b) {
200 %1 = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 4, i32 1, i32 6, i32 7>
201 %2 = shufflevector <4 x i32> %a, <4 x i32> %1, <4 x i32> <i32 4, i32 1, i32 6, i32 7>
204 ; CHECK-LABEL: test20
209 ; Verify that we correctly fold shuffles even when we use illegal vector types.
210 define <4 x i8> @test1c(<4 x i8>* %a, <4 x i8>* %b) {
211 %A = load <4 x i8>* %a
212 %B = load <4 x i8>* %b
213 %1 = shufflevector <4 x i8> %A, <4 x i8> %B, <4 x i32> <i32 0, i32 5, i32 2, i32 7>
214 %2 = shufflevector <4 x i8> %B, <4 x i8> %1, <4 x i32> <i32 4, i32 5, i32 2, i32 7>
217 ; CHECK-LABEL: test1c
222 define <4 x i8> @test2c(<4 x i8>* %a, <4 x i8>* %b) {
223 %A = load <4 x i8>* %a
224 %B = load <4 x i8>* %b
225 %1 = shufflevector <4 x i8> %A, <4 x i8> %B, <4 x i32> <i32 0, i32 5, i32 1, i32 5>
226 %2 = shufflevector <4 x i8> %B, <4 x i8> %1, <4 x i32> <i32 4, i32 6, i32 0, i32 5>
229 ; CHECK-LABEL: test2c
234 define <4 x i8> @test3c(<4 x i8>* %a, <4 x i8>* %b) {
235 %A = load <4 x i8>* %a
236 %B = load <4 x i8>* %b
237 %1 = shufflevector <4 x i8> %A, <4 x i8> %B, <4 x i32> <i32 2, i32 3, i32 5, i32 5>
238 %2 = shufflevector <4 x i8> %B, <4 x i8> %1, <4 x i32> <i32 2, i32 3, i32 4, i32 5>
241 ; CHECK-LABEL: test3c
246 define <4 x i8> @test4c(<4 x i8>* %a, <4 x i8>* %b) {
247 %A = load <4 x i8>* %a
248 %B = load <4 x i8>* %b
249 %1 = shufflevector <4 x i8> %A, <4 x i8> %B, <4 x i32> <i32 4, i32 1, i32 6, i32 3>
250 %2 = shufflevector <4 x i8> %B, <4 x i8> %1, <4 x i32> <i32 4, i32 5, i32 6, i32 3>
253 ; CHECK-LABEL: test4c