1 ; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -mcpu=corei7 | FileCheck %s
3 ; Verify that we fold shuffles according to rule:
4 ; (shuffle(shuffle A, Undef, M0), B, M1) -> (shuffle A, B, M2)
6 define <4 x float> @test1(<4 x float> %a, <4 x float> %b) {
7 %1 = shufflevector <4 x float> %a, <4 x float> undef, <4 x i32> <i32 4, i32 2, i32 3, i32 1>
8 %2 = shufflevector <4 x float> %1, <4 x float> %b, <4 x i32> <i32 4, i32 5, i32 1, i32 2>
16 define <4 x float> @test2(<4 x float> %a, <4 x float> %b) {
17 %1 = shufflevector <4 x float> %a, <4 x float> undef, <4 x i32> <i32 6, i32 0, i32 1, i32 7>
18 %2 = shufflevector <4 x float> %1, <4 x float> %b, <4 x i32> <i32 1, i32 2, i32 4, i32 5>
26 define <4 x float> @test3(<4 x float> %a, <4 x float> %b) {
27 %1 = shufflevector <4 x float> %a, <4 x float> undef, <4 x i32> <i32 0, i32 5, i32 1, i32 7>
28 %2 = shufflevector <4 x float> %1, <4 x float> %b, <4 x i32> <i32 0, i32 2, i32 4, i32 1>
36 define <4 x float> @test4(<4 x float> %a, <4 x float> %b) {
37 %1 = shufflevector <4 x float> %a, <4 x float> undef, <4 x i32> <i32 2, i32 3, i32 5, i32 5>
38 %2 = shufflevector <4 x float> %1, <4 x float> %b, <4 x i32> <i32 6, i32 7, i32 0, i32 1>
46 define <4 x float> @test5(<4 x float> %a, <4 x float> %b) {
47 %1 = shufflevector <4 x float> %a, <4 x float> undef, <4 x i32> <i32 0, i32 4, i32 1, i32 3>
48 %2 = shufflevector <4 x float> %1, <4 x float> %b, <4 x i32> <i32 0, i32 2, i32 6, i32 7>
56 ; Verify that we fold shuffles according to rule:
57 ; (shuffle(shuffle A, Undef, M0), A, M1) -> (shuffle A, Undef, M2)
59 define <4 x float> @test6(<4 x float> %a) {
60 %1 = shufflevector <4 x float> %a, <4 x float> undef, <4 x i32> <i32 4, i32 2, i32 3, i32 1>
61 %2 = shufflevector <4 x float> %1, <4 x float> %a, <4 x i32> <i32 4, i32 5, i32 1, i32 2>
71 define <4 x float> @test7(<4 x float> %a) {
72 %1 = shufflevector <4 x float> %a, <4 x float> undef, <4 x i32> <i32 6, i32 0, i32 1, i32 7>
73 %2 = shufflevector <4 x float> %1, <4 x float> %a, <4 x i32> <i32 1, i32 2, i32 4, i32 5>
83 define <4 x float> @test8(<4 x float> %a) {
84 %1 = shufflevector <4 x float> %a, <4 x float> undef, <4 x i32> <i32 0, i32 5, i32 1, i32 7>
85 %2 = shufflevector <4 x float> %1, <4 x float> %a, <4 x i32> <i32 0, i32 2, i32 4, i32 1>
95 define <4 x float> @test9(<4 x float> %a) {
96 %1 = shufflevector <4 x float> %a, <4 x float> undef, <4 x i32> <i32 2, i32 3, i32 5, i32 5>
97 %2 = shufflevector <4 x float> %1, <4 x float> %a, <4 x i32> <i32 6, i32 7, i32 0, i32 1>
107 define <4 x float> @test10(<4 x float> %a) {
108 %1 = shufflevector <4 x float> %a, <4 x float> undef, <4 x i32> <i32 0, i32 4, i32 1, i32 3>
109 %2 = shufflevector <4 x float> %1, <4 x float> %a, <4 x i32> <i32 0, i32 2, i32 6, i32 7>
112 ; CHECK-LABEL: test10
119 define <4 x float> @test11(<4 x float> %a, <4 x float> %b) {
120 %1 = shufflevector <4 x float> %a, <4 x float> undef, <4 x i32> <i32 4, i32 2, i32 3, i32 1>
121 %2 = shufflevector <4 x float> %b, <4 x float> %1, <4 x i32> <i32 0, i32 1, i32 5, i32 6>
124 ; CHECK-LABEL: test11
129 define <4 x float> @test12(<4 x float> %a, <4 x float> %b) {
130 %1 = shufflevector <4 x float> %a, <4 x float> undef, <4 x i32> <i32 6, i32 0, i32 1, i32 7>
131 %2 = shufflevector <4 x float> %b, <4 x float> %1, <4 x i32> <i32 5, i32 6, i32 0, i32 1>
134 ; CHECK-LABEL: test12
139 define <4 x float> @test13(<4 x float> %a, <4 x float> %b) {
140 %1 = shufflevector <4 x float> %a, <4 x float> undef, <4 x i32> <i32 0, i32 5, i32 1, i32 7>
141 %2 = shufflevector <4 x float> %b, <4 x float> %1, <4 x i32> <i32 4, i32 5, i32 0, i32 5>
144 ; CHECK-LABEL: test13
149 define <4 x float> @test14(<4 x float> %a, <4 x float> %b) {
150 %1 = shufflevector <4 x float> %a, <4 x float> undef, <4 x i32> <i32 2, i32 3, i32 5, i32 5>
151 %2 = shufflevector <4 x float> %b, <4 x float> %1, <4 x i32> <i32 2, i32 3, i32 4, i32 5>
154 ; CHECK-LABEL: test14
159 define <4 x float> @test15(<4 x float> %a, <4 x float> %b) {
160 %1 = shufflevector <4 x float> %a, <4 x float> undef, <4 x i32> <i32 0, i32 4, i32 1, i32 3>
161 %2 = shufflevector <4 x float> %b, <4 x float> %1, <4 x i32> <i32 4, i32 6, i32 2, i32 3>
164 ; CHECK-LABEL: test15
169 ; Verify that shuffles are canonicalized according to rules:
170 ; shuffle(B, shuffle(A, Undef)) -> shuffle(shuffle(A, Undef), B)
172 ; This allows to trigger the following combine rule:
173 ; (shuffle(shuffle A, Undef, M0), A, M1) -> (shuffle A, Undef, M2)
175 ; As a result, all the shuffle pairs in each function below should be
176 ; combined into a single legal shuffle operation.
178 define <4 x float> @test16(<4 x float> %a) {
179 %1 = shufflevector <4 x float> %a, <4 x float> undef, <4 x i32> <i32 4, i32 2, i32 3, i32 1>
180 %2 = shufflevector <4 x float> %a, <4 x float> %1, <4 x i32> <i32 0, i32 1, i32 5, i32 3>
183 ; CHECK-LABEL: test16
190 define <4 x float> @test17(<4 x float> %a) {
191 %1 = shufflevector <4 x float> %a, <4 x float> undef, <4 x i32> <i32 6, i32 0, i32 1, i32 7>
192 %2 = shufflevector <4 x float> %a, <4 x float> %1, <4 x i32> <i32 5, i32 6, i32 0, i32 1>
195 ; CHECK-LABEL: test17
202 define <4 x float> @test18(<4 x float> %a) {
203 %1 = shufflevector <4 x float> %a, <4 x float> undef, <4 x i32> <i32 0, i32 5, i32 1, i32 7>
204 %2 = shufflevector <4 x float> %a, <4 x float> %1, <4 x i32> <i32 4, i32 6, i32 0, i32 5>
207 ; CHECK-LABEL: test18
214 define <4 x float> @test19(<4 x float> %a) {
215 %1 = shufflevector <4 x float> %a, <4 x float> undef, <4 x i32> <i32 2, i32 3, i32 5, i32 5>
216 %2 = shufflevector <4 x float> %a, <4 x float> %1, <4 x i32> <i32 2, i32 3, i32 4, i32 5>
219 ; CHECK-LABEL: test19
226 define <4 x float> @test20(<4 x float> %a) {
227 %1 = shufflevector <4 x float> %a, <4 x float> undef, <4 x i32> <i32 0, i32 4, i32 1, i32 3>
228 %2 = shufflevector <4 x float> %a, <4 x float> %1, <4 x i32> <i32 4, i32 6, i32 2, i32 3>
231 ; CHECK-LABEL: test20