]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/CodeGen/X86/combine-vec-shuffle-4.ll
Vendor import of llvm RELEASE_350/final tag r216957 (effectively, 3.5.0 release):
[FreeBSD/FreeBSD.git] / test / CodeGen / X86 / combine-vec-shuffle-4.ll
1 ; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -mcpu=corei7 | FileCheck %s
2
3 ; Verify that we fold shuffles according to rule:
4 ;  (shuffle(shuffle A, Undef, M0), B, M1) -> (shuffle A, B, M2)
5
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>
9   ret <4 x float> %2
10 }
11 ; CHECK-LABEL: test1
12 ; Mask: [4,5,2,3]
13 ; CHECK: movsd
14 ; CHECK: ret
15
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>
19   ret <4 x float> %2
20 }
21 ; CHECK-LABEL: test2
22 ; Mask: [0,1,4,5]
23 ; CHECK: movlhps 
24 ; CHECK: ret
25
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>
29   ret <4 x float> %2
30 }
31 ; CHECK-LABEL: test3
32 ; Mask: [0,1,4,u]
33 ; CHECK: movlhps
34 ; CHECK: ret
35
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>
39   ret <4 x float> %2
40 }
41 ; CHECK-LABEL: test4
42 ; Mask: [6,7,2,3]
43 ; CHECK: movhlps
44 ; CHECK-NEXT: ret
45
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>
49   ret <4 x float> %2
50 }
51 ; CHECK-LABEL: test5
52 ; Mask: [0,1,6,7]
53 ; CHECK: blendps $12
54 ; CHECK: ret
55
56 ; Verify that we fold shuffles according to rule:
57 ;  (shuffle(shuffle A, Undef, M0), A, M1) -> (shuffle A, Undef, M2)
58
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>
62   ret <4 x float> %2
63 }
64 ; CHECK-LABEL: test6
65 ; Mask: [0,1,2,3]
66 ; CHECK-NOT: pshufd
67 ; CHECK-NOT: shufps
68 ; CHECK-NOT: movlhps
69 ; CHECK: ret
70
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>
74   ret <4 x float> %2
75 }
76 ; CHECK-LABEL: test7
77 ; Mask: [0,1,0,1]
78 ; CHECK-NOT: pshufd
79 ; CHECK-NOT: shufps
80 ; CHECK: movlhps 
81 ; CHECK-NEXT: ret
82
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>
86   ret <4 x float> %2
87 }
88 ; CHECK-LABEL: test8
89 ; Mask: [0,1,0,u]
90 ; CHECK-NOT: pshufd
91 ; CHECK-NOT: shufps
92 ; CHECK: movlhps
93 ; CHECK-NEXT: ret
94
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>
98   ret <4 x float> %2
99 }
100 ; CHECK-LABEL: test9
101 ; Mask: [2,3,2,3]
102 ; CHECK-NOT: movlhps
103 ; CHECK-NOT: palignr
104 ; CHECK: movhlps
105 ; CHECK-NEXT: ret
106
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>
110   ret <4 x float> %2
111 }
112 ; CHECK-LABEL: test10
113 ; Mask: [0,1,2,3]
114 ; CHECK-NOT: pshufd
115 ; CHECK-NOT: shufps
116 ; CHECK-NOT: movlhps
117 ; CHECK: ret
118
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>
122   ret <4 x float> %2
123 }
124 ; CHECK-LABEL: test11
125 ; Mask: [4,5,2,3]
126 ; CHECK: movsd
127 ; CHECK: ret
128
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>
132   ret <4 x float> %2
133 }
134 ; CHECK-LABEL: test12
135 ; Mask: [0,1,4,5]
136 ; CHECK: movlhps 
137 ; CHECK: ret
138
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>
142   ret <4 x float> %2
143 }
144 ; CHECK-LABEL: test13
145 ; Mask: [0,1,4,u]
146 ; CHECK: movlhps
147 ; CHECK: ret
148
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>
152   ret <4 x float> %2
153 }
154 ; CHECK-LABEL: test14
155 ; Mask: [6,7,2,3]
156 ; CHECK: movhlps
157 ; CHECK-NEXT: ret
158
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>
162   ret <4 x float> %2
163 }
164 ; CHECK-LABEL: test15
165 ; Mask: [0,1,6,7]
166 ; CHECK: blendps $12
167 ; CHECK: ret
168
169 ; Verify that shuffles are canonicalized according to rules:
170 ;  shuffle(B, shuffle(A, Undef)) -> shuffle(shuffle(A, Undef), B)
171 ;
172 ; This allows to trigger the following combine rule:
173 ;  (shuffle(shuffle A, Undef, M0), A, M1) -> (shuffle A, Undef, M2)
174 ;
175 ; As a result, all the shuffle pairs in each function below should be
176 ; combined into a single legal shuffle operation.
177
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>
181   ret <4 x float> %2
182 }
183 ; CHECK-LABEL: test16
184 ; Mask: [0,1,2,3]
185 ; CHECK-NOT: pshufd
186 ; CHECK-NOT: shufps
187 ; CHECK-NOT: movlhps
188 ; CHECK: ret
189
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>
193   ret <4 x float> %2
194 }
195 ; CHECK-LABEL: test17
196 ; Mask: [0,1,0,1]
197 ; CHECK-NOT: pshufd
198 ; CHECK-NOT: shufps
199 ; CHECK: movlhps 
200 ; CHECK-NEXT: ret
201
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>
205   ret <4 x float> %2
206 }
207 ; CHECK-LABEL: test18
208 ; Mask: [0,1,0,u]
209 ; CHECK-NOT: pshufd
210 ; CHECK-NOT: shufps
211 ; CHECK: movlhps
212 ; CHECK-NEXT: ret
213
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>
217   ret <4 x float> %2
218 }
219 ; CHECK-LABEL: test19
220 ; Mask: [2,3,2,3]
221 ; CHECK-NOT: movlhps
222 ; CHECK-NOT: palignr
223 ; CHECK: movhlps
224 ; CHECK-NEXT: ret
225
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>
229   ret <4 x float> %2
230 }
231 ; CHECK-LABEL: test20
232 ; Mask: [0,1,2,3]
233 ; CHECK-NOT: pshufd
234 ; CHECK-NOT: shufps
235 ; CHECK-NOT: movlhps
236 ; CHECK: ret
237