1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc < %s -mtriple=i386-unknown -mattr=+sse2,+ssse3 | FileCheck %s --check-prefix=X32
3; RUN: llc < %s -mtriple=x86_64-unknown -mattr=+sse2,+ssse3 | FileCheck %s --check-prefixes=X64,ALIGN
4; RUN: llc < %s -mtriple=x86_64-unknown -mattr=+sse2,+ssse3,sse-unaligned-mem | FileCheck %s --check-prefixes=X64,UNALIGN
5
6; There are no MMX operations in @t1
7
8define void  @t1(i32 %a, x86_mmx* %P) nounwind {
9; X32-LABEL: t1:
10; X32:       # %bb.0:
11; X32-NEXT:    movl {{[0-9]+}}(%esp), %eax
12; X32-NEXT:    movl {{[0-9]+}}(%esp), %ecx
13; X32-NEXT:    shll $12, %ecx
14; X32-NEXT:    movd %ecx, %xmm0
15; X32-NEXT:    psllq $32, %xmm0
16; X32-NEXT:    movq %xmm0, (%eax)
17; X32-NEXT:    retl
18;
19; X64-LABEL: t1:
20; X64:       # %bb.0:
21; X64-NEXT:    shll $12, %edi
22; X64-NEXT:    movd %edi, %xmm0
23; X64-NEXT:    psllq $32, %xmm0
24; X64-NEXT:    movq %xmm0, (%rsi)
25; X64-NEXT:    retq
26 %tmp12 = shl i32 %a, 12
27 %tmp21 = insertelement <2 x i32> undef, i32 %tmp12, i32 1
28 %tmp22 = insertelement <2 x i32> %tmp21, i32 0, i32 0
29 %tmp23 = bitcast <2 x i32> %tmp22 to x86_mmx
30 store x86_mmx %tmp23, x86_mmx* %P
31 ret void
32}
33
34define <4 x float> @t2(<4 x float>* %P) nounwind {
35; X32-LABEL: t2:
36; X32:       # %bb.0:
37; X32-NEXT:    movl {{[0-9]+}}(%esp), %eax
38; X32-NEXT:    xorps %xmm0, %xmm0
39; X32-NEXT:    xorps %xmm1, %xmm1
40; X32-NEXT:    unpcklpd {{.*#+}} xmm1 = xmm1[0],mem[0]
41; X32-NEXT:    shufps {{.*#+}} xmm0 = xmm0[0,1],xmm1[0,2]
42; X32-NEXT:    retl
43;
44; X64-LABEL: t2:
45; X64:       # %bb.0:
46; X64-NEXT:    xorps %xmm0, %xmm0
47; X64-NEXT:    xorps %xmm1, %xmm1
48; X64-NEXT:    unpcklpd {{.*#+}} xmm1 = xmm1[0],mem[0]
49; X64-NEXT:    shufps {{.*#+}} xmm0 = xmm0[0,1],xmm1[0,2]
50; X64-NEXT:    retq
51  %tmp1 = load <4 x float>, <4 x float>* %P
52  %tmp2 = shufflevector <4 x float> %tmp1, <4 x float> zeroinitializer, <4 x i32> < i32 4, i32 4, i32 4, i32 0 >
53  ret <4 x float> %tmp2
54}
55
56define <4 x float> @t3(<4 x float>* %P) nounwind {
57; X32-LABEL: t3:
58; X32:       # %bb.0:
59; X32-NEXT:    movl {{[0-9]+}}(%esp), %eax
60; X32-NEXT:    xorps %xmm0, %xmm0
61; X32-NEXT:    movlps {{.*#+}} xmm0 = mem[0,1],xmm0[2,3]
62; X32-NEXT:    retl
63;
64; X64-LABEL: t3:
65; X64:       # %bb.0:
66; X64-NEXT:    xorps %xmm0, %xmm0
67; X64-NEXT:    movlps {{.*#+}} xmm0 = mem[0,1],xmm0[2,3]
68; X64-NEXT:    retq
69  %tmp1 = load <4 x float>, <4 x float>* %P
70  %tmp2 = shufflevector <4 x float> %tmp1, <4 x float> zeroinitializer, <4 x i32> < i32 2, i32 3, i32 4, i32 4 >
71  ret <4 x float> %tmp2
72}
73
74define <4 x float> @t4(<4 x float>* %P) nounwind {
75; X32-LABEL: t4:
76; X32:       # %bb.0:
77; X32-NEXT:    movl {{[0-9]+}}(%esp), %eax
78; X32-NEXT:    xorps %xmm1, %xmm1
79; X32-NEXT:    xorps %xmm0, %xmm0
80; X32-NEXT:    shufps {{.*#+}} xmm0 = xmm0[1,0],mem[3,0]
81; X32-NEXT:    shufps {{.*#+}} xmm0 = xmm0[2,0],xmm1[2,3]
82; X32-NEXT:    retl
83;
84; X64-LABEL: t4:
85; X64:       # %bb.0:
86; X64-NEXT:    xorps %xmm1, %xmm1
87; X64-NEXT:    xorps %xmm0, %xmm0
88; X64-NEXT:    shufps {{.*#+}} xmm0 = xmm0[1,0],mem[3,0]
89; X64-NEXT:    shufps {{.*#+}} xmm0 = xmm0[2,0],xmm1[2,3]
90; X64-NEXT:    retq
91  %tmp1 = load <4 x float>, <4 x float>* %P
92  %tmp2 = shufflevector <4 x float> zeroinitializer, <4 x float> %tmp1, <4 x i32> < i32 7, i32 0, i32 0, i32 0 >
93  ret <4 x float> %tmp2
94}
95
96define <4 x float> @t4_under_aligned(<4 x float>* %P) nounwind {
97; X32-LABEL: t4_under_aligned:
98; X32:       # %bb.0:
99; X32-NEXT:    movl {{[0-9]+}}(%esp), %eax
100; X32-NEXT:    movups (%eax), %xmm1
101; X32-NEXT:    xorps %xmm2, %xmm2
102; X32-NEXT:    xorps %xmm0, %xmm0
103; X32-NEXT:    shufps {{.*#+}} xmm0 = xmm0[1,0],xmm1[3,0]
104; X32-NEXT:    shufps {{.*#+}} xmm0 = xmm0[2,0],xmm2[2,3]
105; X32-NEXT:    retl
106;
107; ALIGN-LABEL: t4_under_aligned:
108; ALIGN:       # %bb.0:
109; ALIGN-NEXT:    movups (%rdi), %xmm1
110; ALIGN-NEXT:    xorps %xmm2, %xmm2
111; ALIGN-NEXT:    xorps %xmm0, %xmm0
112; ALIGN-NEXT:    shufps {{.*#+}} xmm0 = xmm0[1,0],xmm1[3,0]
113; ALIGN-NEXT:    shufps {{.*#+}} xmm0 = xmm0[2,0],xmm2[2,3]
114; ALIGN-NEXT:    retq
115;
116; UNALIGN-LABEL: t4_under_aligned:
117; UNALIGN:       # %bb.0:
118; UNALIGN-NEXT:    xorps %xmm1, %xmm1
119; UNALIGN-NEXT:    xorps %xmm0, %xmm0
120; UNALIGN-NEXT:    shufps {{.*#+}} xmm0 = xmm0[1,0],mem[3,0]
121; UNALIGN-NEXT:    shufps {{.*#+}} xmm0 = xmm0[2,0],xmm1[2,3]
122; UNALIGN-NEXT:    retq
123  %tmp1 = load <4 x float>, <4 x float>* %P, align 4
124  %tmp2 = shufflevector <4 x float> zeroinitializer, <4 x float> %tmp1, <4 x i32> < i32 7, i32 0, i32 0, i32 0 >
125  ret <4 x float> %tmp2
126}
127
128define <16 x i8> @t5(<16 x i8> %x) nounwind {
129; X32-LABEL: t5:
130; X32:       # %bb.0:
131; X32-NEXT:    psrlw $8, %xmm0
132; X32-NEXT:    retl
133;
134; X64-LABEL: t5:
135; X64:       # %bb.0:
136; X64-NEXT:    psrlw $8, %xmm0
137; X64-NEXT:    retq
138  %s = shufflevector <16 x i8> %x, <16 x i8> zeroinitializer, <16 x i32> <i32 1, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 17>
139  ret <16 x i8> %s
140}
141
142define <16 x i8> @t6(<16 x i8> %x) nounwind {
143; X32-LABEL: t6:
144; X32:       # %bb.0:
145; X32-NEXT:    psrlw $8, %xmm0
146; X32-NEXT:    retl
147;
148; X64-LABEL: t6:
149; X64:       # %bb.0:
150; X64-NEXT:    psrlw $8, %xmm0
151; X64-NEXT:    retq
152  %s = shufflevector <16 x i8> %x, <16 x i8> undef, <16 x i32> <i32 1, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef>
153  ret <16 x i8> %s
154}
155
156define <16 x i8> @t7(<16 x i8> %x) nounwind {
157; X32-LABEL: t7:
158; X32:       # %bb.0:
159; X32-NEXT:    pslldq {{.*#+}} xmm0 = zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,xmm0[0,1,2]
160; X32-NEXT:    retl
161;
162; X64-LABEL: t7:
163; X64:       # %bb.0:
164; X64-NEXT:    pslldq {{.*#+}} xmm0 = zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,xmm0[0,1,2]
165; X64-NEXT:    retq
166  %s = shufflevector <16 x i8> %x, <16 x i8> undef, <16 x i32> <i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 1, i32 2>
167  ret <16 x i8> %s
168}
169
170define <16 x i8> @t8(<16 x i8> %x) nounwind {
171; X32-LABEL: t8:
172; X32:       # %bb.0:
173; X32-NEXT:    psrldq {{.*#+}} xmm0 = xmm0[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15],zero
174; X32-NEXT:    retl
175;
176; X64-LABEL: t8:
177; X64:       # %bb.0:
178; X64-NEXT:    psrldq {{.*#+}} xmm0 = xmm0[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15],zero
179; X64-NEXT:    retq
180  %s = shufflevector <16 x i8> %x, <16 x i8> zeroinitializer, <16 x i32> <i32 1, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 8, i32 9, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 17>
181  ret <16 x i8> %s
182}
183
184define <16 x i8> @t9(<16 x i8> %x) nounwind {
185; X32-LABEL: t9:
186; X32:       # %bb.0:
187; X32-NEXT:    psrldq {{.*#+}} xmm0 = xmm0[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15],zero
188; X32-NEXT:    retl
189;
190; X64-LABEL: t9:
191; X64:       # %bb.0:
192; X64-NEXT:    psrldq {{.*#+}} xmm0 = xmm0[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15],zero
193; X64-NEXT:    retq
194  %s = shufflevector <16 x i8> %x, <16 x i8> undef, <16 x i32> <i32 1, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 7, i32 8, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 14, i32 undef, i32 undef>
195  ret <16 x i8> %s
196}
197