1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -mcpu=corei7 | FileCheck %s -check-prefixes=CHECK,CHECK-LV
3 ; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -mcpu=corei7 -early-live-intervals | FileCheck %s -check-prefixes=CHECK,CHECK-LIS
5 define i32 @or_self(i32 %x) {
6 ; CHECK-LABEL: or_self:
8 ; CHECK-NEXT: movl %edi, %eax
14 define <4 x i32> @or_self_vec(<4 x i32> %x) {
15 ; CHECK-LABEL: or_self_vec:
18 %or = or <4 x i32> %x, %x
22 ; Verify that each of the following test cases is folded into a single
23 ; instruction which performs a blend operation.
25 define <2 x i64> @test1(<2 x i64> %a, <2 x i64> %b) {
28 ; CHECK-NEXT: blendps {{.*#+}} xmm0 = xmm0[0,1],xmm1[2,3]
30 %shuf1 = shufflevector <2 x i64> %a, <2 x i64> zeroinitializer, <2 x i32><i32 0, i32 2>
31 %shuf2 = shufflevector <2 x i64> %b, <2 x i64> zeroinitializer, <2 x i32><i32 2, i32 1>
32 %or = or <2 x i64> %shuf1, %shuf2
37 define <4 x i32> @test2(<4 x i32> %a, <4 x i32> %b) {
40 ; CHECK-NEXT: blendps {{.*#+}} xmm0 = xmm1[0,1],xmm0[2,3]
42 %shuf1 = shufflevector <4 x i32> %a, <4 x i32> zeroinitializer, <4 x i32><i32 4, i32 4, i32 2, i32 3>
43 %shuf2 = shufflevector <4 x i32> %b, <4 x i32> zeroinitializer, <4 x i32><i32 0, i32 1, i32 4, i32 4>
44 %or = or <4 x i32> %shuf1, %shuf2
49 define <2 x i64> @test3(<2 x i64> %a, <2 x i64> %b) {
52 ; CHECK-NEXT: blendps {{.*#+}} xmm0 = xmm1[0,1],xmm0[2,3]
54 %shuf1 = shufflevector <2 x i64> %a, <2 x i64> zeroinitializer, <2 x i32><i32 2, i32 1>
55 %shuf2 = shufflevector <2 x i64> %b, <2 x i64> zeroinitializer, <2 x i32><i32 0, i32 2>
56 %or = or <2 x i64> %shuf1, %shuf2
61 define <4 x i32> @test4(<4 x i32> %a, <4 x i32> %b) {
64 ; CHECK-NEXT: blendps {{.*#+}} xmm0 = xmm0[0],xmm1[1,2,3]
66 %shuf1 = shufflevector <4 x i32> %a, <4 x i32> zeroinitializer, <4 x i32><i32 0, i32 4, i32 4, i32 4>
67 %shuf2 = shufflevector <4 x i32> %b, <4 x i32> zeroinitializer, <4 x i32><i32 4, i32 1, i32 2, i32 3>
68 %or = or <4 x i32> %shuf1, %shuf2
73 define <4 x i32> @test5(<4 x i32> %a, <4 x i32> %b) {
76 ; CHECK-NEXT: blendps {{.*#+}} xmm0 = xmm1[0],xmm0[1,2,3]
78 %shuf1 = shufflevector <4 x i32> %a, <4 x i32> zeroinitializer, <4 x i32><i32 4, i32 1, i32 2, i32 3>
79 %shuf2 = shufflevector <4 x i32> %b, <4 x i32> zeroinitializer, <4 x i32><i32 0, i32 4, i32 4, i32 4>
80 %or = or <4 x i32> %shuf1, %shuf2
85 define <4 x i32> @test6(<4 x i32> %a, <4 x i32> %b) {
88 ; CHECK-NEXT: blendps {{.*#+}} xmm0 = xmm0[0,1],xmm1[2,3]
90 %shuf1 = shufflevector <4 x i32> %a, <4 x i32> zeroinitializer, <4 x i32><i32 0, i32 1, i32 4, i32 4>
91 %shuf2 = shufflevector <4 x i32> %b, <4 x i32> zeroinitializer, <4 x i32><i32 4, i32 4, i32 2, i32 3>
92 %or = or <4 x i32> %shuf1, %shuf2
97 define <4 x i32> @test7(<4 x i32> %a, <4 x i32> %b) {
100 ; CHECK-NEXT: blendps {{.*#+}} xmm0 = xmm0[0,1],xmm1[2,3]
102 %and1 = and <4 x i32> %a, <i32 -1, i32 -1, i32 0, i32 0>
103 %and2 = and <4 x i32> %b, <i32 0, i32 0, i32 -1, i32 -1>
104 %or = or <4 x i32> %and1, %and2
109 define <2 x i64> @test8(<2 x i64> %a, <2 x i64> %b) {
110 ; CHECK-LABEL: test8:
112 ; CHECK-NEXT: blendps {{.*#+}} xmm0 = xmm0[0,1],xmm1[2,3]
114 %and1 = and <2 x i64> %a, <i64 -1, i64 0>
115 %and2 = and <2 x i64> %b, <i64 0, i64 -1>
116 %or = or <2 x i64> %and1, %and2
121 define <4 x i32> @test9(<4 x i32> %a, <4 x i32> %b) {
122 ; CHECK-LABEL: test9:
124 ; CHECK-NEXT: blendps {{.*#+}} xmm0 = xmm1[0,1],xmm0[2,3]
126 %and1 = and <4 x i32> %a, <i32 0, i32 0, i32 -1, i32 -1>
127 %and2 = and <4 x i32> %b, <i32 -1, i32 -1, i32 0, i32 0>
128 %or = or <4 x i32> %and1, %and2
133 define <2 x i64> @test10(<2 x i64> %a, <2 x i64> %b) {
134 ; CHECK-LABEL: test10:
136 ; CHECK-NEXT: blendps {{.*#+}} xmm0 = xmm1[0,1],xmm0[2,3]
138 %and1 = and <2 x i64> %a, <i64 0, i64 -1>
139 %and2 = and <2 x i64> %b, <i64 -1, i64 0>
140 %or = or <2 x i64> %and1, %and2
145 define <4 x i32> @test11(<4 x i32> %a, <4 x i32> %b) {
146 ; CHECK-LABEL: test11:
148 ; CHECK-NEXT: blendps {{.*#+}} xmm0 = xmm0[0],xmm1[1,2,3]
150 %and1 = and <4 x i32> %a, <i32 -1, i32 0, i32 0, i32 0>
151 %and2 = and <4 x i32> %b, <i32 0, i32 -1, i32 -1, i32 -1>
152 %or = or <4 x i32> %and1, %and2
157 define <4 x i32> @test12(<4 x i32> %a, <4 x i32> %b) {
158 ; CHECK-LABEL: test12:
160 ; CHECK-NEXT: blendps {{.*#+}} xmm0 = xmm1[0],xmm0[1,2,3]
162 %and1 = and <4 x i32> %a, <i32 0, i32 -1, i32 -1, i32 -1>
163 %and2 = and <4 x i32> %b, <i32 -1, i32 0, i32 0, i32 0>
164 %or = or <4 x i32> %and1, %and2
169 ; Verify that the following test cases are folded into single shuffles.
171 define <4 x i32> @test13(<4 x i32> %a, <4 x i32> %b) {
172 ; CHECK-LABEL: test13:
174 ; CHECK-NEXT: shufps {{.*#+}} xmm0 = xmm0[1,1],xmm1[2,3]
176 %shuf1 = shufflevector <4 x i32> %a, <4 x i32> zeroinitializer, <4 x i32><i32 1, i32 1, i32 4, i32 4>
177 %shuf2 = shufflevector <4 x i32> %b, <4 x i32> zeroinitializer, <4 x i32><i32 4, i32 4, i32 2, i32 3>
178 %or = or <4 x i32> %shuf1, %shuf2
183 define <2 x i64> @test14(<2 x i64> %a, <2 x i64> %b) {
184 ; CHECK-LABEL: test14:
186 ; CHECK-NEXT: movlhps {{.*#+}} xmm0 = xmm0[0],xmm1[0]
188 %shuf1 = shufflevector <2 x i64> %a, <2 x i64> zeroinitializer, <2 x i32><i32 0, i32 2>
189 %shuf2 = shufflevector <2 x i64> %b, <2 x i64> zeroinitializer, <2 x i32><i32 2, i32 0>
190 %or = or <2 x i64> %shuf1, %shuf2
195 define <4 x i32> @test15(<4 x i32> %a, <4 x i32> %b) {
196 ; CHECK-LABEL: test15:
198 ; CHECK-NEXT: shufps {{.*#+}} xmm1 = xmm1[2,1],xmm0[2,1]
199 ; CHECK-NEXT: movaps %xmm1, %xmm0
201 %shuf1 = shufflevector <4 x i32> %a, <4 x i32> zeroinitializer, <4 x i32><i32 4, i32 4, i32 2, i32 1>
202 %shuf2 = shufflevector <4 x i32> %b, <4 x i32> zeroinitializer, <4 x i32><i32 2, i32 1, i32 4, i32 4>
203 %or = or <4 x i32> %shuf1, %shuf2
208 define <2 x i64> @test16(<2 x i64> %a, <2 x i64> %b) {
209 ; CHECK-LABEL: test16:
211 ; CHECK-NEXT: movlhps {{.*#+}} xmm1 = xmm1[0],xmm0[0]
212 ; CHECK-NEXT: movaps %xmm1, %xmm0
214 %shuf1 = shufflevector <2 x i64> %a, <2 x i64> zeroinitializer, <2 x i32><i32 2, i32 0>
215 %shuf2 = shufflevector <2 x i64> %b, <2 x i64> zeroinitializer, <2 x i32><i32 0, i32 2>
216 %or = or <2 x i64> %shuf1, %shuf2
221 ; Verify that the dag-combiner does not fold a OR of two shuffles into a single
222 ; shuffle instruction when the shuffle indexes are not compatible.
224 define <4 x i32> @test17(<4 x i32> %a, <4 x i32> %b) {
225 ; CHECK-LABEL: test17:
227 ; CHECK-NEXT: psllq $32, %xmm0
228 ; CHECK-NEXT: movq {{.*#+}} xmm1 = xmm1[0],zero
229 ; CHECK-NEXT: por %xmm1, %xmm0
231 %shuf1 = shufflevector <4 x i32> %a, <4 x i32> zeroinitializer, <4 x i32><i32 4, i32 0, i32 4, i32 2>
232 %shuf2 = shufflevector <4 x i32> %b, <4 x i32> zeroinitializer, <4 x i32><i32 0, i32 1, i32 4, i32 4>
233 %or = or <4 x i32> %shuf1, %shuf2
238 define <4 x i32> @test18(<4 x i32> %a, <4 x i32> %b) {
239 ; CHECK-LV-LABEL: test18:
241 ; CHECK-LV-NEXT: pxor %xmm2, %xmm2
242 ; CHECK-LV-NEXT: pblendw {{.*#+}} xmm0 = xmm0[0,1],xmm2[2,3,4,5,6,7]
243 ; CHECK-LV-NEXT: pshufd {{.*#+}} xmm0 = xmm0[1,0,1,1]
244 ; CHECK-LV-NEXT: pblendw {{.*#+}} xmm2 = xmm1[0,1],xmm2[2,3,4,5,6,7]
245 ; CHECK-LV-NEXT: por %xmm0, %xmm2
246 ; CHECK-LV-NEXT: movdqa %xmm2, %xmm0
247 ; CHECK-LV-NEXT: retq
249 ; CHECK-LIS-LABEL: test18:
250 ; CHECK-LIS: # %bb.0:
251 ; CHECK-LIS-NEXT: pxor %xmm2, %xmm2
252 ; CHECK-LIS-NEXT: pblendw {{.*#+}} xmm0 = xmm0[0,1],xmm2[2,3,4,5,6,7]
253 ; CHECK-LIS-NEXT: pshufd {{.*#+}} xmm0 = xmm0[1,0,1,1]
254 ; CHECK-LIS-NEXT: pblendw {{.*#+}} xmm2 = xmm1[0,1],xmm2[2,3,4,5,6,7]
255 ; CHECK-LIS-NEXT: por %xmm0, %xmm2
256 ; CHECK-LIS-NEXT: movdqa %xmm2, %xmm0
257 ; CHECK-LIS-NEXT: retq
258 %shuf1 = shufflevector <4 x i32> %a, <4 x i32> zeroinitializer, <4 x i32><i32 4, i32 0, i32 4, i32 4>
259 %shuf2 = shufflevector <4 x i32> %b, <4 x i32> zeroinitializer, <4 x i32><i32 0, i32 4, i32 4, i32 4>
260 %or = or <4 x i32> %shuf1, %shuf2
265 define <4 x i32> @test19(<4 x i32> %a, <4 x i32> %b) {
266 ; CHECK-LABEL: test19:
268 ; CHECK-NEXT: pshufd {{.*#+}} xmm2 = xmm0[0,0,2,3]
269 ; CHECK-NEXT: pxor %xmm3, %xmm3
270 ; CHECK-NEXT: pblendw {{.*#+}} xmm2 = xmm3[0,1],xmm2[2,3],xmm3[4,5],xmm2[6,7]
271 ; CHECK-NEXT: pshufd {{.*#+}} xmm0 = xmm1[0,1,2,2]
272 ; CHECK-NEXT: pblendw {{.*#+}} xmm0 = xmm0[0,1],xmm3[2,3],xmm0[4,5,6,7]
273 ; CHECK-NEXT: por %xmm2, %xmm0
275 %shuf1 = shufflevector <4 x i32> %a, <4 x i32> zeroinitializer, <4 x i32><i32 4, i32 0, i32 4, i32 3>
276 %shuf2 = shufflevector <4 x i32> %b, <4 x i32> zeroinitializer, <4 x i32><i32 0, i32 4, i32 2, i32 2>
277 %or = or <4 x i32> %shuf1, %shuf2
282 define <2 x i64> @test20(<2 x i64> %a, <2 x i64> %b) {
283 ; CHECK-LABEL: test20:
285 ; CHECK-NEXT: por %xmm1, %xmm0
286 ; CHECK-NEXT: movq {{.*#+}} xmm0 = xmm0[0],zero
288 %shuf1 = shufflevector <2 x i64> %a, <2 x i64> zeroinitializer, <2 x i32><i32 0, i32 2>
289 %shuf2 = shufflevector <2 x i64> %b, <2 x i64> zeroinitializer, <2 x i32><i32 0, i32 2>
290 %or = or <2 x i64> %shuf1, %shuf2
295 define <2 x i64> @test21(<2 x i64> %a, <2 x i64> %b) {
296 ; CHECK-LABEL: test21:
298 ; CHECK-NEXT: por %xmm1, %xmm0
299 ; CHECK-NEXT: pslldq {{.*#+}} xmm0 = zero,zero,zero,zero,zero,zero,zero,zero,xmm0[0,1,2,3,4,5,6,7]
301 %shuf1 = shufflevector <2 x i64> %a, <2 x i64> zeroinitializer, <2 x i32><i32 2, i32 0>
302 %shuf2 = shufflevector <2 x i64> %b, <2 x i64> zeroinitializer, <2 x i32><i32 2, i32 0>
303 %or = or <2 x i64> %shuf1, %shuf2
308 ; Verify that the dag-combiner keeps the correct domain for float/double vectors
309 ; bitcast to use the mask-or blend combine.
311 define <2 x double> @test22(<2 x double> %a0, <2 x double> %a1) {
312 ; CHECK-LABEL: test22:
314 ; CHECK-NEXT: blendps {{.*#+}} xmm0 = xmm1[0,1],xmm0[2,3]
316 %bc1 = bitcast <2 x double> %a0 to <2 x i64>
317 %bc2 = bitcast <2 x double> %a1 to <2 x i64>
318 %and1 = and <2 x i64> %bc1, <i64 0, i64 -1>
319 %and2 = and <2 x i64> %bc2, <i64 -1, i64 0>
320 %or = or <2 x i64> %and1, %and2
321 %bc3 = bitcast <2 x i64> %or to <2 x double>
322 ret <2 x double> %bc3
326 define <4 x float> @test23(<4 x float> %a0, <4 x float> %a1) {
327 ; CHECK-LABEL: test23:
329 ; CHECK-NEXT: blendps {{.*#+}} xmm0 = xmm1[0],xmm0[1,2],xmm1[3]
331 %bc1 = bitcast <4 x float> %a0 to <4 x i32>
332 %bc2 = bitcast <4 x float> %a1 to <4 x i32>
333 %and1 = and <4 x i32> %bc1, <i32 0, i32 -1, i32 -1, i32 0>
334 %and2 = and <4 x i32> %bc2, <i32 -1, i32 0, i32 0, i32 -1>
335 %or = or <4 x i32> %and1, %and2
336 %bc3 = bitcast <4 x i32> %or to <4 x float>
341 define <4 x float> @test24(<4 x float> %a0, <4 x float> %a1) {
342 ; CHECK-LABEL: test24:
344 ; CHECK-NEXT: blendps {{.*#+}} xmm0 = xmm1[0,1],xmm0[2,3]
346 %bc1 = bitcast <4 x float> %a0 to <2 x i64>
347 %bc2 = bitcast <4 x float> %a1 to <2 x i64>
348 %and1 = and <2 x i64> %bc1, <i64 0, i64 -1>
349 %and2 = and <2 x i64> %bc2, <i64 -1, i64 0>
350 %or = or <2 x i64> %and1, %and2
351 %bc3 = bitcast <2 x i64> %or to <4 x float>
356 define <4 x float> @test25(<4 x float> %a0) {
357 ; CHECK-LABEL: test25:
359 ; CHECK-NEXT: blendps {{.*#+}} xmm0 = mem[0],xmm0[1,2],mem[3]
361 %bc1 = bitcast <4 x float> %a0 to <4 x i32>
362 %bc2 = bitcast <4 x float> <float 1.0, float 1.0, float 1.0, float 1.0> to <4 x i32>
363 %and1 = and <4 x i32> %bc1, <i32 0, i32 -1, i32 -1, i32 0>
364 %and2 = and <4 x i32> %bc2, <i32 -1, i32 0, i32 0, i32 -1>
365 %or = or <4 x i32> %and1, %and2
366 %bc3 = bitcast <4 x i32> %or to <4 x float>
371 ; Verify that the DAGCombiner doesn't crash in the attempt to check if a shuffle
372 ; with illegal type has a legal mask. Method 'isShuffleMaskLegal' only knows how to
373 ; handle legal vector value types.
374 define <4 x i8> @test_crash(<4 x i8> %a, <4 x i8> %b) {
375 ; CHECK-LABEL: test_crash:
377 ; CHECK-NEXT: pblendw {{.*#+}} xmm0 = xmm1[0],xmm0[1],xmm1[2,3,4,5,6,7]
379 %shuf1 = shufflevector <4 x i8> %a, <4 x i8> zeroinitializer, <4 x i32><i32 4, i32 4, i32 2, i32 3>
380 %shuf2 = shufflevector <4 x i8> %b, <4 x i8> zeroinitializer, <4 x i32><i32 0, i32 1, i32 4, i32 4>
381 %or = or <4 x i8> %shuf1, %shuf2
385 ; Verify that we can fold regardless of which operand is the zeroinitializer
387 define <4 x i32> @test2b(<4 x i32> %a, <4 x i32> %b) {
388 ; CHECK-LABEL: test2b:
390 ; CHECK-NEXT: blendps {{.*#+}} xmm0 = xmm1[0,1],xmm0[2,3]
392 %shuf1 = shufflevector <4 x i32> zeroinitializer, <4 x i32> %a, <4 x i32><i32 0, i32 0, i32 6, i32 7>
393 %shuf2 = shufflevector <4 x i32> %b, <4 x i32> zeroinitializer, <4 x i32><i32 0, i32 1, i32 4, i32 4>
394 %or = or <4 x i32> %shuf1, %shuf2
398 define <4 x i32> @test2c(<4 x i32> %a, <4 x i32> %b) {
399 ; CHECK-LABEL: test2c:
401 ; CHECK-NEXT: blendps {{.*#+}} xmm0 = xmm1[0,1],xmm0[2,3]
403 %shuf1 = shufflevector <4 x i32> zeroinitializer, <4 x i32> %a, <4 x i32><i32 0, i32 0, i32 6, i32 7>
404 %shuf2 = shufflevector <4 x i32> zeroinitializer, <4 x i32> %b, <4 x i32><i32 4, i32 5, i32 0, i32 0>
405 %or = or <4 x i32> %shuf1, %shuf2
410 define <4 x i32> @test2d(<4 x i32> %a, <4 x i32> %b) {
411 ; CHECK-LABEL: test2d:
413 ; CHECK-NEXT: blendps {{.*#+}} xmm0 = xmm1[0,1],xmm0[2,3]
415 %shuf1 = shufflevector <4 x i32> %a, <4 x i32> zeroinitializer, <4 x i32><i32 4, i32 4, i32 2, i32 3>
416 %shuf2 = shufflevector <4 x i32> zeroinitializer, <4 x i32> %b, <4 x i32><i32 4, i32 5, i32 0, i32 0>
417 %or = or <4 x i32> %shuf1, %shuf2
421 ; Make sure we can have an undef where an index pointing to the zero vector should be
423 define <4 x i32> @test2e(<4 x i32> %a, <4 x i32> %b) {
424 ; CHECK-LABEL: test2e:
426 ; CHECK-NEXT: blendps {{.*#+}} xmm0 = xmm1[0,1],xmm0[2,3]
428 %shuf1 = shufflevector <4 x i32> %a, <4 x i32> <i32 0, i32 undef, i32 undef, i32 undef>, <4 x i32><i32 undef, i32 4, i32 2, i32 3>
429 %shuf2 = shufflevector <4 x i32> %b, <4 x i32> <i32 0, i32 undef, i32 undef, i32 undef>, <4 x i32><i32 0, i32 1, i32 4, i32 4>
430 %or = or <4 x i32> %shuf1, %shuf2
434 define <4 x i32> @test2f(<4 x i32> %a, <4 x i32> %b) {
435 ; CHECK-LABEL: test2f:
437 ; CHECK-NEXT: blendps {{.*#+}} xmm0 = xmm1[0,1],xmm0[2,3]
439 %shuf1 = shufflevector <4 x i32> %a, <4 x i32> <i32 0, i32 undef, i32 undef, i32 undef>, <4 x i32><i32 4, i32 4, i32 2, i32 3>
440 %shuf2 = shufflevector <4 x i32> %b, <4 x i32> <i32 0, i32 undef, i32 undef, i32 undef>, <4 x i32><i32 undef, i32 1, i32 4, i32 4>
441 %or = or <4 x i32> %shuf1, %shuf2
445 ; (or (and X, c1), c2) -> (and (or X, c2), c1|c2) iff (c1 & c2) != 0
447 define <2 x i64> @or_and_v2i64(<2 x i64> %a0) {
448 ; CHECK-LABEL: or_and_v2i64:
450 ; CHECK-NEXT: orps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
451 ; CHECK-NEXT: andps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
453 %1 = and <2 x i64> %a0, <i64 7, i64 7>
454 %2 = or <2 x i64> %1, <i64 3, i64 3>
458 define <4 x i32> @or_and_v4i32(<4 x i32> %a0) {
459 ; CHECK-LABEL: or_and_v4i32:
461 ; CHECK-NEXT: orps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
462 ; CHECK-NEXT: andps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
464 %1 = and <4 x i32> %a0, <i32 1, i32 3, i32 5, i32 7>
465 %2 = or <4 x i32> %1, <i32 3, i32 2, i32 15, i32 2>
469 ; If all masked bits are going to be set, that's a constant fold.
471 define <4 x i32> @or_and_v4i32_fold(<4 x i32> %a0) {
472 ; CHECK-LABEL: or_and_v4i32_fold:
474 ; CHECK-NEXT: movaps {{.*#+}} xmm0 = [3,3,3,3]
476 %1 = and <4 x i32> %a0, <i32 1, i32 1, i32 1, i32 1>
477 %2 = or <4 x i32> %1, <i32 3, i32 3, i32 3, i32 3>
481 ; fold (or x, c) -> c iff (x & ~c) == 0
483 define <2 x i64> @or_zext_v2i32(<2 x i32> %a0) {
484 ; CHECK-LABEL: or_zext_v2i32:
486 ; CHECK-NEXT: movaps {{.*#+}} xmm0 = [4294967295,4294967295]
488 %1 = zext <2 x i32> %a0 to <2 x i64>
489 %2 = or <2 x i64> %1, <i64 4294967295, i64 4294967295>
493 define <4 x i32> @or_zext_v4i16(<4 x i16> %a0) {
494 ; CHECK-LABEL: or_zext_v4i16:
496 ; CHECK-NEXT: movaps {{.*#+}} xmm0 = [65535,65535,65535,65535]
498 %1 = zext <4 x i16> %a0 to <4 x i32>
499 %2 = or <4 x i32> %1, <i32 65535, i32 65535, i32 65535, i32 65535>
503 ; fold (or (and X, C1), (and (or X, Y), C2)) -> (or (and X, C1|C2), (and Y, C2))
505 define i32 @or_and_and_i32(i32 %x, i32 %y) {
506 ; CHECK-LABEL: or_and_and_i32:
508 ; CHECK-NEXT: movl %edi, %eax
509 ; CHECK-NEXT: andl $-11, %esi
510 ; CHECK-NEXT: andl $-3, %eax
511 ; CHECK-NEXT: orl %esi, %eax
515 %mxy = and i32 %xy, -11
516 %r = or i32 %mx, %mxy
520 define i64 @or_and_and_commute_i64(i64 %x, i64 %y) {
521 ; CHECK-LABEL: or_and_and_commute_i64:
523 ; CHECK-NEXT: movq %rdi, %rax
524 ; CHECK-NEXT: orq %rsi, %rax
525 ; CHECK-NEXT: andq $-3, %rax
529 %mxy = and i64 %xy, -3
530 %r = or i64 %mxy, %mx
534 define <4 x i32> @or_and_and_v4i32(<4 x i32> %x, <4 x i32> %y) {
535 ; CHECK-LABEL: or_and_and_v4i32:
537 ; CHECK-NEXT: andps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1
538 ; CHECK-NEXT: andps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
539 ; CHECK-NEXT: orps %xmm1, %xmm0
541 %xy = or <4 x i32> %x, %y
542 %mx = and <4 x i32> %x, <i32 2, i32 4, i32 8, i32 16>
543 %mxy = and <4 x i32> %xy, <i32 1, i32 -1, i32 -5, i32 -25>
544 %r = or <4 x i32> %mx, %mxy
548 define i32 @or_and_and_multiuse_i32(i32 %x, i32 %y) nounwind {
549 ; CHECK-LABEL: or_and_and_multiuse_i32:
551 ; CHECK-NEXT: pushq %rbx
552 ; CHECK-NEXT: # kill: def $esi killed $esi def $rsi
553 ; CHECK-NEXT: # kill: def $edi killed $edi def $rdi
554 ; CHECK-NEXT: orl %edi, %esi
555 ; CHECK-NEXT: andl $8, %edi
556 ; CHECK-NEXT: andl $-11, %esi
557 ; CHECK-NEXT: leal (%rdi,%rsi), %ebx
558 ; CHECK-NEXT: movl %esi, %edi
559 ; CHECK-NEXT: callq use_i32@PLT
560 ; CHECK-NEXT: movl %ebx, %eax
561 ; CHECK-NEXT: popq %rbx
565 %mxy = and i32 %xy, -11
566 %r = or i32 %mx, %mxy
567 call void @use_i32(i32 %mxy)
571 define i32 @or_and_multiuse_and_i32(i32 %x, i32 %y) nounwind {
572 ; CHECK-LABEL: or_and_multiuse_and_i32:
574 ; CHECK-NEXT: pushq %rbx
575 ; CHECK-NEXT: # kill: def $esi killed $esi def $rsi
576 ; CHECK-NEXT: # kill: def $edi killed $edi def $rdi
577 ; CHECK-NEXT: orl %edi, %esi
578 ; CHECK-NEXT: andl $8, %edi
579 ; CHECK-NEXT: andl $-11, %esi
580 ; CHECK-NEXT: leal (%rsi,%rdi), %ebx
581 ; CHECK-NEXT: # kill: def $edi killed $edi killed $rdi
582 ; CHECK-NEXT: callq use_i32@PLT
583 ; CHECK-NEXT: movl %ebx, %eax
584 ; CHECK-NEXT: popq %rbx
588 %mxy = and i32 %xy, -11
589 %r = or i32 %mx, %mxy
590 call void @use_i32(i32 %mx)
594 define i32 @or_and_multiuse_and_multiuse_i32(i32 %x, i32 %y) nounwind {
595 ; CHECK-LABEL: or_and_multiuse_and_multiuse_i32:
597 ; CHECK-NEXT: pushq %rbp
598 ; CHECK-NEXT: pushq %rbx
599 ; CHECK-NEXT: pushq %rax
600 ; CHECK-NEXT: movl %esi, %ebx
601 ; CHECK-NEXT: # kill: def $edi killed $edi def $rdi
602 ; CHECK-NEXT: orl %edi, %ebx
603 ; CHECK-NEXT: andl $8, %edi
604 ; CHECK-NEXT: andl $-11, %ebx
605 ; CHECK-NEXT: leal (%rdi,%rbx), %ebp
606 ; CHECK-NEXT: # kill: def $edi killed $edi killed $rdi
607 ; CHECK-NEXT: callq use_i32@PLT
608 ; CHECK-NEXT: movl %ebx, %edi
609 ; CHECK-NEXT: callq use_i32@PLT
610 ; CHECK-NEXT: movl %ebp, %eax
611 ; CHECK-NEXT: addq $8, %rsp
612 ; CHECK-NEXT: popq %rbx
613 ; CHECK-NEXT: popq %rbp
617 %mxy = and i32 %xy, -11
618 %r = or i32 %mx, %mxy
619 call void @use_i32(i32 %mx)
620 call void @use_i32(i32 %mxy)
624 declare void @use_i32(i32)