Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
256 changes: 197 additions & 59 deletions llvm/test/CodeGen/X86/llrint-conv.ll
Original file line number Diff line number Diff line change
Expand Up @@ -7,47 +7,15 @@
; RUN: llc < %s -mtriple=x86_64-unknown -mattr=avx | FileCheck %s --check-prefixes=X64,X64-AVX
; RUN: llc < %s -mtriple=x86_64-unknown -mattr=avx512f | FileCheck %s --check-prefixes=X64,X64-AVX

define i64 @testmsxh(half %x) nounwind {
; X86-NOSSE-LABEL: testmsxh:
; X86-NOSSE: # %bb.0: # %entry
; X86-NOSSE-NEXT: pushl %eax
; X86-NOSSE-NEXT: movzwl {{[0-9]+}}(%esp), %eax
; X86-NOSSE-NEXT: movl %eax, (%esp)
; X86-NOSSE-NEXT: calll __extendhfsf2
; X86-NOSSE-NEXT: fstps (%esp)
; X86-NOSSE-NEXT: calll llrintf
; X86-NOSSE-NEXT: popl %ecx
; X86-NOSSE-NEXT: retl
;
; X86-SSE2-LABEL: testmsxh:
; X86-SSE2: # %bb.0: # %entry
; X86-SSE2-NEXT: pushl %eax
; X86-SSE2-NEXT: pinsrw $0, {{[0-9]+}}(%esp), %xmm0
; X86-SSE2-NEXT: pextrw $0, %xmm0, %eax
; X86-SSE2-NEXT: movw %ax, (%esp)
; X86-SSE2-NEXT: calll __extendhfsf2
; X86-SSE2-NEXT: fstps (%esp)
; X86-SSE2-NEXT: calll llrintf
; X86-SSE2-NEXT: popl %ecx
; X86-SSE2-NEXT: retl
;
; X64-SSE-LABEL: testmsxh:
; X64-SSE: # %bb.0: # %entry
; X64-SSE-NEXT: pushq %rax
; X64-SSE-NEXT: callq __extendhfsf2@PLT
; X64-SSE-NEXT: callq rintf@PLT
; X64-SSE-NEXT: callq __truncsfhf2@PLT
; X64-SSE-NEXT: callq __extendhfsf2@PLT
; X64-SSE-NEXT: cvttss2si %xmm0, %rax
; X64-SSE-NEXT: popq %rcx
; X64-SSE-NEXT: retq
entry:
%0 = tail call i64 @llvm.llrint.i64.f16(half %x)
ret i64 %0
}
; FIXME: crash
; define i64 @test_llrint_i64_f16(half %x) nounwind {
; entry:
; %0 = tail call i64 @llvm.llrint.i64.f16(half %x)
; ret i64 %0
; }

