Add a triple to switch.ll test.
[oota-llvm.git] / test / CodeGen / X86 / widen_shuffle-1.ll
1 ; RUN: llc < %s -march=x86 -mattr=+sse4.2 | FileCheck %s
2
3 target triple = "x86_64-unknown-unknown"
4
5 ; widening shuffle v3float and then a add
6 define void @shuf(<3 x float>* %dst.addr, <3 x float> %src1,<3 x float> %src2) nounwind {
7 ; CHECK-LABEL: shuf:
8 ; CHECK:       # BB#0: # %entry
9 ; CHECK-NEXT:    movl {{[0-9]+}}(%esp), %eax
10 ; CHECK-NEXT:    addps %xmm1, %xmm0
11 ; CHECK-NEXT:    extractps $2, %xmm0, 8(%eax)
12 ; CHECK-NEXT:    extractps $1, %xmm0, 4(%eax)
13 ; CHECK-NEXT:    movss %xmm0, (%eax)
14 ; CHECK-NEXT:    retl
15 entry:
16         %x = shufflevector <3 x float> %src1, <3 x float> %src2, <3 x i32> < i32 0, i32 1, i32 2>
17         %val = fadd <3 x float> %x, %src2
18         store <3 x float> %val, <3 x float>* %dst.addr
19         ret void
20 }
21
22
23 ; widening shuffle v3float with a different mask and then a add
24 define void @shuf2(<3 x float>* %dst.addr, <3 x float> %src1,<3 x float> %src2) nounwind {
25 ; CHECK-LABEL: shuf2:
26 ; CHECK:       # BB#0: # %entry
27 ; CHECK-NEXT:    movl {{[0-9]+}}(%esp), %eax
28 ; CHECK-NEXT:    blendps {{.*#+}} xmm0 = xmm0[0],xmm1[1],xmm0[2,3]
29 ; CHECK-NEXT:    addps %xmm1, %xmm0
30 ; CHECK-NEXT:    extractps $2, %xmm0, 8(%eax)
31 ; CHECK-NEXT:    extractps $1, %xmm0, 4(%eax)
32 ; CHECK-NEXT:    movss %xmm0, (%eax)
33 ; CHECK-NEXT:    retl
34 entry:
35         %x = shufflevector <3 x float> %src1, <3 x float> %src2, <3 x i32> < i32 0, i32 4, i32 2>
36         %val = fadd <3 x float> %x, %src2
37         store <3 x float> %val, <3 x float>* %dst.addr
38         ret void
39 }
40
41 ; Example of when widening a v3float operation causes the DAG to replace a node
42 ; with the operation that we are currently widening, i.e. when replacing
43 ; opA with opB, the DAG will produce new operations with opA.
44 define void @shuf3(<4 x float> %tmp10, <4 x float> %vecinit15, <4 x float>* %dst) nounwind {
45 ; CHECK-LABEL: shuf3:
46 ; CHECK:       # BB#0: # %entry
47 ; CHECK-NEXT:    movl {{[0-9]+}}(%esp), %eax
48 ; CHECK-NEXT:    shufps {{.*#+}} xmm1 = xmm1[0,0,0,0]
49 ; CHECK-NEXT:    movaps %xmm1, (%eax)
50 ; CHECK-NEXT:    retl
51 entry:
52   %shuffle.i.i.i12 = shufflevector <4 x float> %tmp10, <4 x float> %vecinit15, <4 x i32> <i32 0, i32 1, i32 4, i32 5>
53   %tmp25.i.i = shufflevector <4 x float> %shuffle.i.i.i12, <4 x float> undef, <3 x i32> <i32 0, i32 1, i32 2>
54   %tmp1.i.i = shufflevector <3 x float> %tmp25.i.i, <3 x float> zeroinitializer, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
55   %tmp3.i13 = shufflevector <4 x float> %tmp1.i.i, <4 x float> undef, <3 x i32> <i32 0, i32 1, i32 2> ; <<3 x float>>
56   %tmp6.i14 = shufflevector <3 x float> %tmp3.i13, <3 x float> zeroinitializer, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
57   %tmp97.i = shufflevector <4 x float> %tmp6.i14, <4 x float> undef, <3 x i32> <i32 0, i32 1, i32 2>
58   %tmp2.i18 = shufflevector <3 x float> %tmp97.i, <3 x float> undef, <4 x i32> <i32 0, i32 1, i32 2, i32 2>
59   %t5 = bitcast <4 x float> %tmp2.i18 to <4 x i32>
60   %shr.i.i19 = lshr <4 x i32> %t5, <i32 19, i32 19, i32 19, i32 19>
61   %and.i.i20 = and <4 x i32> %shr.i.i19, <i32 4080, i32 4080, i32 4080, i32 4080>
62   %shuffle.i.i.i21 = shufflevector <4 x float> %tmp2.i18, <4 x float> undef, <4 x i32> <i32 2, i32 3, i32 2, i32 3>
63   store <4 x float> %shuffle.i.i.i21, <4 x float>* %dst
64   ret void
65 }
66
67 ; PR10421: make sure we correctly handle extreme widening with CONCAT_VECTORS
68 define <8 x i8> @shuf4(<4 x i8> %a, <4 x i8> %b) nounwind readnone {
69 ; CHECK-LABEL: shuf4:
70 ; CHECK:       # BB#0:
71 ; CHECK-NEXT:    movdqa {{.*#+}} xmm2 = [0,1,4,5,8,9,12,13,8,9,12,13,12,13,14,15]
72 ; CHECK-NEXT:    pshufb %xmm2, %xmm1
73 ; CHECK-NEXT:    pshufb %xmm2, %xmm0
74 ; CHECK-NEXT:    punpcklqdq {{.*#+}} xmm0 = xmm0[0],xmm1[0]
75 ; CHECK-NEXT:    retl
76   %vshuf = shufflevector <4 x i8> %a, <4 x i8> %b, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
77   ret <8 x i8> %vshuf
78 }
79
80 ; PR11389: another CONCAT_VECTORS case
81 define void @shuf5(<8 x i8>* %p) nounwind {
82 ; CHECK-LABEL: shuf5:
83 ; CHECK:       # BB#0:
84 ; CHECK-NEXT:    movl {{[0-9]+}}(%esp), %eax
85 ; CHECK-NEXT:    movdqa {{.*#+}} xmm0 = [33,33,33,33,33,33,33,33]
86 ; CHECK-NEXT:    pshufb {{.*#+}} xmm0 = xmm0[0,2,4,6,8,10,12,14,u,u,u,u,u,u,u,u]
87 ; CHECK-NEXT:    movq %xmm0, (%eax)
88 ; CHECK-NEXT:    retl
89   %v = shufflevector <2 x i8> <i8 4, i8 33>, <2 x i8> undef, <8 x i32> <i32 1, i32 1, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef>
90   store <8 x i8> %v, <8 x i8>* %p, align 8
91   ret void
92 }