1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=vector-combine -S -mtriple=x86_64-- -mattr=SSE2 | FileCheck %s --check-prefixes=CHECK,SSE
3 ; RUN: opt < %s -passes=vector-combine -S -mtriple=x86_64-- -mattr=AVX2 | FileCheck %s --check-prefixes=CHECK,AVX
5 ; x86 does not have a cheap v16i8 shuffle until SSSE3 (pshufb)
7 define <16 x i8> @bitcast_shuf_narrow_element(<4 x i32> %v) {
8 ; SSE-LABEL: @bitcast_shuf_narrow_element(
9 ; SSE-NEXT: [[SHUF:%.*]] = shufflevector <4 x i32> [[V:%.*]], <4 x i32> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>
10 ; SSE-NEXT: [[R:%.*]] = bitcast <4 x i32> [[SHUF]] to <16 x i8>
11 ; SSE-NEXT: ret <16 x i8> [[R]]
13 ; AVX-LABEL: @bitcast_shuf_narrow_element(
14 ; AVX-NEXT: [[TMP1:%.*]] = bitcast <4 x i32> [[V:%.*]] to <16 x i8>
15 ; AVX-NEXT: [[R:%.*]] = shufflevector <16 x i8> [[TMP1]], <16 x i8> poison, <16 x i32> <i32 12, i32 13, i32 14, i32 15, i32 8, i32 9, i32 10, i32 11, i32 4, i32 5, i32 6, i32 7, i32 0, i32 1, i32 2, i32 3>
16 ; AVX-NEXT: ret <16 x i8> [[R]]
18 %shuf = shufflevector <4 x i32> %v, <4 x i32> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>
19 %r = bitcast <4 x i32> %shuf to <16 x i8>
23 ; v4f32 is the same cost as v4i32, so this always works
25 define <4 x float> @bitcast_shuf_same_size(<4 x i32> %v) {
26 ; CHECK-LABEL: @bitcast_shuf_same_size(
27 ; CHECK-NEXT: [[TMP1:%.*]] = bitcast <4 x i32> [[V:%.*]] to <4 x float>
28 ; CHECK-NEXT: [[R:%.*]] = shufflevector <4 x float> [[TMP1]], <4 x float> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>
29 ; CHECK-NEXT: ret <4 x float> [[R]]
31 %shuf = shufflevector <4 x i32> %v, <4 x i32> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>
32 %r = bitcast <4 x i32> %shuf to <4 x float>
36 ; Length-changing shuffles
38 define <16 x i8> @bitcast_shuf_narrow_element_subvector(<2 x i32> %v) {
39 ; SSE-LABEL: @bitcast_shuf_narrow_element_subvector(
40 ; SSE-NEXT: [[SHUF:%.*]] = shufflevector <2 x i32> [[V:%.*]], <2 x i32> poison, <4 x i32> <i32 1, i32 0, i32 1, i32 0>
41 ; SSE-NEXT: [[R:%.*]] = bitcast <4 x i32> [[SHUF]] to <16 x i8>
42 ; SSE-NEXT: ret <16 x i8> [[R]]
44 ; AVX-LABEL: @bitcast_shuf_narrow_element_subvector(
45 ; AVX-NEXT: [[TMP1:%.*]] = bitcast <2 x i32> [[V:%.*]] to <8 x i8>
46 ; AVX-NEXT: [[R:%.*]] = shufflevector <8 x i8> [[TMP1]], <8 x i8> poison, <16 x i32> <i32 4, i32 5, i32 6, i32 7, i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 0, i32 1, i32 2, i32 3>
47 ; AVX-NEXT: ret <16 x i8> [[R]]
49 %shuf = shufflevector <2 x i32> %v, <2 x i32> poison, <4 x i32> <i32 1, i32 0, i32 1, i32 0>
50 %r = bitcast <4 x i32> %shuf to <16 x i8>
54 define <16 x i16> @bitcast_shuf_narrow_element_concat_subvectors(<2 x i64> %v) {
55 ; SSE-LABEL: @bitcast_shuf_narrow_element_concat_subvectors(
56 ; SSE-NEXT: [[SHUF:%.*]] = shufflevector <2 x i64> [[V:%.*]], <2 x i64> poison, <4 x i32> <i32 0, i32 1, i32 0, i32 1>
57 ; SSE-NEXT: [[R:%.*]] = bitcast <4 x i64> [[SHUF]] to <16 x i16>
58 ; SSE-NEXT: ret <16 x i16> [[R]]
60 ; AVX-LABEL: @bitcast_shuf_narrow_element_concat_subvectors(
61 ; AVX-NEXT: [[TMP1:%.*]] = bitcast <2 x i64> [[V:%.*]] to <8 x i16>
62 ; AVX-NEXT: [[R:%.*]] = shufflevector <8 x i16> [[TMP1]], <8 x i16> poison, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
63 ; AVX-NEXT: ret <16 x i16> [[R]]
65 %shuf = shufflevector <2 x i64> %v, <2 x i64> poison, <4 x i32> <i32 0, i32 1, i32 0, i32 1>
66 %r = bitcast <4 x i64> %shuf to <16 x i16>
70 define <16 x i8> @bitcast_shuf_extract_subvector(<8 x i32> %v) {
71 ; CHECK-LABEL: @bitcast_shuf_extract_subvector(
72 ; CHECK-NEXT: [[TMP1:%.*]] = bitcast <8 x i32> [[V:%.*]] to <32 x i8>
73 ; CHECK-NEXT: [[R:%.*]] = shufflevector <32 x i8> [[TMP1]], <32 x i8> poison, <16 x i32> <i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31>
74 ; CHECK-NEXT: ret <16 x i8> [[R]]
76 %shuf = shufflevector <8 x i32> %v, <8 x i32> poison, <4 x i32> <i32 4, i32 5, i32 6, i32 7>
77 %r = bitcast <4 x i32> %shuf to <16 x i8>
81 ; Negative test - must cast to vector type
83 define i128 @bitcast_shuf_narrow_element_wrong_type(<4 x i32> %v) {
84 ; CHECK-LABEL: @bitcast_shuf_narrow_element_wrong_type(
85 ; CHECK-NEXT: [[SHUF:%.*]] = shufflevector <4 x i32> [[V:%.*]], <4 x i32> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>
86 ; CHECK-NEXT: [[R:%.*]] = bitcast <4 x i32> [[SHUF]] to i128
87 ; CHECK-NEXT: ret i128 [[R]]
89 %shuf = shufflevector <4 x i32> %v, <4 x i32> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>
90 %r = bitcast <4 x i32> %shuf to i128
94 ; Widen shuffle elements
96 define <4 x i32> @bitcast_shuf_wide_element(<8 x i16> %v) {
97 ; CHECK-LABEL: @bitcast_shuf_wide_element(
98 ; CHECK-NEXT: [[TMP1:%.*]] = bitcast <8 x i16> [[V:%.*]] to <4 x i32>
99 ; CHECK-NEXT: [[R:%.*]] = shufflevector <4 x i32> [[TMP1]], <4 x i32> poison, <4 x i32> <i32 0, i32 0, i32 1, i32 1>
100 ; CHECK-NEXT: ret <4 x i32> [[R]]
102 %shuf = shufflevector <8 x i16> %v, <8 x i16> poison, <8 x i32> <i32 0, i32 1, i32 0, i32 1, i32 2, i32 3, i32 2, i32 3>
103 %r = bitcast <8 x i16> %shuf to <4 x i32>
107 declare void @use(<4 x i32>)
109 ; Negative test - don't create an extra shuffle
111 define <16 x i8> @bitcast_shuf_uses(<4 x i32> %v) {
112 ; CHECK-LABEL: @bitcast_shuf_uses(
113 ; CHECK-NEXT: [[SHUF:%.*]] = shufflevector <4 x i32> [[V:%.*]], <4 x i32> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>
114 ; CHECK-NEXT: call void @use(<4 x i32> [[SHUF]])
115 ; CHECK-NEXT: [[R:%.*]] = bitcast <4 x i32> [[SHUF]] to <16 x i8>
116 ; CHECK-NEXT: ret <16 x i8> [[R]]
118 %shuf = shufflevector <4 x i32> %v, <4 x i32> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>
119 call void @use(<4 x i32> %shuf)
120 %r = bitcast <4 x i32> %shuf to <16 x i8>
124 define <2 x i64> @PR35454_1(<2 x i64> %v) {
125 ; SSE-LABEL: @PR35454_1(
126 ; SSE-NEXT: [[BC:%.*]] = bitcast <2 x i64> [[V:%.*]] to <4 x i32>
127 ; SSE-NEXT: [[PERMIL:%.*]] = shufflevector <4 x i32> [[BC]], <4 x i32> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>
128 ; SSE-NEXT: [[BC1:%.*]] = bitcast <4 x i32> [[PERMIL]] to <16 x i8>
129 ; SSE-NEXT: [[ADD:%.*]] = shl <16 x i8> [[BC1]], <i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1>
130 ; SSE-NEXT: [[BC2:%.*]] = bitcast <16 x i8> [[ADD]] to <4 x i32>
131 ; SSE-NEXT: [[PERMIL1:%.*]] = shufflevector <4 x i32> [[BC2]], <4 x i32> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>
132 ; SSE-NEXT: [[BC3:%.*]] = bitcast <4 x i32> [[PERMIL1]] to <2 x i64>
133 ; SSE-NEXT: ret <2 x i64> [[BC3]]
135 ; AVX-LABEL: @PR35454_1(
136 ; AVX-NEXT: [[BC:%.*]] = bitcast <2 x i64> [[V:%.*]] to <4 x i32>
137 ; AVX-NEXT: [[TMP1:%.*]] = bitcast <4 x i32> [[BC]] to <16 x i8>
138 ; AVX-NEXT: [[BC1:%.*]] = shufflevector <16 x i8> [[TMP1]], <16 x i8> poison, <16 x i32> <i32 12, i32 13, i32 14, i32 15, i32 8, i32 9, i32 10, i32 11, i32 4, i32 5, i32 6, i32 7, i32 0, i32 1, i32 2, i32 3>
139 ; AVX-NEXT: [[ADD:%.*]] = shl <16 x i8> [[BC1]], <i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1>
140 ; AVX-NEXT: [[BC2:%.*]] = bitcast <16 x i8> [[ADD]] to <4 x i32>
141 ; AVX-NEXT: [[PERMIL1:%.*]] = shufflevector <4 x i32> [[BC2]], <4 x i32> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>
142 ; AVX-NEXT: [[BC3:%.*]] = bitcast <4 x i32> [[PERMIL1]] to <2 x i64>
143 ; AVX-NEXT: ret <2 x i64> [[BC3]]
145 %bc = bitcast <2 x i64> %v to <4 x i32>
146 %permil = shufflevector <4 x i32> %bc, <4 x i32> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>
147 %bc1 = bitcast <4 x i32> %permil to <16 x i8>
148 %add = shl <16 x i8> %bc1, <i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1>
149 %bc2 = bitcast <16 x i8> %add to <4 x i32>
150 %permil1 = shufflevector <4 x i32> %bc2, <4 x i32> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>
151 %bc3 = bitcast <4 x i32> %permil1 to <2 x i64>
155 define <2 x i64> @PR35454_2(<2 x i64> %v) {
156 ; SSE-LABEL: @PR35454_2(
157 ; SSE-NEXT: [[BC:%.*]] = bitcast <2 x i64> [[V:%.*]] to <4 x i32>
158 ; SSE-NEXT: [[PERMIL:%.*]] = shufflevector <4 x i32> [[BC]], <4 x i32> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>
159 ; SSE-NEXT: [[BC1:%.*]] = bitcast <4 x i32> [[PERMIL]] to <8 x i16>
160 ; SSE-NEXT: [[ADD:%.*]] = shl <8 x i16> [[BC1]], <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>
161 ; SSE-NEXT: [[BC2:%.*]] = bitcast <8 x i16> [[ADD]] to <4 x i32>
162 ; SSE-NEXT: [[PERMIL1:%.*]] = shufflevector <4 x i32> [[BC2]], <4 x i32> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>
163 ; SSE-NEXT: [[BC3:%.*]] = bitcast <4 x i32> [[PERMIL1]] to <2 x i64>
164 ; SSE-NEXT: ret <2 x i64> [[BC3]]
166 ; AVX-LABEL: @PR35454_2(
167 ; AVX-NEXT: [[BC:%.*]] = bitcast <2 x i64> [[V:%.*]] to <4 x i32>
168 ; AVX-NEXT: [[TMP1:%.*]] = bitcast <4 x i32> [[BC]] to <8 x i16>
169 ; AVX-NEXT: [[BC1:%.*]] = shufflevector <8 x i16> [[TMP1]], <8 x i16> poison, <8 x i32> <i32 6, i32 7, i32 4, i32 5, i32 2, i32 3, i32 0, i32 1>
170 ; AVX-NEXT: [[ADD:%.*]] = shl <8 x i16> [[BC1]], <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>
171 ; AVX-NEXT: [[BC2:%.*]] = bitcast <8 x i16> [[ADD]] to <4 x i32>
172 ; AVX-NEXT: [[PERMIL1:%.*]] = shufflevector <4 x i32> [[BC2]], <4 x i32> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>
173 ; AVX-NEXT: [[BC3:%.*]] = bitcast <4 x i32> [[PERMIL1]] to <2 x i64>
174 ; AVX-NEXT: ret <2 x i64> [[BC3]]
176 %bc = bitcast <2 x i64> %v to <4 x i32>
177 %permil = shufflevector <4 x i32> %bc, <4 x i32> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>
178 %bc1 = bitcast <4 x i32> %permil to <8 x i16>
179 %add = shl <8 x i16> %bc1, <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>
180 %bc2 = bitcast <8 x i16> %add to <4 x i32>
181 %permil1 = shufflevector <4 x i32> %bc2, <4 x i32> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>
182 %bc3 = bitcast <4 x i32> %permil1 to <2 x i64>
186 ; Shuffle is much cheaper than fdiv. FMF are intersected.
188 define <4 x float> @shuf_fdiv_v4f32_yy(<4 x float> %x, <4 x float> %y, <4 x float> %z) {
189 ; CHECK-LABEL: @shuf_fdiv_v4f32_yy(
190 ; CHECK-NEXT: [[TMP1:%.*]] = shufflevector <4 x float> [[X:%.*]], <4 x float> [[Z:%.*]], <4 x i32> <i32 1, i32 3, i32 5, i32 7>
191 ; CHECK-NEXT: [[TMP2:%.*]] = shufflevector <4 x float> [[Y:%.*]], <4 x float> poison, <4 x i32> <i32 1, i32 3, i32 1, i32 3>
192 ; CHECK-NEXT: [[R:%.*]] = fdiv arcp <4 x float> [[TMP1]], [[TMP2]]
193 ; CHECK-NEXT: ret <4 x float> [[R]]
195 %b0 = fdiv fast <4 x float> %x, %y
196 %b1 = fdiv arcp <4 x float> %z, %y
197 %r = shufflevector <4 x float> %b0, <4 x float> %b1, <4 x i32> <i32 1, i32 3, i32 5, i32 7>
201 ; Common operand is op0 of the binops.
203 define <4 x i32> @shuf_add_v4i32_xx(<4 x i32> %x, <4 x i32> %y, <4 x i32> %z) {
204 ; CHECK-LABEL: @shuf_add_v4i32_xx(
205 ; CHECK-NEXT: [[TMP1:%.*]] = shufflevector <4 x i32> [[X:%.*]], <4 x i32> poison, <4 x i32> <i32 poison, i32 poison, i32 2, i32 0>
206 ; CHECK-NEXT: [[TMP2:%.*]] = shufflevector <4 x i32> [[Y:%.*]], <4 x i32> [[Z:%.*]], <4 x i32> <i32 poison, i32 poison, i32 6, i32 0>
207 ; CHECK-NEXT: [[R:%.*]] = add <4 x i32> [[TMP1]], [[TMP2]]
208 ; CHECK-NEXT: ret <4 x i32> [[R]]
210 %b0 = add <4 x i32> %x, %y
211 %b1 = add <4 x i32> %x, %z
212 %r = shufflevector <4 x i32> %b0, <4 x i32> %b1, <4 x i32> <i32 poison, i32 poison, i32 6, i32 0>
216 ; For commutative instructions, common operand may be swapped.
218 define <4 x float> @shuf_fmul_v4f32_xx_swap(<4 x float> %x, <4 x float> %y, <4 x float> %z) {
219 ; CHECK-LABEL: @shuf_fmul_v4f32_xx_swap(
220 ; CHECK-NEXT: [[TMP1:%.*]] = shufflevector <4 x float> [[Y:%.*]], <4 x float> [[Z:%.*]], <4 x i32> <i32 0, i32 3, i32 4, i32 7>
221 ; CHECK-NEXT: [[TMP2:%.*]] = shufflevector <4 x float> [[X:%.*]], <4 x float> poison, <4 x i32> <i32 0, i32 3, i32 0, i32 3>
222 ; CHECK-NEXT: [[R:%.*]] = fmul <4 x float> [[TMP1]], [[TMP2]]
223 ; CHECK-NEXT: ret <4 x float> [[R]]
225 %b0 = fmul <4 x float> %x, %y
226 %b1 = fmul <4 x float> %z, %x
227 %r = shufflevector <4 x float> %b0, <4 x float> %b1, <4 x i32> <i32 0, i32 3, i32 4, i32 7>
231 ; For commutative instructions, common operand may be swapped.
233 define <2 x i64> @shuf_and_v2i64_yy_swap(<2 x i64> %x, <2 x i64> %y, <2 x i64> %z) {
234 ; CHECK-LABEL: @shuf_and_v2i64_yy_swap(
235 ; CHECK-NEXT: [[TMP1:%.*]] = shufflevector <2 x i64> [[Y:%.*]], <2 x i64> poison, <2 x i32> <i32 1, i32 0>
236 ; CHECK-NEXT: [[TMP2:%.*]] = shufflevector <2 x i64> [[X:%.*]], <2 x i64> [[Z:%.*]], <2 x i32> <i32 3, i32 0>
237 ; CHECK-NEXT: [[R:%.*]] = and <2 x i64> [[TMP1]], [[TMP2]]
238 ; CHECK-NEXT: ret <2 x i64> [[R]]
240 %b0 = and <2 x i64> %x, %y
241 %b1 = and <2 x i64> %y, %z
242 %r = shufflevector <2 x i64> %b0, <2 x i64> %b1, <2 x i32> <i32 3, i32 0>
246 ; non-commutative binop, but common op0
248 define <4 x i32> @shuf_shl_v4i32_xx(<4 x i32> %x, <4 x i32> %y, <4 x i32> %z) {
249 ; CHECK-LABEL: @shuf_shl_v4i32_xx(
250 ; CHECK-NEXT: [[TMP1:%.*]] = shufflevector <4 x i32> [[X:%.*]], <4 x i32> poison, <4 x i32> <i32 3, i32 1, i32 1, i32 2>
251 ; CHECK-NEXT: [[TMP2:%.*]] = shufflevector <4 x i32> [[Y:%.*]], <4 x i32> [[Z:%.*]], <4 x i32> <i32 3, i32 1, i32 1, i32 6>
252 ; CHECK-NEXT: [[R:%.*]] = shl <4 x i32> [[TMP1]], [[TMP2]]
253 ; CHECK-NEXT: ret <4 x i32> [[R]]
255 %b0 = shl <4 x i32> %x, %y
256 %b1 = shl <4 x i32> %x, %z
257 %r = shufflevector <4 x i32> %b0, <4 x i32> %b1, <4 x i32> <i32 3, i32 1, i32 1, i32 6>
261 ; negative test - common operand, but not commutable
263 define <4 x i32> @shuf_shl_v4i32_xx_swap(<4 x i32> %x, <4 x i32> %y, <4 x i32> %z) {
264 ; CHECK-LABEL: @shuf_shl_v4i32_xx_swap(
265 ; CHECK-NEXT: [[B0:%.*]] = shl <4 x i32> [[X:%.*]], [[Y:%.*]]
266 ; CHECK-NEXT: [[B1:%.*]] = shl <4 x i32> [[Z:%.*]], [[X]]
267 ; CHECK-NEXT: [[R:%.*]] = shufflevector <4 x i32> [[B0]], <4 x i32> [[B1]], <4 x i32> <i32 3, i32 2, i32 2, i32 5>
268 ; CHECK-NEXT: ret <4 x i32> [[R]]
270 %b0 = shl <4 x i32> %x, %y
271 %b1 = shl <4 x i32> %z, %x
272 %r = shufflevector <4 x i32> %b0, <4 x i32> %b1, <4 x i32> <i32 3, i32 2, i32 2, i32 5>
276 ; negative test - mismatched opcodes
278 define <2 x i64> @shuf_sub_add_v2i64_yy(<2 x i64> %x, <2 x i64> %y, <2 x i64> %z) {
279 ; CHECK-LABEL: @shuf_sub_add_v2i64_yy(
280 ; CHECK-NEXT: [[B0:%.*]] = sub <2 x i64> [[X:%.*]], [[Y:%.*]]
281 ; CHECK-NEXT: [[B1:%.*]] = add <2 x i64> [[Z:%.*]], [[Y]]
282 ; CHECK-NEXT: [[R:%.*]] = shufflevector <2 x i64> [[B0]], <2 x i64> [[B1]], <2 x i32> <i32 3, i32 0>
283 ; CHECK-NEXT: ret <2 x i64> [[R]]
285 %b0 = sub <2 x i64> %x, %y
286 %b1 = add <2 x i64> %z, %y
287 %r = shufflevector <2 x i64> %b0, <2 x i64> %b1, <2 x i32> <i32 3, i32 0>
291 ; negative test - type change via shuffle
293 define <8 x float> @shuf_fmul_v4f32_xx_type(<4 x float> %x, <4 x float> %y, <4 x float> %z) {
294 ; CHECK-LABEL: @shuf_fmul_v4f32_xx_type(
295 ; CHECK-NEXT: [[B0:%.*]] = fmul <4 x float> [[X:%.*]], [[Y:%.*]]
296 ; CHECK-NEXT: [[B1:%.*]] = fmul <4 x float> [[Z:%.*]], [[X]]
297 ; CHECK-NEXT: [[R:%.*]] = shufflevector <4 x float> [[B0]], <4 x float> [[B1]], <8 x i32> <i32 0, i32 3, i32 4, i32 7, i32 0, i32 1, i32 1, i32 6>
298 ; CHECK-NEXT: ret <8 x float> [[R]]
300 %b0 = fmul <4 x float> %x, %y
301 %b1 = fmul <4 x float> %z, %x
302 %r = shufflevector <4 x float> %b0, <4 x float> %b1, <8 x i32> <i32 0, i32 3, i32 4, i32 7, i32 0, i32 1, i32 1, i32 6>
306 ; negative test - uses
308 define <4 x i32> @shuf_lshr_v4i32_yy_use1(<4 x i32> %x, <4 x i32> %y, <4 x i32> %z) {
309 ; CHECK-LABEL: @shuf_lshr_v4i32_yy_use1(
310 ; CHECK-NEXT: [[B0:%.*]] = lshr <4 x i32> [[X:%.*]], [[Y:%.*]]
311 ; CHECK-NEXT: call void @use(<4 x i32> [[B0]])
312 ; CHECK-NEXT: [[B1:%.*]] = lshr <4 x i32> [[Z:%.*]], [[Y]]
313 ; CHECK-NEXT: [[R:%.*]] = shufflevector <4 x i32> [[B0]], <4 x i32> [[B1]], <4 x i32> <i32 0, i32 2, i32 4, i32 6>
314 ; CHECK-NEXT: ret <4 x i32> [[R]]
316 %b0 = lshr <4 x i32> %x, %y
317 call void @use(<4 x i32> %b0)
318 %b1 = lshr <4 x i32> %z, %y
319 %r = shufflevector <4 x i32> %b0, <4 x i32> %b1, <4 x i32> <i32 0, i32 2, i32 4, i32 6>
323 ; negative test - uses
325 define <4 x i32> @shuf_mul_v4i32_yy_use2(<4 x i32> %x, <4 x i32> %y, <4 x i32> %z) {
326 ; CHECK-LABEL: @shuf_mul_v4i32_yy_use2(
327 ; CHECK-NEXT: [[B0:%.*]] = mul <4 x i32> [[X:%.*]], [[Y:%.*]]
328 ; CHECK-NEXT: [[B1:%.*]] = mul <4 x i32> [[Z:%.*]], [[Y]]
329 ; CHECK-NEXT: call void @use(<4 x i32> [[B1]])
330 ; CHECK-NEXT: [[R:%.*]] = shufflevector <4 x i32> [[B0]], <4 x i32> [[B1]], <4 x i32> <i32 1, i32 3, i32 5, i32 7>
331 ; CHECK-NEXT: ret <4 x i32> [[R]]
333 %b0 = mul <4 x i32> %x, %y
334 %b1 = mul <4 x i32> %z, %y
335 call void @use(<4 x i32> %b1)
336 %r = shufflevector <4 x i32> %b0, <4 x i32> %b1, <4 x i32> <i32 1, i32 3, i32 5, i32 7>
340 ; negative test - must have matching operand
342 define <4 x float> @shuf_fadd_v4f32_no_common_op(<4 x float> %x, <4 x float> %y, <4 x float> %z, <4 x float> %w) {
343 ; CHECK-LABEL: @shuf_fadd_v4f32_no_common_op(
344 ; CHECK-NEXT: [[B0:%.*]] = fadd <4 x float> [[X:%.*]], [[Y:%.*]]
345 ; CHECK-NEXT: [[B1:%.*]] = fadd <4 x float> [[Z:%.*]], [[W:%.*]]
346 ; CHECK-NEXT: [[R:%.*]] = shufflevector <4 x float> [[B0]], <4 x float> [[B1]], <4 x i32> <i32 1, i32 3, i32 5, i32 7>
347 ; CHECK-NEXT: ret <4 x float> [[R]]
349 %b0 = fadd <4 x float> %x, %y
350 %b1 = fadd <4 x float> %z, %w
351 %r = shufflevector <4 x float> %b0, <4 x float> %b1, <4 x i32> <i32 1, i32 3, i32 5, i32 7>
355 ; negative test - binops may be relatively cheap
357 define <16 x i16> @shuf_and_v16i16_yy_expensive_shuf(<16 x i16> %x, <16 x i16> %y, <16 x i16> %z) {
358 ; CHECK-LABEL: @shuf_and_v16i16_yy_expensive_shuf(
359 ; CHECK-NEXT: [[B0:%.*]] = and <16 x i16> [[X:%.*]], [[Y:%.*]]
360 ; CHECK-NEXT: [[B1:%.*]] = and <16 x i16> [[Y]], [[Z:%.*]]
361 ; CHECK-NEXT: [[R:%.*]] = shufflevector <16 x i16> [[B0]], <16 x i16> [[B1]], <16 x i32> <i32 15, i32 22, i32 25, i32 13, i32 28, i32 0, i32 poison, i32 3, i32 0, i32 30, i32 3, i32 7, i32 9, i32 19, i32 2, i32 22>
362 ; CHECK-NEXT: ret <16 x i16> [[R]]
364 %b0 = and <16 x i16> %x, %y
365 %b1 = and <16 x i16> %y, %z
366 %r = shufflevector <16 x i16> %b0, <16 x i16> %b1, <16 x i32> <i32 15, i32 22, i32 25, i32 13, i32 28, i32 0, i32 poison, i32 3, i32 0, i32 30, i32 3, i32 7, i32 9, i32 19, i32 2, i32 22>