define i64 @testmsxs(float %x) nounwind {
; X86-NOSSE-LABEL: testmsxs:
define i64 @test_llrint_i64_f32(float %x) nounwind {
; X86-NOSSE-LABEL: test_llrint_i64_f32:
; X86-NOSSE: # %bb.0: # %entry
; X86-NOSSE-NEXT: pushl %ebp
; X86-NOSSE-NEXT: movl %esp, %ebp
Expand All @@ -61,7 +29,7 @@ define i64 @testmsxs(float %x) nounwind {
; X86-NOSSE-NEXT: popl %ebp
; X86-NOSSE-NEXT: retl
;
; X86-SSE2-LABEL: testmsxs:
; X86-SSE2-LABEL: test_llrint_i64_f32:
; X86-SSE2: # %bb.0: # %entry
; X86-SSE2-NEXT: pushl %ebp
; X86-SSE2-NEXT: movl %esp, %ebp
Expand All @@ -77,7 +45,7 @@ define i64 @testmsxs(float %x) nounwind {
; X86-SSE2-NEXT: popl %ebp
; X86-SSE2-NEXT: retl
;
; X86-AVX-LABEL: testmsxs:
; X86-AVX-LABEL: test_llrint_i64_f32:
; X86-AVX: # %bb.0: # %entry
; X86-AVX-NEXT: pushl %ebp
; X86-AVX-NEXT: movl %esp, %ebp
Expand All @@ -93,12 +61,12 @@ define i64 @testmsxs(float %x) nounwind {
; X86-AVX-NEXT: popl %ebp
; X86-AVX-NEXT: retl
;
; X64-SSE-LABEL: testmsxs:
; X64-SSE-LABEL: test_llrint_i64_f32:
; X64-SSE: # %bb.0: # %entry
; X64-SSE-NEXT: cvtss2si %xmm0, %rax
; X64-SSE-NEXT: retq
;
; X64-AVX-LABEL: testmsxs:
; X64-AVX-LABEL: test_llrint_i64_f32:
; X64-AVX: # %bb.0: # %entry
; X64-AVX-NEXT: vcvtss2si %xmm0, %rax
; X64-AVX-NEXT: retq
Expand All @@ -107,8 +75,8 @@ entry:
ret i64 %0
}

define i64 @testmsxd(double %x) nounwind {
; X86-NOSSE-LABEL: testmsxd:
define i64 @test_llrint_i64_f64(double %x) nounwind {
; X86-NOSSE-LABEL: test_llrint_i64_f64:
; X86-NOSSE: # %bb.0: # %entry
; X86-NOSSE-NEXT: pushl %ebp
; X86-NOSSE-NEXT: movl %esp, %ebp
Expand All @@ -122,7 +90,7 @@ define i64 @testmsxd(double %x) nounwind {
; X86-NOSSE-NEXT: popl %ebp
; X86-NOSSE-NEXT: retl
;
; X86-SSE2-LABEL: testmsxd:
; X86-SSE2-LABEL: test_llrint_i64_f64:
; X86-SSE2: # %bb.0: # %entry
; X86-SSE2-NEXT: pushl %ebp
; X86-SSE2-NEXT: movl %esp, %ebp
Expand All @@ -138,7 +106,7 @@ define i64 @testmsxd(double %x) nounwind {
; X86-SSE2-NEXT: popl %ebp
; X86-SSE2-NEXT: retl
;
; X86-AVX-LABEL: testmsxd:
; X86-AVX-LABEL: test_llrint_i64_f64:
; X86-AVX: # %bb.0: # %entry
; X86-AVX-NEXT: pushl %ebp
; X86-AVX-NEXT: movl %esp, %ebp
Expand All @@ -154,12 +122,12 @@ define i64 @testmsxd(double %x) nounwind {
; X86-AVX-NEXT: popl %ebp
; X86-AVX-NEXT: retl
;
; X64-SSE-LABEL: testmsxd:
; X64-SSE-LABEL: test_llrint_i64_f64:
; X64-SSE: # %bb.0: # %entry
; X64-SSE-NEXT: cvtsd2si %xmm0, %rax
; X64-SSE-NEXT: retq
;
; X64-AVX-LABEL: testmsxd:
; X64-AVX-LABEL: test_llrint_i64_f64:
; X64-AVX: # %bb.0: # %entry
; X64-AVX-NEXT: vcvtsd2si %xmm0, %rax
; X64-AVX-NEXT: retq
Expand All @@ -168,8 +136,8 @@ entry:
ret i64 %0
}

define i64 @testmsll(x86_fp80 %x) nounwind {
; X86-LABEL: testmsll:
define i64 @test_llrint_i64_f80(x86_fp80 %x) nounwind {
; X86-LABEL: test_llrint_i64_f80:
; X86: # %bb.0: # %entry
; X86-NEXT: pushl %ebp
; X86-NEXT: movl %esp, %ebp
Expand All @@ -183,7 +151,7 @@ define i64 @testmsll(x86_fp80 %x) nounwind {
; X86-NEXT: popl %ebp
; X86-NEXT: retl
;
; X64-LABEL: testmsll:
; X64-LABEL: test_llrint_i64_f80:
; X64: # %bb.0: # %entry
; X64-NEXT: fldt {{[0-9]+}}(%rsp)
; X64-NEXT: fistpll -{{[0-9]+}}(%rsp)
Expand All @@ -195,8 +163,8 @@ entry:
}

; FIXME(#44744): incorrect libcall
define i64 @testmslq(fp128 %x) nounwind {
; X86-NOSSE-LABEL: testmslq:
define i64 @test_llrint_i64_f128(fp128 %x) nounwind {
; X86-NOSSE-LABEL: test_llrint_i64_f128:
; X86-NOSSE: # %bb.0: # %entry
; X86-NOSSE-NEXT: pushl %ebp
; X86-NOSSE-NEXT: movl %esp, %ebp
Expand All @@ -212,7 +180,7 @@ define i64 @testmslq(fp128 %x) nounwind {
; X86-NOSSE-NEXT: popl %ebp
; X86-NOSSE-NEXT: retl
;
; X86-SSE2-LABEL: testmslq:
; X86-SSE2-LABEL: test_llrint_i64_f128:
; X86-SSE2: # %bb.0: # %entry
; X86-SSE2-NEXT: pushl %ebp
; X86-SSE2-NEXT: movl %esp, %ebp
Expand All @@ -228,7 +196,7 @@ define i64 @testmslq(fp128 %x) nounwind {
; X86-SSE2-NEXT: popl %ebp
; X86-SSE2-NEXT: retl
;
; X86-AVX-LABEL: testmslq:
; X86-AVX-LABEL: test_llrint_i64_f128:
; X86-AVX: # %bb.0: # %entry
; X86-AVX-NEXT: pushl %ebp
; X86-AVX-NEXT: movl %esp, %ebp
Expand All @@ -241,11 +209,181 @@ define i64 @testmslq(fp128 %x) nounwind {
; X86-AVX-NEXT: popl %ebp
; X86-AVX-NEXT: retl
;
; X64-LABEL: testmslq:
; X64-LABEL: test_llrint_i64_f128:
; X64: # %bb.0: # %entry
; X64-NEXT: jmp llrintl@PLT # TAILCALL
entry:
%0 = tail call i64 @llvm.llrint.i64.fp128(fp128 %x)
%0 = tail call i64 @llvm.llrint.i64.f128(fp128 %x)
ret i64 %0
}

; FIXME: crash
; define i64 @test_llrint_i64_f16_strict(half %x) nounwind strictfp {
; entry:
; %0 = tail call i64 @llvm.experimental.constrained.llrint.i64.f16(half %x, metadata!"round.dynamic", metadata!"fpexcept.strict")
; ret i64 %0
; }

define i64 @test_llrint_i64_f32_strict(float %x) nounwind strictfp {
; X86-NOSSE-LABEL: test_llrint_i64_f32_strict:
; X86-NOSSE: # %bb.0: # %entry
; X86-NOSSE-NEXT: pushl %eax
; X86-NOSSE-NEXT: flds {{[0-9]+}}(%esp)
; X86-NOSSE-NEXT: fstps (%esp)
; X86-NOSSE-NEXT: wait
; X86-NOSSE-NEXT: calll llrintf
; X86-NOSSE-NEXT: popl %ecx
; X86-NOSSE-NEXT: retl
;
; X86-SSE2-LABEL: test_llrint_i64_f32_strict:
; X86-SSE2: # %bb.0: # %entry
; X86-SSE2-NEXT: pushl %eax
; X86-SSE2-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
; X86-SSE2-NEXT: movss %xmm0, (%esp)
; X86-SSE2-NEXT: calll llrintf
; X86-SSE2-NEXT: popl %ecx
; X86-SSE2-NEXT: retl
;
; X86-AVX-LABEL: test_llrint_i64_f32_strict:
; X86-AVX: # %bb.0: # %entry
; X86-AVX-NEXT: pushl %eax
; X86-AVX-NEXT: vmovss {{.*#+}} xmm0 = mem[0],zero,zero,zero
; X86-AVX-NEXT: vmovss %xmm0, (%esp)
; X86-AVX-NEXT: calll llrintf
; X86-AVX-NEXT: popl %ecx
; X86-AVX-NEXT: retl
;
; X64-LABEL: test_llrint_i64_f32_strict:
; X64: # %bb.0: # %entry
; X64-NEXT: pushq %rax
; X64-NEXT: callq llrintf@PLT
; X64-NEXT: popq %rcx
; X64-NEXT: retq
entry:
%0 = tail call i64 @llvm.experimental.constrained.llrint.i64.f32(float %x, metadata!"round.dynamic", metadata!"fpexcept.strict")
ret i64 %0
}

define i64 @test_llrint_i64_f64_strict(double %x) nounwind strictfp {
; X86-NOSSE-LABEL: test_llrint_i64_f64_strict:
; X86-NOSSE: # %bb.0: # %entry
; X86-NOSSE-NEXT: subl $8, %esp
; X86-NOSSE-NEXT: fldl {{[0-9]+}}(%esp)
; X86-NOSSE-NEXT: fstpl (%esp)
; X86-NOSSE-NEXT: wait
; X86-NOSSE-NEXT: calll llrint
; X86-NOSSE-NEXT: addl $8, %esp
; X86-NOSSE-NEXT: retl
;
; X86-SSE2-LABEL: test_llrint_i64_f64_strict:
; X86-SSE2: # %bb.0: # %entry
; X86-SSE2-NEXT: subl $8, %esp
; X86-SSE2-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero
; X86-SSE2-NEXT: movsd %xmm0, (%esp)
; X86-SSE2-NEXT: calll llrint
; X86-SSE2-NEXT: addl $8, %esp
; X86-SSE2-NEXT: retl
;
; X86-AVX-LABEL: test_llrint_i64_f64_strict:
; X86-AVX: # %bb.0: # %entry
; X86-AVX-NEXT: subl $8, %esp
; X86-AVX-NEXT: vmovsd {{.*#+}} xmm0 = mem[0],zero
; X86-AVX-NEXT: vmovsd %xmm0, (%esp)
; X86-AVX-NEXT: calll llrint
; X86-AVX-NEXT: addl $8, %esp
; X86-AVX-NEXT: retl
;
; X64-LABEL: test_llrint_i64_f64_strict:
; X64: # %bb.0: # %entry
; X64-NEXT: pushq %rax
; X64-NEXT: callq llrint@PLT
; X64-NEXT: popq %rcx
; X64-NEXT: retq
entry:
%0 = tail call i64 @llvm.experimental.constrained.llrint.i64.f64(double %x, metadata!"round.dynamic", metadata!"fpexcept.strict")
ret i64 %0
}

define i64 @test_llrint_i64_f80_strict(x86_fp80 %x) nounwind strictfp {
; X86-LABEL: test_llrint_i64_f80_strict:
; X86: # %bb.0: # %entry
; X86-NEXT: subl $12, %esp
; X86-NEXT: fldt {{[0-9]+}}(%esp)
; X86-NEXT: fstpt (%esp)
; X86-NEXT: wait
; X86-NEXT: calll llrintl
; X86-NEXT: addl $12, %esp
; X86-NEXT: retl
;
; X64-LABEL: test_llrint_i64_f80_strict:
; X64: # %bb.0: # %entry
; X64-NEXT: subq $24, %rsp
; X64-NEXT: fldt {{[0-9]+}}(%rsp)
; X64-NEXT: fstpt (%rsp)
; X64-NEXT: wait
; X64-NEXT: callq llrintl@PLT
; X64-NEXT: addq $24, %rsp
; X64-NEXT: retq
entry:
%0 = tail call i64 @llvm.experimental.constrained.llrint.i64.f80(x86_fp80 %x, metadata!"round.dynamic", metadata!"fpexcept.strict")
ret i64 %0
}

; FIXME(#44744): incorrect libcall
define i64 @test_llrint_i64_f128_strict(fp128 %x) nounwind strictfp {
; X86-NOSSE-LABEL: test_llrint_i64_f128_strict:
; X86-NOSSE: # %bb.0: # %entry
; X86-NOSSE-NEXT: pushl %ebp
; X86-NOSSE-NEXT: movl %esp, %ebp
; X86-NOSSE-NEXT: andl $-16, %esp
; X86-NOSSE-NEXT: subl $16, %esp
; X86-NOSSE-NEXT: pushl 20(%ebp)
; X86-NOSSE-NEXT: pushl 16(%ebp)
; X86-NOSSE-NEXT: pushl 12(%ebp)
; X86-NOSSE-NEXT: pushl 8(%ebp)
; X86-NOSSE-NEXT: calll llrintl
; X86-NOSSE-NEXT: addl $16, %esp
; X86-NOSSE-NEXT: movl %ebp, %esp
; X86-NOSSE-NEXT: popl %ebp
; X86-NOSSE-NEXT: retl
;
; X86-SSE2-LABEL: test_llrint_i64_f128_strict:
; X86-SSE2: # %bb.0: # %entry
; X86-SSE2-NEXT: pushl %ebp
; X86-SSE2-NEXT: movl %esp, %ebp
; X86-SSE2-NEXT: andl $-16, %esp
; X86-SSE2-NEXT: subl $16, %esp
; X86-SSE2-NEXT: pushl 20(%ebp)
; X86-SSE2-NEXT: pushl 16(%ebp)
; X86-SSE2-NEXT: pushl 12(%ebp)
; X86-SSE2-NEXT: pushl 8(%ebp)
; X86-SSE2-NEXT: calll llrintl
; X86-SSE2-NEXT: addl $16, %esp
; X86-SSE2-NEXT: movl %ebp, %esp
; X86-SSE2-NEXT: popl %ebp
; X86-SSE2-NEXT: retl
;
; X86-AVX-LABEL: test_llrint_i64_f128_strict:
; X86-AVX: # %bb.0: # %entry
; X86-AVX-NEXT: pushl %ebp
; X86-AVX-NEXT: movl %esp, %ebp
; X86-AVX-NEXT: andl $-16, %esp
; X86-AVX-NEXT: subl $32, %esp
; X86-AVX-NEXT: vmovups 8(%ebp), %xmm0
; X86-AVX-NEXT: vmovups %xmm0, (%esp)
; X86-AVX-NEXT: calll llrintl
; X86-AVX-NEXT: movl %ebp, %esp
; X86-AVX-NEXT: popl %ebp
; X86-AVX-NEXT: retl
;
; X64-LABEL: test_llrint_i64_f128_strict:
; X64: # %bb.0: # %entry
; X64-NEXT: pushq %rax
; X64-NEXT: callq llrintl@PLT
; X64-NEXT: popq %rcx
; X64-NEXT: retq
entry:
%0 = tail call i64 @llvm.experimental.constrained.llrint.i64.f128(fp128 %x, metadata!"round.dynamic", metadata!"fpexcept.strict")
ret i64 %0
}

Expand Down
Loading