1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 2; RUN: llc -mtriple=x86_64-unknown-unknown -mattr=+f16c < %s | FileCheck %s --check-prefix=ALL --check-prefix=F16C 3; RUN: llc -mtriple=x86_64-unknown-unknown -mattr=+avx < %s | FileCheck %s --check-prefix=ALL --check-prefix=AVX 4 5define zeroext i16 @test1_fast(double %d) #0 { 6; F16C-LABEL: test1_fast: 7; F16C: # %bb.0: # %entry 8; F16C-NEXT: vcvtsd2ss %xmm0, %xmm0, %xmm0 9; F16C-NEXT: vcvtps2ph $4, %xmm0, %xmm0 10; F16C-NEXT: vmovd %xmm0, %eax 11; F16C-NEXT: # kill: def $ax killed $ax killed $eax 12; F16C-NEXT: retq 13; 14; AVX-LABEL: test1_fast: 15; AVX: # %bb.0: # %entry 16; AVX-NEXT: pushq %rax 17; AVX-NEXT: .cfi_def_cfa_offset 16 18; AVX-NEXT: callq __truncdfhf2 19; AVX-NEXT: popq %rcx 20; AVX-NEXT: .cfi_def_cfa_offset 8 21; AVX-NEXT: retq 22entry: 23 %0 = tail call i16 @llvm.convert.to.fp16.f64(double %d) 24 ret i16 %0 25} 26 27define zeroext i16 @test2_fast(x86_fp80 %d) #0 { 28; F16C-LABEL: test2_fast: 29; F16C: # %bb.0: # %entry 30; F16C-NEXT: fldt {{[0-9]+}}(%rsp) 31; F16C-NEXT: fstps -{{[0-9]+}}(%rsp) 32; F16C-NEXT: vmovss {{.*#+}} xmm0 = mem[0],zero,zero,zero 33; F16C-NEXT: vcvtps2ph $4, %xmm0, %xmm0 34; F16C-NEXT: vmovd %xmm0, %eax 35; F16C-NEXT: # kill: def $ax killed $ax killed $eax 36; F16C-NEXT: retq 37; 38; AVX-LABEL: test2_fast: 39; AVX: # %bb.0: # %entry 40; AVX-NEXT: subq $24, %rsp 41; AVX-NEXT: .cfi_def_cfa_offset 32 42; AVX-NEXT: fldt {{[0-9]+}}(%rsp) 43; AVX-NEXT: fstpt (%rsp) 44; AVX-NEXT: callq __truncxfhf2 45; AVX-NEXT: addq $24, %rsp 46; AVX-NEXT: .cfi_def_cfa_offset 8 47; AVX-NEXT: retq 48entry: 49 %0 = tail call i16 @llvm.convert.to.fp16.f80(x86_fp80 %d) 50 ret i16 %0 51} 52 53define zeroext i16 @test1(double %d) #1 { 54; ALL-LABEL: test1: 55; ALL: # %bb.0: # %entry 56; ALL-NEXT: pushq %rax 57; ALL-NEXT: .cfi_def_cfa_offset 16 58; ALL-NEXT: callq __truncdfhf2 59; ALL-NEXT: popq %rcx 60; ALL-NEXT: .cfi_def_cfa_offset 8 61; ALL-NEXT: retq 62entry: 63 %0 = tail call i16 @llvm.convert.to.fp16.f64(double %d) 64 ret i16 %0 65} 66 67define zeroext i16 @test2(x86_fp80 %d) #1 { 68; ALL-LABEL: test2: 69; ALL: # %bb.0: # %entry 70; ALL-NEXT: subq $24, %rsp 71; ALL-NEXT: .cfi_def_cfa_offset 32 72; ALL-NEXT: fldt {{[0-9]+}}(%rsp) 73; ALL-NEXT: fstpt (%rsp) 74; ALL-NEXT: callq __truncxfhf2 75; ALL-NEXT: addq $24, %rsp 76; ALL-NEXT: .cfi_def_cfa_offset 8 77; ALL-NEXT: retq 78entry: 79 %0 = tail call i16 @llvm.convert.to.fp16.f80(x86_fp80 %d) 80 ret i16 %0 81} 82 83declare i16 @llvm.convert.to.fp16.f64(double) 84declare i16 @llvm.convert.to.fp16.f80(x86_fp80) 85 86attributes #0 = { nounwind readnone uwtable "unsafe-fp-math"="true" "use-soft-float"="false" } 87attributes #1 = { nounwind readnone uwtable "unsafe-fp-math"="false" "use-soft-float"="false" } 88