1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc < %s -march=x86 -mcpu=core2 -mattr=+ssse3 | FileCheck %s
3; RUN: llc < %s -march=x86 -mcpu=yonah | FileCheck --check-prefix=CHECK-YONAH %s
4
5define <4 x i32> @test1(<4 x i32> %A, <4 x i32> %B) nounwind {
6; CHECK-LABEL: test1:
7; CHECK:       # BB#0:
8; CHECK-NEXT:    pshufd {{.*#+}} xmm0 = xmm0[1,2,3,0]
9; CHECK-NEXT:    retl
10;
11; CHECK-YONAH-LABEL: test1:
12; CHECK-YONAH:       # BB#0:
13; CHECK-YONAH-NEXT:    pshufd {{.*#+}} xmm0 = xmm0[1,2,3,0]
14; CHECK-YONAH-NEXT:    retl
15  %C = shufflevector <4 x i32> %A, <4 x i32> undef, <4 x i32> < i32 1, i32 2, i32 3, i32 0 >
16	ret <4 x i32> %C
17}
18
19define <4 x i32> @test2(<4 x i32> %A, <4 x i32> %B) nounwind {
20; CHECK-LABEL: test2:
21; CHECK:       # BB#0:
22; CHECK-NEXT:    palignr {{.*#+}} xmm1 = xmm0[4,5,6,7,8,9,10,11,12,13,14,15],xmm1[0,1,2,3]
23; CHECK-NEXT:    movdqa %xmm1, %xmm0
24; CHECK-NEXT:    retl
25;
26; CHECK-YONAH-LABEL: test2:
27; CHECK-YONAH:       # BB#0:
28; CHECK-YONAH-NEXT:    shufps {{.*#+}} xmm1 = xmm1[0,0],xmm0[3,0]
29; CHECK-YONAH-NEXT:    shufps {{.*#+}} xmm0 = xmm0[1,2],xmm1[2,0]
30; CHECK-YONAH-NEXT:    retl
31  %C = shufflevector <4 x i32> %A, <4 x i32> %B, <4 x i32> < i32 1, i32 2, i32 3, i32 4 >
32	ret <4 x i32> %C
33}
34
35define <4 x i32> @test3(<4 x i32> %A, <4 x i32> %B) nounwind {
36; CHECK-LABEL: test3:
37; CHECK:       # BB#0:
38; CHECK-NEXT:    palignr {{.*#+}} xmm1 = xmm0[4,5,6,7,8,9,10,11,12,13,14,15],xmm1[0,1,2,3]
39; CHECK-NEXT:    movdqa %xmm1, %xmm0
40; CHECK-NEXT:    retl
41;
42; CHECK-YONAH-LABEL: test3:
43; CHECK-YONAH:       # BB#0:
44; CHECK-YONAH-NEXT:    pshufd {{.*#+}} xmm1 = xmm1[0,0,1,1]
45; CHECK-YONAH-NEXT:    pshufd {{.*#+}} xmm0 = xmm0[1,2,2,3]
46; CHECK-YONAH-NEXT:    punpcklqdq {{.*#+}} xmm0 = xmm0[0],xmm1[0]
47; CHECK-YONAH-NEXT:    retl
48  %C = shufflevector <4 x i32> %A, <4 x i32> %B, <4 x i32> < i32 1, i32 2, i32 undef, i32 4 >
49	ret <4 x i32> %C
50}
51
52define <4 x i32> @test4(<4 x i32> %A, <4 x i32> %B) nounwind {
53; CHECK-LABEL: test4:
54; CHECK:       # BB#0:
55; CHECK-NEXT:    palignr {{.*#+}} xmm0 = xmm1[8,9,10,11,12,13,14,15],xmm0[0,1,2,3,4,5,6,7]
56; CHECK-NEXT:    retl
57;
58; CHECK-YONAH-LABEL: test4:
59; CHECK-YONAH:       # BB#0:
60; CHECK-YONAH-NEXT:    shufpd {{.*#+}} xmm1 = xmm1[1],xmm0[0]
61; CHECK-YONAH-NEXT:    movapd %xmm1, %xmm0
62; CHECK-YONAH-NEXT:    retl
63  %C = shufflevector <4 x i32> %A, <4 x i32> %B, <4 x i32> < i32 6, i32 7, i32 undef, i32 1 >
64	ret <4 x i32> %C
65}
66
67define <4 x float> @test5(<4 x float> %A, <4 x float> %B) nounwind {
68; CHECK-LABEL: test5:
69; CHECK:       # BB#0:
70; CHECK-NEXT:    shufpd {{.*#+}} xmm1 = xmm1[1],xmm0[0]
71; CHECK-NEXT:    movapd %xmm1, %xmm0
72; CHECK-NEXT:    retl
73;
74; CHECK-YONAH-LABEL: test5:
75; CHECK-YONAH:       # BB#0:
76; CHECK-YONAH-NEXT:    shufpd {{.*#+}} xmm1 = xmm1[1],xmm0[0]
77; CHECK-YONAH-NEXT:    movapd %xmm1, %xmm0
78; CHECK-YONAH-NEXT:    retl
79  %C = shufflevector <4 x float> %A, <4 x float> %B, <4 x i32> < i32 6, i32 7, i32 undef, i32 1 >
80	ret <4 x float> %C
81}
82
83define <8 x i16> @test6(<8 x i16> %A, <8 x i16> %B) nounwind {
84; CHECK-LABEL: test6:
85; CHECK:       # BB#0:
86; CHECK-NEXT:    palignr {{.*#+}} xmm1 = xmm0[6,7,8,9,10,11,12,13,14,15],xmm1[0,1,2,3,4,5]
87; CHECK-NEXT:    movdqa %xmm1, %xmm0
88; CHECK-NEXT:    retl
89;
90; CHECK-YONAH-LABEL: test6:
91; CHECK-YONAH:       # BB#0:
92; CHECK-YONAH-NEXT:    psrldq {{.*#+}} xmm0 = xmm0[6,7,8,9,10,11,12,13,14,15],zero,zero,zero,zero,zero,zero
93; CHECK-YONAH-NEXT:    pslldq {{.*#+}} xmm1 = zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,xmm1[0,1,2,3,4,5]
94; CHECK-YONAH-NEXT:    por %xmm1, %xmm0
95; CHECK-YONAH-NEXT:    retl
96  %C = shufflevector <8 x i16> %A, <8 x i16> %B, <8 x i32> < i32 3, i32 4, i32 undef, i32 6, i32 7, i32 8, i32 9, i32 10 >
97	ret <8 x i16> %C
98}
99
100define <8 x i16> @test7(<8 x i16> %A, <8 x i16> %B) nounwind {
101; CHECK-LABEL: test7:
102; CHECK:       # BB#0:
103; CHECK-NEXT:    palignr {{.*#+}} xmm1 = xmm0[10,11,12,13,14,15],xmm1[0,1,2,3,4,5,6,7,8,9]
104; CHECK-NEXT:    movdqa %xmm1, %xmm0
105; CHECK-NEXT:    retl
106;
107; CHECK-YONAH-LABEL: test7:
108; CHECK-YONAH:       # BB#0:
109; CHECK-YONAH-NEXT:    psrldq {{.*#+}} xmm0 = xmm0[10,11,12,13,14,15],zero,zero,zero,zero,zero,zero,zero,zero,zero,zero
110; CHECK-YONAH-NEXT:    pslldq {{.*#+}} xmm1 = zero,zero,zero,zero,zero,zero,xmm1[0,1,2,3,4,5,6,7,8,9]
111; CHECK-YONAH-NEXT:    por %xmm1, %xmm0
112; CHECK-YONAH-NEXT:    retl
113  %C = shufflevector <8 x i16> %A, <8 x i16> %B, <8 x i32> < i32 undef, i32 6, i32 undef, i32 8, i32 9, i32 10, i32 11, i32 12 >
114	ret <8 x i16> %C
115}
116
117define <16 x i8> @test8(<16 x i8> %A, <16 x i8> %B) nounwind {
118; CHECK-LABEL: test8:
119; CHECK:       # BB#0:
120; CHECK-NEXT:    palignr {{.*#+}} xmm1 = xmm0[5,6,7,8,9,10,11,12,13,14,15],xmm1[0,1,2,3,4]
121; CHECK-NEXT:    movdqa %xmm1, %xmm0
122; CHECK-NEXT:    retl
123;
124; CHECK-YONAH-LABEL: test8:
125; CHECK-YONAH:       # BB#0:
126; CHECK-YONAH-NEXT:    psrldq {{.*#+}} xmm0 = xmm0[5,6,7,8,9,10,11,12,13,14,15],zero,zero,zero,zero,zero
127; CHECK-YONAH-NEXT:    pslldq {{.*#+}} xmm1 = zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,xmm1[0,1,2,3,4]
128; CHECK-YONAH-NEXT:    por %xmm1, %xmm0
129; CHECK-YONAH-NEXT:    retl
130  %C = shufflevector <16 x i8> %A, <16 x i8> %B, <16 x i32> < i32 5, i32 6, i32 7, i32 undef, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16, i32 17, i32 18, i32 19, i32 20 >
131	ret <16 x i8> %C
132}
133
134; Check that we don't do unary (circular on single operand) palignr incorrectly.
135; (It is possible, but before this testcase was committed, it was being done
136; incorrectly.  In particular, one of the operands of the palignr node
137; was an UNDEF.)
138define <8 x i16> @test9(<8 x i16> %A, <8 x i16> %B) nounwind {
139; CHECK-LABEL: test9:
140; CHECK:       # BB#0:
141; CHECK-NEXT:    palignr {{.*#+}} xmm1 = xmm1[2,3,4,5,6,7,8,9,10,11,12,13,14,15,0,1]
142; CHECK-NEXT:    movdqa %xmm1, %xmm0
143; CHECK-NEXT:    retl
144;
145; CHECK-YONAH-LABEL: test9:
146; CHECK-YONAH:       # BB#0:
147; CHECK-YONAH-NEXT:    movdqa %xmm1, %xmm0
148; CHECK-YONAH-NEXT:    psrldq {{.*#+}} xmm0 = xmm0[2,3,4,5,6,7,8,9,10,11,12,13,14,15],zero,zero
149; CHECK-YONAH-NEXT:    pslldq {{.*#+}} xmm1 = zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,xmm1[0,1]
150; CHECK-YONAH-NEXT:    por %xmm0, %xmm1
151; CHECK-YONAH-NEXT:    movdqa %xmm1, %xmm0
152; CHECK-YONAH-NEXT:    retl
153  %C = shufflevector <8 x i16> %B, <8 x i16> %A, <8 x i32> < i32 undef, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 0 >
154	ret <8 x i16> %C
155}
156
157