77; RUN: llc < %s -mtriple=x86_64-unknown -mattr=avx | FileCheck %s --check-prefixes=X64,X64-AVX
88; RUN: llc < %s -mtriple=x86_64-unknown -mattr=avx512f | FileCheck %s --check-prefixes=X64,X64-AVX
99
10- define i64 @testmsxh (half %x ) nounwind {
11- ; X86-NOSSE-LABEL: testmsxh:
12- ; X86-NOSSE: # %bb.0: # %entry
13- ; X86-NOSSE-NEXT: pushl %eax
14- ; X86-NOSSE-NEXT: movzwl {{[0-9]+}}(%esp), %eax
15- ; X86-NOSSE-NEXT: movl %eax, (%esp)
16- ; X86-NOSSE-NEXT: calll __extendhfsf2
17- ; X86-NOSSE-NEXT: fstps (%esp)
18- ; X86-NOSSE-NEXT: calll llrintf
19- ; X86-NOSSE-NEXT: popl %ecx
20- ; X86-NOSSE-NEXT: retl
21- ;
22- ; X86-SSE2-LABEL: testmsxh:
23- ; X86-SSE2: # %bb.0: # %entry
24- ; X86-SSE2-NEXT: pushl %eax
25- ; X86-SSE2-NEXT: pinsrw $0, {{[0-9]+}}(%esp), %xmm0
26- ; X86-SSE2-NEXT: pextrw $0, %xmm0, %eax
27- ; X86-SSE2-NEXT: movw %ax, (%esp)
28- ; X86-SSE2-NEXT: calll __extendhfsf2
29- ; X86-SSE2-NEXT: fstps (%esp)
30- ; X86-SSE2-NEXT: calll llrintf
31- ; X86-SSE2-NEXT: popl %ecx
32- ; X86-SSE2-NEXT: retl
33- ;
34- ; X64-SSE-LABEL: testmsxh:
35- ; X64-SSE: # %bb.0: # %entry
36- ; X64-SSE-NEXT: pushq %rax
37- ; X64-SSE-NEXT: callq __extendhfsf2@PLT
38- ; X64-SSE-NEXT: callq rintf@PLT
39- ; X64-SSE-NEXT: callq __truncsfhf2@PLT
40- ; X64-SSE-NEXT: callq __extendhfsf2@PLT
41- ; X64-SSE-NEXT: cvttss2si %xmm0, %rax
42- ; X64-SSE-NEXT: popq %rcx
43- ; X64-SSE-NEXT: retq
44- entry:
45- %0 = tail call i64 @llvm.llrint.i64.f16 (half %x )
46- ret i64 %0
47- }
10+ ; FIXME: crash
11+ ; define i64 @test_llrint_i64_f16(half %x) nounwind {
12+ ; entry:
13+ ; %0 = tail call i64 @llvm.llrint.i64.f16(half %x)
14+ ; ret i64 %0
15+ ; }
4816
49- define i64 @testmsxs (float %x ) nounwind {
50- ; X86-NOSSE-LABEL: testmsxs :
17+ define i64 @test_llrint_i64_f32 (float %x ) nounwind {
18+ ; X86-NOSSE-LABEL: test_llrint_i64_f32 :
5119; X86-NOSSE: # %bb.0: # %entry
5220; X86-NOSSE-NEXT: pushl %ebp
5321; X86-NOSSE-NEXT: movl %esp, %ebp
@@ -61,7 +29,7 @@ define i64 @testmsxs(float %x) nounwind {
6129; X86-NOSSE-NEXT: popl %ebp
6230; X86-NOSSE-NEXT: retl
6331;
64- ; X86-SSE2-LABEL: testmsxs :
32+ ; X86-SSE2-LABEL: test_llrint_i64_f32 :
6533; X86-SSE2: # %bb.0: # %entry
6634; X86-SSE2-NEXT: pushl %ebp
6735; X86-SSE2-NEXT: movl %esp, %ebp
@@ -77,7 +45,7 @@ define i64 @testmsxs(float %x) nounwind {
7745; X86-SSE2-NEXT: popl %ebp
7846; X86-SSE2-NEXT: retl
7947;
80- ; X86-AVX-LABEL: testmsxs :
48+ ; X86-AVX-LABEL: test_llrint_i64_f32 :
8149; X86-AVX: # %bb.0: # %entry
8250; X86-AVX-NEXT: pushl %ebp
8351; X86-AVX-NEXT: movl %esp, %ebp
@@ -93,12 +61,12 @@ define i64 @testmsxs(float %x) nounwind {
9361; X86-AVX-NEXT: popl %ebp
9462; X86-AVX-NEXT: retl
9563;
96- ; X64-SSE-LABEL: testmsxs :
64+ ; X64-SSE-LABEL: test_llrint_i64_f32 :
9765; X64-SSE: # %bb.0: # %entry
9866; X64-SSE-NEXT: cvtss2si %xmm0, %rax
9967; X64-SSE-NEXT: retq
10068;
101- ; X64-AVX-LABEL: testmsxs :
69+ ; X64-AVX-LABEL: test_llrint_i64_f32 :
10270; X64-AVX: # %bb.0: # %entry
10371; X64-AVX-NEXT: vcvtss2si %xmm0, %rax
10472; X64-AVX-NEXT: retq
@@ -107,8 +75,8 @@ entry:
10775 ret i64 %0
10876}
10977
110- define i64 @testmsxd (double %x ) nounwind {
111- ; X86-NOSSE-LABEL: testmsxd :
78+ define i64 @test_llrint_i64_f64 (double %x ) nounwind {
79+ ; X86-NOSSE-LABEL: test_llrint_i64_f64 :
11280; X86-NOSSE: # %bb.0: # %entry
11381; X86-NOSSE-NEXT: pushl %ebp
11482; X86-NOSSE-NEXT: movl %esp, %ebp
@@ -122,7 +90,7 @@ define i64 @testmsxd(double %x) nounwind {
12290; X86-NOSSE-NEXT: popl %ebp
12391; X86-NOSSE-NEXT: retl
12492;
125- ; X86-SSE2-LABEL: testmsxd :
93+ ; X86-SSE2-LABEL: test_llrint_i64_f64 :
12694; X86-SSE2: # %bb.0: # %entry
12795; X86-SSE2-NEXT: pushl %ebp
12896; X86-SSE2-NEXT: movl %esp, %ebp
@@ -138,7 +106,7 @@ define i64 @testmsxd(double %x) nounwind {
138106; X86-SSE2-NEXT: popl %ebp
139107; X86-SSE2-NEXT: retl
140108;
141- ; X86-AVX-LABEL: testmsxd :
109+ ; X86-AVX-LABEL: test_llrint_i64_f64 :
142110; X86-AVX: # %bb.0: # %entry
143111; X86-AVX-NEXT: pushl %ebp
144112; X86-AVX-NEXT: movl %esp, %ebp
@@ -154,12 +122,12 @@ define i64 @testmsxd(double %x) nounwind {
154122; X86-AVX-NEXT: popl %ebp
155123; X86-AVX-NEXT: retl
156124;
157- ; X64-SSE-LABEL: testmsxd :
125+ ; X64-SSE-LABEL: test_llrint_i64_f64 :
158126; X64-SSE: # %bb.0: # %entry
159127; X64-SSE-NEXT: cvtsd2si %xmm0, %rax
160128; X64-SSE-NEXT: retq
161129;
162- ; X64-AVX-LABEL: testmsxd :
130+ ; X64-AVX-LABEL: test_llrint_i64_f64 :
163131; X64-AVX: # %bb.0: # %entry
164132; X64-AVX-NEXT: vcvtsd2si %xmm0, %rax
165133; X64-AVX-NEXT: retq
@@ -168,8 +136,8 @@ entry:
168136 ret i64 %0
169137}
170138
171- define i64 @testmsll (x86_fp80 %x ) nounwind {
172- ; X86-LABEL: testmsll :
139+ define i64 @test_llrint_i64_f80 (x86_fp80 %x ) nounwind {
140+ ; X86-LABEL: test_llrint_i64_f80 :
173141; X86: # %bb.0: # %entry
174142; X86-NEXT: pushl %ebp
175143; X86-NEXT: movl %esp, %ebp
@@ -183,7 +151,7 @@ define i64 @testmsll(x86_fp80 %x) nounwind {
183151; X86-NEXT: popl %ebp
184152; X86-NEXT: retl
185153;
186- ; X64-LABEL: testmsll :
154+ ; X64-LABEL: test_llrint_i64_f80 :
187155; X64: # %bb.0: # %entry
188156; X64-NEXT: fldt {{[0-9]+}}(%rsp)
189157; X64-NEXT: fistpll -{{[0-9]+}}(%rsp)
@@ -195,8 +163,8 @@ entry:
195163}
196164
197165; FIXME(#44744): incorrect libcall
198- define i64 @testmslq (fp128 %x ) nounwind {
199- ; X86-NOSSE-LABEL: testmslq :
166+ define i64 @test_llrint_i64_f128 (fp128 %x ) nounwind {
167+ ; X86-NOSSE-LABEL: test_llrint_i64_f128 :
200168; X86-NOSSE: # %bb.0: # %entry
201169; X86-NOSSE-NEXT: pushl %ebp
202170; X86-NOSSE-NEXT: movl %esp, %ebp
@@ -212,7 +180,7 @@ define i64 @testmslq(fp128 %x) nounwind {
212180; X86-NOSSE-NEXT: popl %ebp
213181; X86-NOSSE-NEXT: retl
214182;
215- ; X86-SSE2-LABEL: testmslq :
183+ ; X86-SSE2-LABEL: test_llrint_i64_f128 :
216184; X86-SSE2: # %bb.0: # %entry
217185; X86-SSE2-NEXT: pushl %ebp
218186; X86-SSE2-NEXT: movl %esp, %ebp
@@ -228,7 +196,7 @@ define i64 @testmslq(fp128 %x) nounwind {
228196; X86-SSE2-NEXT: popl %ebp
229197; X86-SSE2-NEXT: retl
230198;
231- ; X86-AVX-LABEL: testmslq :
199+ ; X86-AVX-LABEL: test_llrint_i64_f128 :
232200; X86-AVX: # %bb.0: # %entry
233201; X86-AVX-NEXT: pushl %ebp
234202; X86-AVX-NEXT: movl %esp, %ebp
@@ -241,11 +209,181 @@ define i64 @testmslq(fp128 %x) nounwind {
241209; X86-AVX-NEXT: popl %ebp
242210; X86-AVX-NEXT: retl
243211;
244- ; X64-LABEL: testmslq :
212+ ; X64-LABEL: test_llrint_i64_f128 :
245213; X64: # %bb.0: # %entry
246214; X64-NEXT: jmp llrintl@PLT # TAILCALL
247215entry:
248- %0 = tail call i64 @llvm.llrint.i64.fp128 (fp128 %x )
216+ %0 = tail call i64 @llvm.llrint.i64.f128 (fp128 %x )
217+ ret i64 %0
218+ }
219+
220+ ; FIXME: crash
221+ ; define i64 @test_llrint_i64_f16_strict(half %x) nounwind strictfp {
222+ ; entry:
223+ ; %0 = tail call i64 @llvm.experimental.constrained.llrint.i64.f16(half %x, metadata!"round.dynamic", metadata!"fpexcept.strict")
224+ ; ret i64 %0
225+ ; }
226+
227+ define i64 @test_llrint_i64_f32_strict (float %x ) nounwind strictfp {
228+ ; X86-NOSSE-LABEL: test_llrint_i64_f32_strict:
229+ ; X86-NOSSE: # %bb.0: # %entry
230+ ; X86-NOSSE-NEXT: pushl %eax
231+ ; X86-NOSSE-NEXT: flds {{[0-9]+}}(%esp)
232+ ; X86-NOSSE-NEXT: fstps (%esp)
233+ ; X86-NOSSE-NEXT: wait
234+ ; X86-NOSSE-NEXT: calll llrintf
235+ ; X86-NOSSE-NEXT: popl %ecx
236+ ; X86-NOSSE-NEXT: retl
237+ ;
238+ ; X86-SSE2-LABEL: test_llrint_i64_f32_strict:
239+ ; X86-SSE2: # %bb.0: # %entry
240+ ; X86-SSE2-NEXT: pushl %eax
241+ ; X86-SSE2-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
242+ ; X86-SSE2-NEXT: movss %xmm0, (%esp)
243+ ; X86-SSE2-NEXT: calll llrintf
244+ ; X86-SSE2-NEXT: popl %ecx
245+ ; X86-SSE2-NEXT: retl
246+ ;
247+ ; X86-AVX-LABEL: test_llrint_i64_f32_strict:
248+ ; X86-AVX: # %bb.0: # %entry
249+ ; X86-AVX-NEXT: pushl %eax
250+ ; X86-AVX-NEXT: vmovss {{.*#+}} xmm0 = mem[0],zero,zero,zero
251+ ; X86-AVX-NEXT: vmovss %xmm0, (%esp)
252+ ; X86-AVX-NEXT: calll llrintf
253+ ; X86-AVX-NEXT: popl %ecx
254+ ; X86-AVX-NEXT: retl
255+ ;
256+ ; X64-LABEL: test_llrint_i64_f32_strict:
257+ ; X64: # %bb.0: # %entry
258+ ; X64-NEXT: pushq %rax
259+ ; X64-NEXT: callq llrintf@PLT
260+ ; X64-NEXT: popq %rcx
261+ ; X64-NEXT: retq
262+ entry:
263+ %0 = tail call i64 @llvm.experimental.constrained.llrint.i64.f32 (float %x , metadata !"round.dynamic" , metadata !"fpexcept.strict" )
264+ ret i64 %0
265+ }
266+
267+ define i64 @test_llrint_i64_f64_strict (double %x ) nounwind strictfp {
268+ ; X86-NOSSE-LABEL: test_llrint_i64_f64_strict:
269+ ; X86-NOSSE: # %bb.0: # %entry
270+ ; X86-NOSSE-NEXT: subl $8, %esp
271+ ; X86-NOSSE-NEXT: fldl {{[0-9]+}}(%esp)
272+ ; X86-NOSSE-NEXT: fstpl (%esp)
273+ ; X86-NOSSE-NEXT: wait
274+ ; X86-NOSSE-NEXT: calll llrint
275+ ; X86-NOSSE-NEXT: addl $8, %esp
276+ ; X86-NOSSE-NEXT: retl
277+ ;
278+ ; X86-SSE2-LABEL: test_llrint_i64_f64_strict:
279+ ; X86-SSE2: # %bb.0: # %entry
280+ ; X86-SSE2-NEXT: subl $8, %esp
281+ ; X86-SSE2-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero
282+ ; X86-SSE2-NEXT: movsd %xmm0, (%esp)
283+ ; X86-SSE2-NEXT: calll llrint
284+ ; X86-SSE2-NEXT: addl $8, %esp
285+ ; X86-SSE2-NEXT: retl
286+ ;
287+ ; X86-AVX-LABEL: test_llrint_i64_f64_strict:
288+ ; X86-AVX: # %bb.0: # %entry
289+ ; X86-AVX-NEXT: subl $8, %esp
290+ ; X86-AVX-NEXT: vmovsd {{.*#+}} xmm0 = mem[0],zero
291+ ; X86-AVX-NEXT: vmovsd %xmm0, (%esp)
292+ ; X86-AVX-NEXT: calll llrint
293+ ; X86-AVX-NEXT: addl $8, %esp
294+ ; X86-AVX-NEXT: retl
295+ ;
296+ ; X64-LABEL: test_llrint_i64_f64_strict:
297+ ; X64: # %bb.0: # %entry
298+ ; X64-NEXT: pushq %rax
299+ ; X64-NEXT: callq llrint@PLT
300+ ; X64-NEXT: popq %rcx
301+ ; X64-NEXT: retq
302+ entry:
303+ %0 = tail call i64 @llvm.experimental.constrained.llrint.i64.f64 (double %x , metadata !"round.dynamic" , metadata !"fpexcept.strict" )
304+ ret i64 %0
305+ }
306+
307+ define i64 @test_llrint_i64_f80_strict (x86_fp80 %x ) nounwind strictfp {
308+ ; X86-LABEL: test_llrint_i64_f80_strict:
309+ ; X86: # %bb.0: # %entry
310+ ; X86-NEXT: subl $12, %esp
311+ ; X86-NEXT: fldt {{[0-9]+}}(%esp)
312+ ; X86-NEXT: fstpt (%esp)
313+ ; X86-NEXT: wait
314+ ; X86-NEXT: calll llrintl
315+ ; X86-NEXT: addl $12, %esp
316+ ; X86-NEXT: retl
317+ ;
318+ ; X64-LABEL: test_llrint_i64_f80_strict:
319+ ; X64: # %bb.0: # %entry
320+ ; X64-NEXT: subq $24, %rsp
321+ ; X64-NEXT: fldt {{[0-9]+}}(%rsp)
322+ ; X64-NEXT: fstpt (%rsp)
323+ ; X64-NEXT: wait
324+ ; X64-NEXT: callq llrintl@PLT
325+ ; X64-NEXT: addq $24, %rsp
326+ ; X64-NEXT: retq
327+ entry:
328+ %0 = tail call i64 @llvm.experimental.constrained.llrint.i64.f80 (x86_fp80 %x , metadata !"round.dynamic" , metadata !"fpexcept.strict" )
329+ ret i64 %0
330+ }
331+
332+ ; FIXME(#44744): incorrect libcall
333+ define i64 @test_llrint_i64_f128_strict (fp128 %x ) nounwind strictfp {
334+ ; X86-NOSSE-LABEL: test_llrint_i64_f128_strict:
335+ ; X86-NOSSE: # %bb.0: # %entry
336+ ; X86-NOSSE-NEXT: pushl %ebp
337+ ; X86-NOSSE-NEXT: movl %esp, %ebp
338+ ; X86-NOSSE-NEXT: andl $-16, %esp
339+ ; X86-NOSSE-NEXT: subl $16, %esp
340+ ; X86-NOSSE-NEXT: pushl 20(%ebp)
341+ ; X86-NOSSE-NEXT: pushl 16(%ebp)
342+ ; X86-NOSSE-NEXT: pushl 12(%ebp)
343+ ; X86-NOSSE-NEXT: pushl 8(%ebp)
344+ ; X86-NOSSE-NEXT: calll llrintl
345+ ; X86-NOSSE-NEXT: addl $16, %esp
346+ ; X86-NOSSE-NEXT: movl %ebp, %esp
347+ ; X86-NOSSE-NEXT: popl %ebp
348+ ; X86-NOSSE-NEXT: retl
349+ ;
350+ ; X86-SSE2-LABEL: test_llrint_i64_f128_strict:
351+ ; X86-SSE2: # %bb.0: # %entry
352+ ; X86-SSE2-NEXT: pushl %ebp
353+ ; X86-SSE2-NEXT: movl %esp, %ebp
354+ ; X86-SSE2-NEXT: andl $-16, %esp
355+ ; X86-SSE2-NEXT: subl $16, %esp
356+ ; X86-SSE2-NEXT: pushl 20(%ebp)
357+ ; X86-SSE2-NEXT: pushl 16(%ebp)
358+ ; X86-SSE2-NEXT: pushl 12(%ebp)
359+ ; X86-SSE2-NEXT: pushl 8(%ebp)
360+ ; X86-SSE2-NEXT: calll llrintl
361+ ; X86-SSE2-NEXT: addl $16, %esp
362+ ; X86-SSE2-NEXT: movl %ebp, %esp
363+ ; X86-SSE2-NEXT: popl %ebp
364+ ; X86-SSE2-NEXT: retl
365+ ;
366+ ; X86-AVX-LABEL: test_llrint_i64_f128_strict:
367+ ; X86-AVX: # %bb.0: # %entry
368+ ; X86-AVX-NEXT: pushl %ebp
369+ ; X86-AVX-NEXT: movl %esp, %ebp
370+ ; X86-AVX-NEXT: andl $-16, %esp
371+ ; X86-AVX-NEXT: subl $32, %esp
372+ ; X86-AVX-NEXT: vmovups 8(%ebp), %xmm0
373+ ; X86-AVX-NEXT: vmovups %xmm0, (%esp)
374+ ; X86-AVX-NEXT: calll llrintl
375+ ; X86-AVX-NEXT: movl %ebp, %esp
376+ ; X86-AVX-NEXT: popl %ebp
377+ ; X86-AVX-NEXT: retl
378+ ;
379+ ; X64-LABEL: test_llrint_i64_f128_strict:
380+ ; X64: # %bb.0: # %entry
381+ ; X64-NEXT: pushq %rax
382+ ; X64-NEXT: callq llrintl@PLT
383+ ; X64-NEXT: popq %rcx
384+ ; X64-NEXT: retq
385+ entry:
386+ %0 = tail call i64 @llvm.experimental.constrained.llrint.i64.f128 (fp128 %x , metadata !"round.dynamic" , metadata !"fpexcept.strict" )
249387 ret i64 %0
250388}
251389
0 commit comments