1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+sse2 | FileCheck %s --check-prefix=SSE --check-prefix=SSE2
3 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+sse4.1 | FileCheck %s --check-prefix=SSE --check-prefix=SSE41
4 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx | FileCheck %s --check-prefix=AVX
6 define <16 x i8> @v16i8_icmp_uge(<16 x i8> %a, <16 x i8> %b) nounwind readnone ssp uwtable {
7 ; SSE-LABEL: v16i8_icmp_uge:
9 ; SSE-NEXT: pmaxub %xmm0, %xmm1
10 ; SSE-NEXT: pcmpeqb %xmm1, %xmm0
13 ; AVX-LABEL: v16i8_icmp_uge:
15 ; AVX-NEXT: vpmaxub %xmm1, %xmm0, %xmm1
16 ; AVX-NEXT: vpcmpeqb %xmm1, %xmm0, %xmm0
18 %1 = icmp uge <16 x i8> %a, %b
19 %2 = sext <16 x i1> %1 to <16 x i8>
23 define <16 x i8> @v16i8_icmp_ule(<16 x i8> %a, <16 x i8> %b) nounwind readnone ssp uwtable {
24 ; SSE-LABEL: v16i8_icmp_ule:
26 ; SSE-NEXT: pminub %xmm0, %xmm1
27 ; SSE-NEXT: pcmpeqb %xmm1, %xmm0
30 ; AVX-LABEL: v16i8_icmp_ule:
32 ; AVX-NEXT: vpminub %xmm1, %xmm0, %xmm1
33 ; AVX-NEXT: vpcmpeqb %xmm1, %xmm0, %xmm0
35 %1 = icmp ule <16 x i8> %a, %b
36 %2 = sext <16 x i1> %1 to <16 x i8>
40 define <8 x i16> @v8i16_icmp_uge(<8 x i16> %a, <8 x i16> %b) nounwind readnone ssp uwtable {
41 ; SSE2-LABEL: v8i16_icmp_uge:
43 ; SSE2-NEXT: psubusw %xmm0, %xmm1
44 ; SSE2-NEXT: pxor %xmm0, %xmm0
45 ; SSE2-NEXT: pcmpeqw %xmm1, %xmm0
48 ; SSE41-LABEL: v8i16_icmp_uge:
50 ; SSE41-NEXT: pmaxuw %xmm0, %xmm1
51 ; SSE41-NEXT: pcmpeqw %xmm1, %xmm0
54 ; AVX-LABEL: v8i16_icmp_uge:
56 ; AVX-NEXT: vpmaxuw %xmm1, %xmm0, %xmm1
57 ; AVX-NEXT: vpcmpeqw %xmm1, %xmm0, %xmm0
59 %1 = icmp uge <8 x i16> %a, %b
60 %2 = sext <8 x i1> %1 to <8 x i16>
64 define <8 x i16> @v8i16_icmp_ule(<8 x i16> %a, <8 x i16> %b) nounwind readnone ssp uwtable {
65 ; SSE2-LABEL: v8i16_icmp_ule:
67 ; SSE2-NEXT: psubusw %xmm1, %xmm0
68 ; SSE2-NEXT: pxor %xmm1, %xmm1
69 ; SSE2-NEXT: pcmpeqw %xmm1, %xmm0
72 ; SSE41-LABEL: v8i16_icmp_ule:
74 ; SSE41-NEXT: pminuw %xmm0, %xmm1
75 ; SSE41-NEXT: pcmpeqw %xmm1, %xmm0
78 ; AVX-LABEL: v8i16_icmp_ule:
80 ; AVX-NEXT: vpminuw %xmm1, %xmm0, %xmm1
81 ; AVX-NEXT: vpcmpeqw %xmm1, %xmm0, %xmm0
83 %1 = icmp ule <8 x i16> %a, %b
84 %2 = sext <8 x i1> %1 to <8 x i16>
88 define <4 x i32> @v4i32_icmp_uge(<4 x i32> %a, <4 x i32> %b) nounwind readnone ssp uwtable {
89 ; SSE2-LABEL: v4i32_icmp_uge:
91 ; SSE2-NEXT: movdqa {{.*#+}} xmm2 = [2147483648,2147483648,2147483648,2147483648]
92 ; SSE2-NEXT: pxor %xmm2, %xmm0
93 ; SSE2-NEXT: pxor %xmm1, %xmm2
94 ; SSE2-NEXT: pcmpgtd %xmm0, %xmm2
95 ; SSE2-NEXT: pcmpeqd %xmm0, %xmm0
96 ; SSE2-NEXT: pxor %xmm2, %xmm0
99 ; SSE41-LABEL: v4i32_icmp_uge:
101 ; SSE41-NEXT: pmaxud %xmm0, %xmm1
102 ; SSE41-NEXT: pcmpeqd %xmm1, %xmm0
105 ; AVX-LABEL: v4i32_icmp_uge:
107 ; AVX-NEXT: vpmaxud %xmm1, %xmm0, %xmm1
108 ; AVX-NEXT: vpcmpeqd %xmm1, %xmm0, %xmm0
110 %1 = icmp uge <4 x i32> %a, %b
111 %2 = sext <4 x i1> %1 to <4 x i32>
115 define <4 x i32> @v4i32_icmp_ule(<4 x i32> %a, <4 x i32> %b) nounwind readnone ssp uwtable {
116 ; SSE2-LABEL: v4i32_icmp_ule:
118 ; SSE2-NEXT: movdqa {{.*#+}} xmm2 = [2147483648,2147483648,2147483648,2147483648]
119 ; SSE2-NEXT: pxor %xmm2, %xmm1
120 ; SSE2-NEXT: pxor %xmm2, %xmm0
121 ; SSE2-NEXT: pcmpgtd %xmm1, %xmm0
122 ; SSE2-NEXT: pcmpeqd %xmm1, %xmm1
123 ; SSE2-NEXT: pxor %xmm1, %xmm0
126 ; SSE41-LABEL: v4i32_icmp_ule:
128 ; SSE41-NEXT: pminud %xmm0, %xmm1
129 ; SSE41-NEXT: pcmpeqd %xmm1, %xmm0
132 ; AVX-LABEL: v4i32_icmp_ule:
134 ; AVX-NEXT: vpminud %xmm1, %xmm0, %xmm1
135 ; AVX-NEXT: vpcmpeqd %xmm1, %xmm0, %xmm0
137 %1 = icmp ule <4 x i32> %a, %b
138 %2 = sext <4 x i1> %1 to <4 x i32>
142 define <16 x i8> @or_icmp_eq_const_1bit_diff(<16 x i8> %x) {
143 ; SSE-LABEL: or_icmp_eq_const_1bit_diff:
145 ; SSE-NEXT: movdqa {{.*#+}} xmm1 = [43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43]
146 ; SSE-NEXT: pcmpeqb %xmm0, %xmm1
147 ; SSE-NEXT: pcmpeqb {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
148 ; SSE-NEXT: por %xmm1, %xmm0
151 ; AVX-LABEL: or_icmp_eq_const_1bit_diff:
153 ; AVX-NEXT: vpcmpeqb {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm1
154 ; AVX-NEXT: vpcmpeqb {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
155 ; AVX-NEXT: vpor %xmm0, %xmm1, %xmm0
157 %a = icmp eq <16 x i8> %x, <i8 43, i8 43, i8 43, i8 43, i8 43, i8 43, i8 43, i8 43, i8 43, i8 43, i8 43, i8 43, i8 43, i8 43, i8 43, i8 43>
158 %b = icmp eq <16 x i8> %x, <i8 45, i8 45, i8 45, i8 45, i8 45, i8 45, i8 45, i8 45, i8 45, i8 45, i8 45, i8 45, i8 45, i8 45, i8 45, i8 45>
159 %ax = sext <16 x i1> %a to <16 x i8>
160 %bx = sext <16 x i1> %b to <16 x i8>
161 %r = or <16 x i8> %ax, %bx
165 define <4 x i32> @or_icmp_ne_const_1bit_diff(<4 x i32> %x) {
166 ; SSE-LABEL: or_icmp_ne_const_1bit_diff:
168 ; SSE-NEXT: movdqa {{.*#+}} xmm1 = [44,60,44,60]
169 ; SSE-NEXT: pcmpeqd %xmm0, %xmm1
170 ; SSE-NEXT: pcmpeqd %xmm2, %xmm2
171 ; SSE-NEXT: pxor %xmm2, %xmm1
172 ; SSE-NEXT: pcmpeqd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
173 ; SSE-NEXT: pxor %xmm2, %xmm0
174 ; SSE-NEXT: por %xmm1, %xmm0
177 ; AVX-LABEL: or_icmp_ne_const_1bit_diff:
179 ; AVX-NEXT: vpcmpeqd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm1
180 ; AVX-NEXT: vpcmpeqd %xmm2, %xmm2, %xmm2
181 ; AVX-NEXT: vpxor %xmm2, %xmm1, %xmm1
182 ; AVX-NEXT: vpcmpeqd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
183 ; AVX-NEXT: vpxor %xmm2, %xmm0, %xmm0
184 ; AVX-NEXT: vpor %xmm0, %xmm1, %xmm0
186 %a = icmp ne <4 x i32> %x, <i32 44, i32 60, i32 44, i32 60>
187 %b = icmp ne <4 x i32> %x, <i32 60, i32 44, i32 60, i32 44>
188 %ax = sext <4 x i1> %a to <4 x i32>
189 %bx = sext <4 x i1> %b to <4 x i32>
190 %r = or <4 x i32> %ax, %bx
194 define <16 x i8> @and_icmp_eq_const_1bit_diff(<16 x i8> %x) {
195 ; SSE-LABEL: and_icmp_eq_const_1bit_diff:
197 ; SSE-NEXT: movdqa {{.*#+}} xmm1 = [43,43,45,45,43,43,45,45,43,43,45,45,43,43,45,45]
198 ; SSE-NEXT: pcmpeqb %xmm0, %xmm1
199 ; SSE-NEXT: pcmpeqb {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
200 ; SSE-NEXT: pand %xmm1, %xmm0
203 ; AVX-LABEL: and_icmp_eq_const_1bit_diff:
205 ; AVX-NEXT: vpcmpeqb {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm1
206 ; AVX-NEXT: vpcmpeqb {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
207 ; AVX-NEXT: vpand %xmm0, %xmm1, %xmm0
209 %a = icmp eq <16 x i8> %x, <i8 43, i8 43, i8 45, i8 45, i8 43, i8 43, i8 45, i8 45, i8 43, i8 43, i8 45, i8 45, i8 43, i8 43, i8 45, i8 45>
210 %b = icmp eq <16 x i8> %x, <i8 45, i8 45, i8 43, i8 43, i8 45, i8 45, i8 43, i8 43, i8 45, i8 45, i8 43, i8 43, i8 45, i8 45, i8 43, i8 43>
211 %ax = sext <16 x i1> %a to <16 x i8>
212 %bx = sext <16 x i1> %b to <16 x i8>
213 %r = and <16 x i8> %ax, %bx
217 define <4 x i32> @and_icmp_ne_const_1bit_diff(<4 x i32> %x) {
218 ; SSE-LABEL: and_icmp_ne_const_1bit_diff:
220 ; SSE-NEXT: movdqa {{.*#+}} xmm1 = [44,60,54,44]
221 ; SSE-NEXT: pcmpeqd %xmm0, %xmm1
222 ; SSE-NEXT: pcmpeqd %xmm2, %xmm2
223 ; SSE-NEXT: pxor %xmm2, %xmm1
224 ; SSE-NEXT: pcmpeqd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
225 ; SSE-NEXT: pxor %xmm2, %xmm0
226 ; SSE-NEXT: por %xmm1, %xmm0
229 ; AVX-LABEL: and_icmp_ne_const_1bit_diff:
231 ; AVX-NEXT: vpcmpeqd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm1
232 ; AVX-NEXT: vpcmpeqd %xmm2, %xmm2, %xmm2
233 ; AVX-NEXT: vpxor %xmm2, %xmm1, %xmm1
234 ; AVX-NEXT: vpcmpeqd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
235 ; AVX-NEXT: vpxor %xmm2, %xmm0, %xmm0
236 ; AVX-NEXT: vpor %xmm0, %xmm1, %xmm0
238 %a = icmp ne <4 x i32> %x, <i32 44, i32 60, i32 54, i32 44>
239 %b = icmp ne <4 x i32> %x, <i32 60, i32 52, i32 50, i32 60>
240 %ax = sext <4 x i1> %a to <4 x i32>
241 %bx = sext <4 x i1> %b to <4 x i32>
242 %r = or <4 x i32> %ax, %bx
246 ; At one point we were incorrectly constant-folding a setcc to 0x1 instead of
247 ; 0xff, leading to a constpool load. The instruction doesn't matter here, but it
248 ; should set all bits to 1.
249 define <16 x i8> @test_setcc_constfold_vi8(<16 x i8> %l, <16 x i8> %r) {
250 ; SSE-LABEL: test_setcc_constfold_vi8:
252 ; SSE-NEXT: pcmpeqd %xmm0, %xmm0
255 ; AVX-LABEL: test_setcc_constfold_vi8:
257 ; AVX-NEXT: vpcmpeqd %xmm0, %xmm0, %xmm0
259 %test1 = icmp eq <16 x i8> %l, %r
260 %mask1 = sext <16 x i1> %test1 to <16 x i8>
261 %test2 = icmp ne <16 x i8> %l, %r
262 %mask2 = sext <16 x i1> %test2 to <16 x i8>
263 %res = or <16 x i8> %mask1, %mask2
267 ; Make sure sensible results come from doing extension afterwards
268 define <16 x i8> @test_setcc_constfold_vi1(<16 x i8> %l, <16 x i8> %r) {
269 ; SSE-LABEL: test_setcc_constfold_vi1:
271 ; SSE-NEXT: pcmpeqd %xmm0, %xmm0
274 ; AVX-LABEL: test_setcc_constfold_vi1:
276 ; AVX-NEXT: vpcmpeqd %xmm0, %xmm0, %xmm0
278 %test1 = icmp eq <16 x i8> %l, %r
279 %test2 = icmp ne <16 x i8> %l, %r
280 %res = or <16 x i1> %test1, %test2
281 %mask = sext <16 x i1> %res to <16 x i8>
285 ; 64-bit case is also particularly important, as the constant "-1" is probably
287 define <2 x i64> @test_setcc_constfold_vi64(<2 x i64> %l, <2 x i64> %r) {
288 ; SSE-LABEL: test_setcc_constfold_vi64:
290 ; SSE-NEXT: pcmpeqd %xmm0, %xmm0
293 ; AVX-LABEL: test_setcc_constfold_vi64:
295 ; AVX-NEXT: vpcmpeqd %xmm0, %xmm0, %xmm0
297 %test1 = icmp eq <2 x i64> %l, %r
298 %mask1 = sext <2 x i1> %test1 to <2 x i64>
299 %test2 = icmp ne <2 x i64> %l, %r
300 %mask2 = sext <2 x i1> %test2 to <2 x i64>
301 %res = or <2 x i64> %mask1, %mask2
305 ; This asserted in type legalization for v3i1 setcc after v3i16 was made
306 ; a simple value type.
307 define <3 x i1> @test_setcc_v3i1_v3i16(ptr %a) nounwind {
308 ; SSE2-LABEL: test_setcc_v3i1_v3i16:
310 ; SSE2-NEXT: movq {{.*#+}} xmm0 = mem[0],zero
311 ; SSE2-NEXT: pxor %xmm1, %xmm1
312 ; SSE2-NEXT: pcmpeqw %xmm0, %xmm1
313 ; SSE2-NEXT: punpcklwd {{.*#+}} xmm1 = xmm1[0,0,1,1,2,2,3,3]
314 ; SSE2-NEXT: movdqa %xmm1, -{{[0-9]+}}(%rsp)
315 ; SSE2-NEXT: movzbl -{{[0-9]+}}(%rsp), %eax
316 ; SSE2-NEXT: movzbl -{{[0-9]+}}(%rsp), %edx
317 ; SSE2-NEXT: movzbl -{{[0-9]+}}(%rsp), %ecx
320 ; SSE41-LABEL: test_setcc_v3i1_v3i16:
322 ; SSE41-NEXT: movq {{.*#+}} xmm0 = mem[0],zero
323 ; SSE41-NEXT: pxor %xmm1, %xmm1
324 ; SSE41-NEXT: pcmpeqw %xmm0, %xmm1
325 ; SSE41-NEXT: movd %xmm1, %eax
326 ; SSE41-NEXT: pextrb $2, %xmm1, %edx
327 ; SSE41-NEXT: pextrb $4, %xmm1, %ecx
328 ; SSE41-NEXT: # kill: def $al killed $al killed $eax
329 ; SSE41-NEXT: # kill: def $dl killed $dl killed $edx
330 ; SSE41-NEXT: # kill: def $cl killed $cl killed $ecx
333 ; AVX-LABEL: test_setcc_v3i1_v3i16:
335 ; AVX-NEXT: vmovq {{.*#+}} xmm0 = mem[0],zero
336 ; AVX-NEXT: vpxor %xmm1, %xmm1, %xmm1
337 ; AVX-NEXT: vpcmpeqw %xmm1, %xmm0, %xmm0
338 ; AVX-NEXT: vmovd %xmm0, %eax
339 ; AVX-NEXT: vpextrb $2, %xmm0, %edx
340 ; AVX-NEXT: vpextrb $4, %xmm0, %ecx
341 ; AVX-NEXT: # kill: def $al killed $al killed $eax
342 ; AVX-NEXT: # kill: def $dl killed $dl killed $edx
343 ; AVX-NEXT: # kill: def $cl killed $cl killed $ecx
345 %b = load <3 x i16>, ptr %a
346 %cmp = icmp eq <3 x i16> %b, <i16 0, i16 0, i16 0>