1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc < %s -fast-isel -mtriple=i386-unknown-unknown -mattr=+sse4.2 | FileCheck %s --check-prefixes=X86,SSE,X86-SSE
3; RUN: llc < %s -fast-isel -mtriple=i386-unknown-unknown -mattr=+avx | FileCheck %s --check-prefixes=X86,AVX,X86-AVX,AVX1
4; RUN: llc < %s -fast-isel -mtriple=i386-unknown-unknown -mattr=+avx512f,+avx512bw,+avx512dq,+avx512vl | FileCheck %s --check-prefixes=X86,AVX,X86-AVX,AVX512
5; RUN: llc < %s -fast-isel -mtriple=x86_64-unknown-unknown -mattr=+sse4.2 | FileCheck %s --check-prefixes=X64,SSE,X64-SSE
6; RUN: llc < %s -fast-isel -mtriple=x86_64-unknown-unknown -mattr=+avx | FileCheck %s --check-prefixes=X64,AVX,X64-AVX,AVX1
7; RUN: llc < %s -fast-isel -mtriple=x86_64-unknown-unknown -mattr=+avx512f,+avx512bw,+avx512dq,+avx512vl | FileCheck %s --check-prefixes=X64,AVX,X64-AVX,AVX512
8
9; NOTE: This should use IR equivalent to what is generated by clang/test/CodeGen/sse42-builtins.c
10
11define i32 @test_mm_cmpestra(<2 x i64> %a0, i32 %a1, <2 x i64> %a2, i32 %a3) nounwind {
12; X86-SSE-LABEL: test_mm_cmpestra:
13; X86-SSE:       # %bb.0:
14; X86-SSE-NEXT:    pushl %ebx
15; X86-SSE-NEXT:    movl {{[0-9]+}}(%esp), %edx
16; X86-SSE-NEXT:    movl {{[0-9]+}}(%esp), %eax
17; X86-SSE-NEXT:    xorl %ebx, %ebx
18; X86-SSE-NEXT:    pcmpestri $7, %xmm1, %xmm0
19; X86-SSE-NEXT:    seta %bl
20; X86-SSE-NEXT:    movl %ebx, %eax
21; X86-SSE-NEXT:    popl %ebx
22; X86-SSE-NEXT:    retl
23;
24; X86-AVX-LABEL: test_mm_cmpestra:
25; X86-AVX:       # %bb.0:
26; X86-AVX-NEXT:    pushl %ebx
27; X86-AVX-NEXT:    movl {{[0-9]+}}(%esp), %edx
28; X86-AVX-NEXT:    movl {{[0-9]+}}(%esp), %eax
29; X86-AVX-NEXT:    xorl %ebx, %ebx
30; X86-AVX-NEXT:    vpcmpestri $7, %xmm1, %xmm0
31; X86-AVX-NEXT:    seta %bl
32; X86-AVX-NEXT:    movl %ebx, %eax
33; X86-AVX-NEXT:    popl %ebx
34; X86-AVX-NEXT:    retl
35;
36; X64-SSE-LABEL: test_mm_cmpestra:
37; X64-SSE:       # %bb.0:
38; X64-SSE-NEXT:    movl %esi, %edx
39; X64-SSE-NEXT:    movl %edi, %eax
40; X64-SSE-NEXT:    xorl %esi, %esi
41; X64-SSE-NEXT:    pcmpestri $7, %xmm1, %xmm0
42; X64-SSE-NEXT:    seta %sil
43; X64-SSE-NEXT:    movl %esi, %eax
44; X64-SSE-NEXT:    retq
45;
46; X64-AVX-LABEL: test_mm_cmpestra:
47; X64-AVX:       # %bb.0:
48; X64-AVX-NEXT:    movl %esi, %edx
49; X64-AVX-NEXT:    movl %edi, %eax
50; X64-AVX-NEXT:    xorl %esi, %esi
51; X64-AVX-NEXT:    vpcmpestri $7, %xmm1, %xmm0
52; X64-AVX-NEXT:    seta %sil
53; X64-AVX-NEXT:    movl %esi, %eax
54; X64-AVX-NEXT:    retq
55  %arg0 = bitcast <2 x i64> %a0 to <16 x i8>
56  %arg2 = bitcast <2 x i64> %a2 to <16 x i8>
57  %res = call i32 @llvm.x86.sse42.pcmpestria128(<16 x i8> %arg0, i32 %a1, <16 x i8> %arg2, i32 %a3, i8 7)
58  ret i32 %res
59}
60declare i32 @llvm.x86.sse42.pcmpestria128(<16 x i8>, i32, <16 x i8>, i32, i8) nounwind readnone
61
62define i32 @test_mm_cmpestrc(<2 x i64> %a0, i32 %a1, <2 x i64> %a2, i32 %a3) nounwind {
63; X86-SSE-LABEL: test_mm_cmpestrc:
64; X86-SSE:       # %bb.0:
65; X86-SSE-NEXT:    pushl %ebx
66; X86-SSE-NEXT:    movl {{[0-9]+}}(%esp), %edx
67; X86-SSE-NEXT:    movl {{[0-9]+}}(%esp), %eax
68; X86-SSE-NEXT:    xorl %ebx, %ebx
69; X86-SSE-NEXT:    pcmpestri $7, %xmm1, %xmm0
70; X86-SSE-NEXT:    setb %bl
71; X86-SSE-NEXT:    movl %ebx, %eax
72; X86-SSE-NEXT:    popl %ebx
73; X86-SSE-NEXT:    retl
74;
75; X86-AVX-LABEL: test_mm_cmpestrc:
76; X86-AVX:       # %bb.0:
77; X86-AVX-NEXT:    pushl %ebx
78; X86-AVX-NEXT:    movl {{[0-9]+}}(%esp), %edx
79; X86-AVX-NEXT:    movl {{[0-9]+}}(%esp), %eax
80; X86-AVX-NEXT:    xorl %ebx, %ebx
81; X86-AVX-NEXT:    vpcmpestri $7, %xmm1, %xmm0
82; X86-AVX-NEXT:    setb %bl
83; X86-AVX-NEXT:    movl %ebx, %eax
84; X86-AVX-NEXT:    popl %ebx
85; X86-AVX-NEXT:    retl
86;
87; X64-SSE-LABEL: test_mm_cmpestrc:
88; X64-SSE:       # %bb.0:
89; X64-SSE-NEXT:    movl %esi, %edx
90; X64-SSE-NEXT:    movl %edi, %eax
91; X64-SSE-NEXT:    xorl %esi, %esi
92; X64-SSE-NEXT:    pcmpestri $7, %xmm1, %xmm0
93; X64-SSE-NEXT:    setb %sil
94; X64-SSE-NEXT:    movl %esi, %eax
95; X64-SSE-NEXT:    retq
96;
97; X64-AVX-LABEL: test_mm_cmpestrc:
98; X64-AVX:       # %bb.0:
99; X64-AVX-NEXT:    movl %esi, %edx
100; X64-AVX-NEXT:    movl %edi, %eax
101; X64-AVX-NEXT:    xorl %esi, %esi
102; X64-AVX-NEXT:    vpcmpestri $7, %xmm1, %xmm0
103; X64-AVX-NEXT:    setb %sil
104; X64-AVX-NEXT:    movl %esi, %eax
105; X64-AVX-NEXT:    retq
106  %arg0 = bitcast <2 x i64> %a0 to <16 x i8>
107  %arg2 = bitcast <2 x i64> %a2 to <16 x i8>
108  %res = call i32 @llvm.x86.sse42.pcmpestric128(<16 x i8> %arg0, i32 %a1, <16 x i8> %arg2, i32 %a3, i8 7)
109  ret i32 %res
110}
111declare i32 @llvm.x86.sse42.pcmpestric128(<16 x i8>, i32, <16 x i8>, i32, i8) nounwind readnone
112
113define i32 @test_mm_cmpestri(<2 x i64> %a0, i32 %a1, <2 x i64> %a2, i32 %a3) {
114; X86-SSE-LABEL: test_mm_cmpestri:
115; X86-SSE:       # %bb.0:
116; X86-SSE-NEXT:    movl {{[0-9]+}}(%esp), %edx
117; X86-SSE-NEXT:    movl {{[0-9]+}}(%esp), %eax
118; X86-SSE-NEXT:    pcmpestri $7, %xmm1, %xmm0
119; X86-SSE-NEXT:    movl %ecx, %eax
120; X86-SSE-NEXT:    retl
121;
122; X86-AVX-LABEL: test_mm_cmpestri:
123; X86-AVX:       # %bb.0:
124; X86-AVX-NEXT:    movl {{[0-9]+}}(%esp), %edx
125; X86-AVX-NEXT:    movl {{[0-9]+}}(%esp), %eax
126; X86-AVX-NEXT:    vpcmpestri $7, %xmm1, %xmm0
127; X86-AVX-NEXT:    movl %ecx, %eax
128; X86-AVX-NEXT:    retl
129;
130; X64-SSE-LABEL: test_mm_cmpestri:
131; X64-SSE:       # %bb.0:
132; X64-SSE-NEXT:    movl %esi, %edx
133; X64-SSE-NEXT:    movl %edi, %eax
134; X64-SSE-NEXT:    pcmpestri $7, %xmm1, %xmm0
135; X64-SSE-NEXT:    movl %ecx, %eax
136; X64-SSE-NEXT:    retq
137;
138; X64-AVX-LABEL: test_mm_cmpestri:
139; X64-AVX:       # %bb.0:
140; X64-AVX-NEXT:    movl %esi, %edx
141; X64-AVX-NEXT:    movl %edi, %eax
142; X64-AVX-NEXT:    vpcmpestri $7, %xmm1, %xmm0
143; X64-AVX-NEXT:    movl %ecx, %eax
144; X64-AVX-NEXT:    retq
145  %arg0 = bitcast <2 x i64> %a0 to <16 x i8>
146  %arg2 = bitcast <2 x i64> %a2 to <16 x i8>
147  %res = call i32 @llvm.x86.sse42.pcmpestri128(<16 x i8> %arg0, i32 %a1, <16 x i8> %arg2, i32 %a3, i8 7)
148  ret i32 %res
149}
150declare i32 @llvm.x86.sse42.pcmpestri128(<16 x i8>, i32, <16 x i8>, i32, i8) nounwind readnone
151
152define <2 x i64> @test_mm_cmpestrm(<2 x i64> %a0, i32 %a1, <2 x i64> %a2, i32 %a3) {
153; X86-SSE-LABEL: test_mm_cmpestrm:
154; X86-SSE:       # %bb.0:
155; X86-SSE-NEXT:    movl {{[0-9]+}}(%esp), %edx
156; X86-SSE-NEXT:    movl {{[0-9]+}}(%esp), %eax
157; X86-SSE-NEXT:    pcmpestrm $7, %xmm1, %xmm0
158; X86-SSE-NEXT:    retl
159;
160; X86-AVX-LABEL: test_mm_cmpestrm:
161; X86-AVX:       # %bb.0:
162; X86-AVX-NEXT:    movl {{[0-9]+}}(%esp), %edx
163; X86-AVX-NEXT:    movl {{[0-9]+}}(%esp), %eax
164; X86-AVX-NEXT:    vpcmpestrm $7, %xmm1, %xmm0
165; X86-AVX-NEXT:    retl
166;
167; X64-SSE-LABEL: test_mm_cmpestrm:
168; X64-SSE:       # %bb.0:
169; X64-SSE-NEXT:    movl %esi, %edx
170; X64-SSE-NEXT:    movl %edi, %eax
171; X64-SSE-NEXT:    pcmpestrm $7, %xmm1, %xmm0
172; X64-SSE-NEXT:    retq
173;
174; X64-AVX-LABEL: test_mm_cmpestrm:
175; X64-AVX:       # %bb.0:
176; X64-AVX-NEXT:    movl %esi, %edx
177; X64-AVX-NEXT:    movl %edi, %eax
178; X64-AVX-NEXT:    vpcmpestrm $7, %xmm1, %xmm0
179; X64-AVX-NEXT:    retq
180  %arg0 = bitcast <2 x i64> %a0 to <16 x i8>
181  %arg2 = bitcast <2 x i64> %a2 to <16 x i8>
182  %res = call <16 x i8> @llvm.x86.sse42.pcmpestrm128(<16 x i8> %arg0, i32 %a1, <16 x i8> %arg2, i32 %a3, i8 7)
183  %bc = bitcast <16 x i8> %res to <2 x i64>
184  ret <2 x i64> %bc
185}
186declare <16 x i8> @llvm.x86.sse42.pcmpestrm128(<16 x i8>, i32, <16 x i8>, i32, i8) nounwind readnone
187
188define i32 @test_mm_cmpestro(<2 x i64> %a0, i32 %a1, <2 x i64> %a2, i32 %a3) nounwind {
189; X86-SSE-LABEL: test_mm_cmpestro:
190; X86-SSE:       # %bb.0:
191; X86-SSE-NEXT:    pushl %ebx
192; X86-SSE-NEXT:    movl {{[0-9]+}}(%esp), %edx
193; X86-SSE-NEXT:    movl {{[0-9]+}}(%esp), %eax
194; X86-SSE-NEXT:    xorl %ebx, %ebx
195; X86-SSE-NEXT:    pcmpestri $7, %xmm1, %xmm0
196; X86-SSE-NEXT:    seto %bl
197; X86-SSE-NEXT:    movl %ebx, %eax
198; X86-SSE-NEXT:    popl %ebx
199; X86-SSE-NEXT:    retl
200;
201; X86-AVX-LABEL: test_mm_cmpestro:
202; X86-AVX:       # %bb.0:
203; X86-AVX-NEXT:    pushl %ebx
204; X86-AVX-NEXT:    movl {{[0-9]+}}(%esp), %edx
205; X86-AVX-NEXT:    movl {{[0-9]+}}(%esp), %eax
206; X86-AVX-NEXT:    xorl %ebx, %ebx
207; X86-AVX-NEXT:    vpcmpestri $7, %xmm1, %xmm0
208; X86-AVX-NEXT:    seto %bl
209; X86-AVX-NEXT:    movl %ebx, %eax
210; X86-AVX-NEXT:    popl %ebx
211; X86-AVX-NEXT:    retl
212;
213; X64-SSE-LABEL: test_mm_cmpestro:
214; X64-SSE:       # %bb.0:
215; X64-SSE-NEXT:    movl %esi, %edx
216; X64-SSE-NEXT:    movl %edi, %eax
217; X64-SSE-NEXT:    xorl %esi, %esi
218; X64-SSE-NEXT:    pcmpestri $7, %xmm1, %xmm0
219; X64-SSE-NEXT:    seto %sil
220; X64-SSE-NEXT:    movl %esi, %eax
221; X64-SSE-NEXT:    retq
222;
223; X64-AVX-LABEL: test_mm_cmpestro:
224; X64-AVX:       # %bb.0:
225; X64-AVX-NEXT:    movl %esi, %edx
226; X64-AVX-NEXT:    movl %edi, %eax
227; X64-AVX-NEXT:    xorl %esi, %esi
228; X64-AVX-NEXT:    vpcmpestri $7, %xmm1, %xmm0
229; X64-AVX-NEXT:    seto %sil
230; X64-AVX-NEXT:    movl %esi, %eax
231; X64-AVX-NEXT:    retq
232  %arg0 = bitcast <2 x i64> %a0 to <16 x i8>
233  %arg2 = bitcast <2 x i64> %a2 to <16 x i8>
234  %res = call i32 @llvm.x86.sse42.pcmpestrio128(<16 x i8> %arg0, i32 %a1, <16 x i8> %arg2, i32 %a3, i8 7)
235  ret i32 %res
236}
237declare i32 @llvm.x86.sse42.pcmpestrio128(<16 x i8>, i32, <16 x i8>, i32, i8) nounwind readnone
238
239define i32 @test_mm_cmpestrs(<2 x i64> %a0, i32 %a1, <2 x i64> %a2, i32 %a3) nounwind {
240; X86-SSE-LABEL: test_mm_cmpestrs:
241; X86-SSE:       # %bb.0:
242; X86-SSE-NEXT:    pushl %ebx
243; X86-SSE-NEXT:    movl {{[0-9]+}}(%esp), %edx
244; X86-SSE-NEXT:    movl {{[0-9]+}}(%esp), %eax
245; X86-SSE-NEXT:    xorl %ebx, %ebx
246; X86-SSE-NEXT:    pcmpestri $7, %xmm1, %xmm0
247; X86-SSE-NEXT:    sets %bl
248; X86-SSE-NEXT:    movl %ebx, %eax
249; X86-SSE-NEXT:    popl %ebx
250; X86-SSE-NEXT:    retl
251;
252; X86-AVX-LABEL: test_mm_cmpestrs:
253; X86-AVX:       # %bb.0:
254; X86-AVX-NEXT:    pushl %ebx
255; X86-AVX-NEXT:    movl {{[0-9]+}}(%esp), %edx
256; X86-AVX-NEXT:    movl {{[0-9]+}}(%esp), %eax
257; X86-AVX-NEXT:    xorl %ebx, %ebx
258; X86-AVX-NEXT:    vpcmpestri $7, %xmm1, %xmm0
259; X86-AVX-NEXT:    sets %bl
260; X86-AVX-NEXT:    movl %ebx, %eax
261; X86-AVX-NEXT:    popl %ebx
262; X86-AVX-NEXT:    retl
263;
264; X64-SSE-LABEL: test_mm_cmpestrs:
265; X64-SSE:       # %bb.0:
266; X64-SSE-NEXT:    movl %esi, %edx
267; X64-SSE-NEXT:    movl %edi, %eax
268; X64-SSE-NEXT:    xorl %esi, %esi
269; X64-SSE-NEXT:    pcmpestri $7, %xmm1, %xmm0
270; X64-SSE-NEXT:    sets %sil
271; X64-SSE-NEXT:    movl %esi, %eax
272; X64-SSE-NEXT:    retq
273;
274; X64-AVX-LABEL: test_mm_cmpestrs:
275; X64-AVX:       # %bb.0:
276; X64-AVX-NEXT:    movl %esi, %edx
277; X64-AVX-NEXT:    movl %edi, %eax
278; X64-AVX-NEXT:    xorl %esi, %esi
279; X64-AVX-NEXT:    vpcmpestri $7, %xmm1, %xmm0
280; X64-AVX-NEXT:    sets %sil
281; X64-AVX-NEXT:    movl %esi, %eax
282; X64-AVX-NEXT:    retq
283  %arg0 = bitcast <2 x i64> %a0 to <16 x i8>
284  %arg2 = bitcast <2 x i64> %a2 to <16 x i8>
285  %res = call i32 @llvm.x86.sse42.pcmpestris128(<16 x i8> %arg0, i32 %a1, <16 x i8> %arg2, i32 %a3, i8 7)
286  ret i32 %res
287}
288declare i32 @llvm.x86.sse42.pcmpestris128(<16 x i8>, i32, <16 x i8>, i32, i8) nounwind readnone
289
290define i32 @test_mm_cmpestrz(<2 x i64> %a0, i32 %a1, <2 x i64> %a2, i32 %a3) nounwind {
291; X86-SSE-LABEL: test_mm_cmpestrz:
292; X86-SSE:       # %bb.0:
293; X86-SSE-NEXT:    pushl %ebx
294; X86-SSE-NEXT:    movl {{[0-9]+}}(%esp), %edx
295; X86-SSE-NEXT:    movl {{[0-9]+}}(%esp), %eax
296; X86-SSE-NEXT:    xorl %ebx, %ebx
297; X86-SSE-NEXT:    pcmpestri $7, %xmm1, %xmm0
298; X86-SSE-NEXT:    sete %bl
299; X86-SSE-NEXT:    movl %ebx, %eax
300; X86-SSE-NEXT:    popl %ebx
301; X86-SSE-NEXT:    retl
302;
303; X86-AVX-LABEL: test_mm_cmpestrz:
304; X86-AVX:       # %bb.0:
305; X86-AVX-NEXT:    pushl %ebx
306; X86-AVX-NEXT:    movl {{[0-9]+}}(%esp), %edx
307; X86-AVX-NEXT:    movl {{[0-9]+}}(%esp), %eax
308; X86-AVX-NEXT:    xorl %ebx, %ebx
309; X86-AVX-NEXT:    vpcmpestri $7, %xmm1, %xmm0
310; X86-AVX-NEXT:    sete %bl
311; X86-AVX-NEXT:    movl %ebx, %eax
312; X86-AVX-NEXT:    popl %ebx
313; X86-AVX-NEXT:    retl
314;
315; X64-SSE-LABEL: test_mm_cmpestrz:
316; X64-SSE:       # %bb.0:
317; X64-SSE-NEXT:    movl %esi, %edx
318; X64-SSE-NEXT:    movl %edi, %eax
319; X64-SSE-NEXT:    xorl %esi, %esi
320; X64-SSE-NEXT:    pcmpestri $7, %xmm1, %xmm0
321; X64-SSE-NEXT:    sete %sil
322; X64-SSE-NEXT:    movl %esi, %eax
323; X64-SSE-NEXT:    retq
324;
325; X64-AVX-LABEL: test_mm_cmpestrz:
326; X64-AVX:       # %bb.0:
327; X64-AVX-NEXT:    movl %esi, %edx
328; X64-AVX-NEXT:    movl %edi, %eax
329; X64-AVX-NEXT:    xorl %esi, %esi
330; X64-AVX-NEXT:    vpcmpestri $7, %xmm1, %xmm0
331; X64-AVX-NEXT:    sete %sil
332; X64-AVX-NEXT:    movl %esi, %eax
333; X64-AVX-NEXT:    retq
334  %arg0 = bitcast <2 x i64> %a0 to <16 x i8>
335  %arg2 = bitcast <2 x i64> %a2 to <16 x i8>
336  %res = call i32 @llvm.x86.sse42.pcmpestriz128(<16 x i8> %arg0, i32 %a1, <16 x i8> %arg2, i32 %a3, i8 7)
337  ret i32 %res
338}
339declare i32 @llvm.x86.sse42.pcmpestriz128(<16 x i8>, i32, <16 x i8>, i32, i8) nounwind readnone
340
341define <2 x i64> @test_mm_cmpgt_epi64(<2 x i64> %a0, <2 x i64> %a1) {
342; SSE-LABEL: test_mm_cmpgt_epi64:
343; SSE:       # %bb.0:
344; SSE-NEXT:    pcmpgtq %xmm1, %xmm0
345; SSE-NEXT:    ret{{[l|q]}}
346;
347; AVX1-LABEL: test_mm_cmpgt_epi64:
348; AVX1:       # %bb.0:
349; AVX1-NEXT:    vpcmpgtq %xmm1, %xmm0, %xmm0
350; AVX1-NEXT:    ret{{[l|q]}}
351;
352; AVX512-LABEL: test_mm_cmpgt_epi64:
353; AVX512:       # %bb.0:
354; AVX512-NEXT:    vpcmpgtq %xmm1, %xmm0, %k0
355; AVX512-NEXT:    vpmovm2q %k0, %xmm0
356; AVX512-NEXT:    ret{{[l|q]}}
357  %cmp = icmp sgt <2 x i64> %a0, %a1
358  %res = sext <2 x i1> %cmp to <2 x i64>
359  ret <2 x i64> %res
360}
361
362define i32 @test_mm_cmpistra(<2 x i64> %a0, <2 x i64> %a1) {
363; SSE-LABEL: test_mm_cmpistra:
364; SSE:       # %bb.0:
365; SSE-NEXT:    xorl %eax, %eax
366; SSE-NEXT:    pcmpistri $7, %xmm1, %xmm0
367; SSE-NEXT:    seta %al
368; SSE-NEXT:    ret{{[l|q]}}
369;
370; AVX-LABEL: test_mm_cmpistra:
371; AVX:       # %bb.0:
372; AVX-NEXT:    xorl %eax, %eax
373; AVX-NEXT:    vpcmpistri $7, %xmm1, %xmm0
374; AVX-NEXT:    seta %al
375; AVX-NEXT:    ret{{[l|q]}}
376  %arg0 = bitcast <2 x i64> %a0 to <16 x i8>
377  %arg1 = bitcast <2 x i64> %a1 to <16 x i8>
378  %res = call i32 @llvm.x86.sse42.pcmpistria128(<16 x i8> %arg0, <16 x i8> %arg1, i8 7)
379  ret i32 %res
380}
381declare i32 @llvm.x86.sse42.pcmpistria128(<16 x i8>, <16 x i8>, i8) nounwind readnone
382
383define i32 @test_mm_cmpistrc(<2 x i64> %a0, <2 x i64> %a1) {
384; SSE-LABEL: test_mm_cmpistrc:
385; SSE:       # %bb.0:
386; SSE-NEXT:    xorl %eax, %eax
387; SSE-NEXT:    pcmpistri $7, %xmm1, %xmm0
388; SSE-NEXT:    setb %al
389; SSE-NEXT:    ret{{[l|q]}}
390;
391; AVX-LABEL: test_mm_cmpistrc:
392; AVX:       # %bb.0:
393; AVX-NEXT:    xorl %eax, %eax
394; AVX-NEXT:    vpcmpistri $7, %xmm1, %xmm0
395; AVX-NEXT:    setb %al
396; AVX-NEXT:    ret{{[l|q]}}
397  %arg0 = bitcast <2 x i64> %a0 to <16 x i8>
398  %arg1 = bitcast <2 x i64> %a1 to <16 x i8>
399  %res = call i32 @llvm.x86.sse42.pcmpistric128(<16 x i8> %arg0, <16 x i8> %arg1, i8 7)
400  ret i32 %res
401}
402declare i32 @llvm.x86.sse42.pcmpistric128(<16 x i8>, <16 x i8>, i8) nounwind readnone
403
404define i32 @test_mm_cmpistri(<2 x i64> %a0, <2 x i64> %a1) {
405; SSE-LABEL: test_mm_cmpistri:
406; SSE:       # %bb.0:
407; SSE-NEXT:    pcmpistri $7, %xmm1, %xmm0
408; SSE-NEXT:    movl %ecx, %eax
409; SSE-NEXT:    ret{{[l|q]}}
410;
411; AVX-LABEL: test_mm_cmpistri:
412; AVX:       # %bb.0:
413; AVX-NEXT:    vpcmpistri $7, %xmm1, %xmm0
414; AVX-NEXT:    movl %ecx, %eax
415; AVX-NEXT:    ret{{[l|q]}}
416  %arg0 = bitcast <2 x i64> %a0 to <16 x i8>
417  %arg1 = bitcast <2 x i64> %a1 to <16 x i8>
418  %res = call i32 @llvm.x86.sse42.pcmpistri128(<16 x i8> %arg0, <16 x i8> %arg1, i8 7)
419  ret i32 %res
420}
421declare i32 @llvm.x86.sse42.pcmpistri128(<16 x i8>, <16 x i8>, i8) nounwind readnone
422
423define <2 x i64> @test_mm_cmpistrm(<2 x i64> %a0, <2 x i64> %a1) {
424; SSE-LABEL: test_mm_cmpistrm:
425; SSE:       # %bb.0:
426; SSE-NEXT:    pcmpistrm $7, %xmm1, %xmm0
427; SSE-NEXT:    ret{{[l|q]}}
428;
429; AVX-LABEL: test_mm_cmpistrm:
430; AVX:       # %bb.0:
431; AVX-NEXT:    vpcmpistrm $7, %xmm1, %xmm0
432; AVX-NEXT:    ret{{[l|q]}}
433  %arg0 = bitcast <2 x i64> %a0 to <16 x i8>
434  %arg1 = bitcast <2 x i64> %a1 to <16 x i8>
435  %res = call <16 x i8> @llvm.x86.sse42.pcmpistrm128(<16 x i8> %arg0, <16 x i8> %arg1, i8 7)
436  %bc = bitcast <16 x i8> %res to <2 x i64>
437  ret <2 x i64> %bc
438}
439declare <16 x i8> @llvm.x86.sse42.pcmpistrm128(<16 x i8>, <16 x i8>, i8) nounwind readnone
440
441define i32 @test_mm_cmpistro(<2 x i64> %a0, <2 x i64> %a1) {
442; SSE-LABEL: test_mm_cmpistro:
443; SSE:       # %bb.0:
444; SSE-NEXT:    xorl %eax, %eax
445; SSE-NEXT:    pcmpistri $7, %xmm1, %xmm0
446; SSE-NEXT:    seto %al
447; SSE-NEXT:    ret{{[l|q]}}
448;
449; AVX-LABEL: test_mm_cmpistro:
450; AVX:       # %bb.0:
451; AVX-NEXT:    xorl %eax, %eax
452; AVX-NEXT:    vpcmpistri $7, %xmm1, %xmm0
453; AVX-NEXT:    seto %al
454; AVX-NEXT:    ret{{[l|q]}}
455  %arg0 = bitcast <2 x i64> %a0 to <16 x i8>
456  %arg1 = bitcast <2 x i64> %a1 to <16 x i8>
457  %res = call i32 @llvm.x86.sse42.pcmpistrio128(<16 x i8> %arg0, <16 x i8> %arg1, i8 7)
458  ret i32 %res
459}
460declare i32 @llvm.x86.sse42.pcmpistrio128(<16 x i8>, <16 x i8>, i8) nounwind readnone
461
462define i32 @test_mm_cmpistrs(<2 x i64> %a0, <2 x i64> %a1) {
463; SSE-LABEL: test_mm_cmpistrs:
464; SSE:       # %bb.0:
465; SSE-NEXT:    xorl %eax, %eax
466; SSE-NEXT:    pcmpistri $7, %xmm1, %xmm0
467; SSE-NEXT:    sets %al
468; SSE-NEXT:    ret{{[l|q]}}
469;
470; AVX-LABEL: test_mm_cmpistrs:
471; AVX:       # %bb.0:
472; AVX-NEXT:    xorl %eax, %eax
473; AVX-NEXT:    vpcmpistri $7, %xmm1, %xmm0
474; AVX-NEXT:    sets %al
475; AVX-NEXT:    ret{{[l|q]}}
476  %arg0 = bitcast <2 x i64> %a0 to <16 x i8>
477  %arg1 = bitcast <2 x i64> %a1 to <16 x i8>
478  %res = call i32 @llvm.x86.sse42.pcmpistris128(<16 x i8> %arg0, <16 x i8> %arg1, i8 7)
479  ret i32 %res
480}
481declare i32 @llvm.x86.sse42.pcmpistris128(<16 x i8>, <16 x i8>, i8) nounwind readnone
482
483define i32 @test_mm_cmpistrz(<2 x i64> %a0, <2 x i64> %a1) {
484; SSE-LABEL: test_mm_cmpistrz:
485; SSE:       # %bb.0:
486; SSE-NEXT:    xorl %eax, %eax
487; SSE-NEXT:    pcmpistri $7, %xmm1, %xmm0
488; SSE-NEXT:    sete %al
489; SSE-NEXT:    ret{{[l|q]}}
490;
491; AVX-LABEL: test_mm_cmpistrz:
492; AVX:       # %bb.0:
493; AVX-NEXT:    xorl %eax, %eax
494; AVX-NEXT:    vpcmpistri $7, %xmm1, %xmm0
495; AVX-NEXT:    sete %al
496; AVX-NEXT:    ret{{[l|q]}}
497  %arg0 = bitcast <2 x i64> %a0 to <16 x i8>
498  %arg1 = bitcast <2 x i64> %a1 to <16 x i8>
499  %res = call i32 @llvm.x86.sse42.pcmpistriz128(<16 x i8> %arg0, <16 x i8> %arg1, i8 7)
500  ret i32 %res
501}
502declare i32 @llvm.x86.sse42.pcmpistriz128(<16 x i8>, <16 x i8>, i8) nounwind readnone
503
504define i32 @test_mm_crc32_u8(i32 %a0, i8 %a1) {
505; X86-LABEL: test_mm_crc32_u8:
506; X86:       # %bb.0:
507; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
508; X86-NEXT:    crc32b {{[0-9]+}}(%esp), %eax
509; X86-NEXT:    retl
510;
511; X64-LABEL: test_mm_crc32_u8:
512; X64:       # %bb.0:
513; X64-NEXT:    movl %edi, %eax
514; X64-NEXT:    crc32b %sil, %eax
515; X64-NEXT:    retq
516  %res = call i32 @llvm.x86.sse42.crc32.32.8(i32 %a0, i8 %a1)
517  ret i32 %res
518}
519declare i32 @llvm.x86.sse42.crc32.32.8(i32, i8) nounwind readnone
520
521define i32 @test_mm_crc32_u16(i32 %a0, i16 %a1) {
522; X86-LABEL: test_mm_crc32_u16:
523; X86:       # %bb.0:
524; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
525; X86-NEXT:    crc32w {{[0-9]+}}(%esp), %eax
526; X86-NEXT:    retl
527;
528; X64-LABEL: test_mm_crc32_u16:
529; X64:       # %bb.0:
530; X64-NEXT:    movl %edi, %eax
531; X64-NEXT:    crc32w %si, %eax
532; X64-NEXT:    retq
533  %res = call i32 @llvm.x86.sse42.crc32.32.16(i32 %a0, i16 %a1)
534  ret i32 %res
535}
536declare i32 @llvm.x86.sse42.crc32.32.16(i32, i16) nounwind readnone
537
538define i32 @test_mm_crc32_u32(i32 %a0, i32 %a1) {
539; X86-LABEL: test_mm_crc32_u32:
540; X86:       # %bb.0:
541; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
542; X86-NEXT:    crc32l {{[0-9]+}}(%esp), %eax
543; X86-NEXT:    retl
544;
545; X64-LABEL: test_mm_crc32_u32:
546; X64:       # %bb.0:
547; X64-NEXT:    movl %edi, %eax
548; X64-NEXT:    crc32l %esi, %eax
549; X64-NEXT:    retq
550  %res = call i32 @llvm.x86.sse42.crc32.32.32(i32 %a0, i32 %a1)
551  ret i32 %res
552}
553declare i32 @llvm.x86.sse42.crc32.32.32(i32, i32) nounwind readnone
554