1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+sse2 | FileCheck %s --check-prefixes=CHECK,X86
3 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+sse2 | FileCheck %s --check-prefixes=CHECK,X64
7 define <4 x i32> @shl4(<4 x i32> %A) nounwind {
9 ; CHECK: # %bb.0: # %entry
10 ; CHECK-NEXT: movdqa %xmm0, %xmm1
11 ; CHECK-NEXT: pslld $2, %xmm1
12 ; CHECK-NEXT: paddd %xmm0, %xmm0
13 ; CHECK-NEXT: pxor %xmm1, %xmm0
14 ; CHECK-NEXT: ret{{[l|q]}}
16 %B = shl <4 x i32> %A, < i32 2, i32 2, i32 2, i32 2>
17 %C = shl <4 x i32> %A, < i32 1, i32 1, i32 1, i32 1>
18 %K = xor <4 x i32> %B, %C
22 define <4 x i32> @shr4(<4 x i32> %A) nounwind {
24 ; CHECK: # %bb.0: # %entry
25 ; CHECK-NEXT: movdqa %xmm0, %xmm1
26 ; CHECK-NEXT: psrld $2, %xmm1
27 ; CHECK-NEXT: psrld $1, %xmm0
28 ; CHECK-NEXT: pxor %xmm1, %xmm0
29 ; CHECK-NEXT: ret{{[l|q]}}
31 %B = lshr <4 x i32> %A, < i32 2, i32 2, i32 2, i32 2>
32 %C = lshr <4 x i32> %A, < i32 1, i32 1, i32 1, i32 1>
33 %K = xor <4 x i32> %B, %C
37 define <4 x i32> @sra4(<4 x i32> %A) nounwind {
39 ; CHECK: # %bb.0: # %entry
40 ; CHECK-NEXT: movdqa %xmm0, %xmm1
41 ; CHECK-NEXT: psrad $2, %xmm1
42 ; CHECK-NEXT: psrad $1, %xmm0
43 ; CHECK-NEXT: pxor %xmm1, %xmm0
44 ; CHECK-NEXT: ret{{[l|q]}}
46 %B = ashr <4 x i32> %A, < i32 2, i32 2, i32 2, i32 2>
47 %C = ashr <4 x i32> %A, < i32 1, i32 1, i32 1, i32 1>
48 %K = xor <4 x i32> %B, %C
52 define <2 x i64> @shl2(<2 x i64> %A) nounwind {
54 ; CHECK: # %bb.0: # %entry
55 ; CHECK-NEXT: movdqa %xmm0, %xmm1
56 ; CHECK-NEXT: psllq $2, %xmm1
57 ; CHECK-NEXT: psllq $9, %xmm0
58 ; CHECK-NEXT: pxor %xmm1, %xmm0
59 ; CHECK-NEXT: ret{{[l|q]}}
61 %B = shl <2 x i64> %A, < i64 2, i64 2>
62 %C = shl <2 x i64> %A, < i64 9, i64 9>
63 %K = xor <2 x i64> %B, %C
67 define <2 x i64> @shr2(<2 x i64> %A) nounwind {
69 ; CHECK: # %bb.0: # %entry
70 ; CHECK-NEXT: movdqa %xmm0, %xmm1
71 ; CHECK-NEXT: psrlq $8, %xmm1
72 ; CHECK-NEXT: psrlq $1, %xmm0
73 ; CHECK-NEXT: pxor %xmm1, %xmm0
74 ; CHECK-NEXT: ret{{[l|q]}}
76 %B = lshr <2 x i64> %A, < i64 8, i64 8>
77 %C = lshr <2 x i64> %A, < i64 1, i64 1>
78 %K = xor <2 x i64> %B, %C
82 define <8 x i16> @shl8(<8 x i16> %A) nounwind {
84 ; CHECK: # %bb.0: # %entry
85 ; CHECK-NEXT: movdqa %xmm0, %xmm1
86 ; CHECK-NEXT: psllw $2, %xmm1
87 ; CHECK-NEXT: paddw %xmm0, %xmm0
88 ; CHECK-NEXT: pxor %xmm1, %xmm0
89 ; CHECK-NEXT: ret{{[l|q]}}
91 %B = shl <8 x i16> %A, < i16 2, i16 2, i16 2, i16 2, i16 2, i16 2, i16 2, i16 2>
92 %C = shl <8 x i16> %A, < i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>
93 %K = xor <8 x i16> %B, %C
97 define <8 x i16> @shr8(<8 x i16> %A) nounwind {
99 ; CHECK: # %bb.0: # %entry
100 ; CHECK-NEXT: movdqa %xmm0, %xmm1
101 ; CHECK-NEXT: psrlw $2, %xmm1
102 ; CHECK-NEXT: psrlw $1, %xmm0
103 ; CHECK-NEXT: pxor %xmm1, %xmm0
104 ; CHECK-NEXT: ret{{[l|q]}}
106 %B = lshr <8 x i16> %A, < i16 2, i16 2, i16 2, i16 2, i16 2, i16 2, i16 2, i16 2>
107 %C = lshr <8 x i16> %A, < i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>
108 %K = xor <8 x i16> %B, %C
112 define <8 x i16> @sra8(<8 x i16> %A) nounwind {
114 ; CHECK: # %bb.0: # %entry
115 ; CHECK-NEXT: movdqa %xmm0, %xmm1
116 ; CHECK-NEXT: psraw $2, %xmm1
117 ; CHECK-NEXT: psraw $1, %xmm0
118 ; CHECK-NEXT: pxor %xmm1, %xmm0
119 ; CHECK-NEXT: ret{{[l|q]}}
121 %B = ashr <8 x i16> %A, < i16 2, i16 2, i16 2, i16 2, i16 2, i16 2, i16 2, i16 2>
122 %C = ashr <8 x i16> %A, < i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>
123 %K = xor <8 x i16> %B, %C
129 define <8 x i16> @sll8_nosplat(<8 x i16> %A) nounwind {
130 ; X86-LABEL: sll8_nosplat:
131 ; X86: # %bb.0: # %entry
132 ; X86-NEXT: movdqa {{.*#+}} xmm1 = [2,4,8,64,4,4,4,4]
133 ; X86-NEXT: pmullw %xmm0, %xmm1
134 ; X86-NEXT: pmullw {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0
135 ; X86-NEXT: pxor %xmm1, %xmm0
138 ; X64-LABEL: sll8_nosplat:
139 ; X64: # %bb.0: # %entry
140 ; X64-NEXT: movdqa {{.*#+}} xmm1 = [2,4,8,64,4,4,4,4]
141 ; X64-NEXT: pmullw %xmm0, %xmm1
142 ; X64-NEXT: pmullw {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
143 ; X64-NEXT: pxor %xmm1, %xmm0
146 %B = shl <8 x i16> %A, < i16 1, i16 2, i16 3, i16 6, i16 2, i16 2, i16 2, i16 2>
147 %C = shl <8 x i16> %A, < i16 9, i16 7, i16 5, i16 1, i16 4, i16 1, i16 1, i16 1>
148 %K = xor <8 x i16> %B, %C
152 define <2 x i64> @shr2_nosplat(<2 x i64> %A) nounwind {
153 ; CHECK-LABEL: shr2_nosplat:
154 ; CHECK: # %bb.0: # %entry
155 ; CHECK-NEXT: movdqa %xmm0, %xmm2
156 ; CHECK-NEXT: psrlq $8, %xmm2
157 ; CHECK-NEXT: movdqa %xmm0, %xmm1
158 ; CHECK-NEXT: psrlq $1, %xmm1
159 ; CHECK-NEXT: shufps {{.*#+}} xmm2 = xmm2[0,1],xmm1[2,3]
160 ; CHECK-NEXT: shufps {{.*#+}} xmm1 = xmm1[0,1],xmm0[2,3]
161 ; CHECK-NEXT: xorps %xmm2, %xmm1
162 ; CHECK-NEXT: movaps %xmm1, %xmm0
163 ; CHECK-NEXT: ret{{[l|q]}}
165 %B = lshr <2 x i64> %A, < i64 8, i64 1>
166 %C = lshr <2 x i64> %A, < i64 1, i64 0>
167 %K = xor <2 x i64> %B, %C
173 define <2 x i32> @shl2_other(<2 x i32> %A) nounwind {
174 ; CHECK-LABEL: shl2_other:
175 ; CHECK: # %bb.0: # %entry
176 ; CHECK-NEXT: movdqa %xmm0, %xmm1
177 ; CHECK-NEXT: pslld $2, %xmm1
178 ; CHECK-NEXT: pslld $9, %xmm0
179 ; CHECK-NEXT: pxor %xmm1, %xmm0
180 ; CHECK-NEXT: ret{{[l|q]}}
182 %B = shl <2 x i32> %A, < i32 2, i32 2>
183 %C = shl <2 x i32> %A, < i32 9, i32 9>
184 %K = xor <2 x i32> %B, %C
188 define <2 x i32> @shr2_other(<2 x i32> %A) nounwind {
189 ; CHECK-LABEL: shr2_other:
190 ; CHECK: # %bb.0: # %entry
191 ; CHECK-NEXT: movdqa %xmm0, %xmm1
192 ; CHECK-NEXT: psrld $8, %xmm1
193 ; CHECK-NEXT: psrld $1, %xmm0
194 ; CHECK-NEXT: pxor %xmm1, %xmm0
195 ; CHECK-NEXT: ret{{[l|q]}}
197 %B = lshr <2 x i32> %A, < i32 8, i32 8>
198 %C = lshr <2 x i32> %A, < i32 1, i32 1>
199 %K = xor <2 x i32> %B, %C
203 define <16 x i8> @shl9(<16 x i8> %A) nounwind {
206 ; X86-NEXT: psllw $3, %xmm0
207 ; X86-NEXT: pand {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0
212 ; X64-NEXT: psllw $3, %xmm0
213 ; X64-NEXT: pand {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
215 %B = shl <16 x i8> %A, <i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3>
219 define <16 x i8> @shr9(<16 x i8> %A) nounwind {
222 ; X86-NEXT: psrlw $3, %xmm0
223 ; X86-NEXT: pand {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0
228 ; X64-NEXT: psrlw $3, %xmm0
229 ; X64-NEXT: pand {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
231 %B = lshr <16 x i8> %A, <i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3>
235 define <16 x i8> @sra_v16i8_7(<16 x i8> %A) nounwind {
236 ; CHECK-LABEL: sra_v16i8_7:
238 ; CHECK-NEXT: pxor %xmm1, %xmm1
239 ; CHECK-NEXT: pcmpgtb %xmm0, %xmm1
240 ; CHECK-NEXT: movdqa %xmm1, %xmm0
241 ; CHECK-NEXT: ret{{[l|q]}}
242 %B = ashr <16 x i8> %A, <i8 7, i8 7, i8 7, i8 7, i8 7, i8 7, i8 7, i8 7, i8 7, i8 7, i8 7, i8 7, i8 7, i8 7, i8 7, i8 7>
246 define <16 x i8> @sra_v16i8(<16 x i8> %A) nounwind {
247 ; X86-LABEL: sra_v16i8:
249 ; X86-NEXT: psrlw $3, %xmm0
250 ; X86-NEXT: pand {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0
251 ; X86-NEXT: movdqa {{.*#+}} xmm1 = [16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16]
252 ; X86-NEXT: pxor %xmm1, %xmm0
253 ; X86-NEXT: psubb %xmm1, %xmm0
256 ; X64-LABEL: sra_v16i8:
258 ; X64-NEXT: psrlw $3, %xmm0
259 ; X64-NEXT: pand {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
260 ; X64-NEXT: movdqa {{.*#+}} xmm1 = [16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16]
261 ; X64-NEXT: pxor %xmm1, %xmm0
262 ; X64-NEXT: psubb %xmm1, %xmm0
264 %B = ashr <16 x i8> %A, <i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3>