1 ; RUN: llc < %s -march=x86-64 -mtriple=x86_64-unknown-linux-gnu -mcpu=corei7 -mattr=-f16c | FileCheck %s -check-prefix=CHECK -check-prefix=LIBCALL
2 ; RUN: llc < %s -march=x86-64 -mtriple=x86_64-unknown-linux-gnu -mcpu=corei7 -mattr=+f16c | FileCheck %s -check-prefix=CHECK -check-prefix=F16C
3 ; RUN: llc < %s -march=x86-64 -mtriple=x86_64-unknown-linux-gnu -mcpu=corei7 -soft-float=1 -mattr=-f16c | FileCheck %s -check-prefix=CHECK -check-prefix=SOFTFLOAT
4 ; RUN: llc < %s -march=x86-64 -mtriple=x86_64-unknown-linux-gnu -mcpu=corei7 -soft-float=1 -mattr=+f16c | FileCheck %s -check-prefix=CHECK -check-prefix=SOFTFLOAT
6 ; This is a test for float to half float conversions on x86-64.
8 ; If flag -soft-float is set, or if there is no F16C support, then:
9 ; 1) half float to float conversions are
10 ; translated into calls to __gnu_h2f_ieee defined
11 ; by the compiler runtime library;
12 ; 2) float to half float conversions are translated into calls
13 ; to __gnu_f2h_ieee which expected to be defined by the
14 ; compiler runtime library.
16 ; Otherwise (we have F16C support):
17 ; 1) half float to float conversion are translated using
18 ; vcvtph2ps instructions;
19 ; 2) float to half float conversions are translated using
20 ; vcvtps2ph instructions
23 define void @test1(float %src, i16* %dest) {
24 %1 = tail call i16 @llvm.convert.to.fp16.f32(float %src)
25 store i16 %1, i16* %dest, align 2
29 ; LIBCALL: callq __gnu_f2h_ieee
30 ; SOFTFLOAT: callq __gnu_f2h_ieee
35 define float @test2(i16* nocapture %src) {
36 %1 = load i16, i16* %src, align 2
37 %2 = tail call float @llvm.convert.from.fp16.f32(i16 %1)
41 ; LIBCALL: jmp __gnu_h2f_ieee
42 ; SOFTFLOAT: callq __gnu_h2f_ieee
47 define float @test3(float %src) nounwind uwtable readnone {
48 %1 = tail call i16 @llvm.convert.to.fp16.f32(float %src)
49 %2 = tail call float @llvm.convert.from.fp16.f32(i16 %1)
54 ; LIBCALL: callq __gnu_f2h_ieee
55 ; LIBCALL: jmp __gnu_h2f_ieee
56 ; SOFTFLOAT: callq __gnu_f2h_ieee
57 ; SOFTFLOAT: callq __gnu_h2f_ieee
59 ; F16C-NEXT: vcvtph2ps
62 define double @test4(i16* nocapture %src) {
63 %1 = load i16, i16* %src, align 2
64 %2 = tail call double @llvm.convert.from.fp16.f64(i16 %1)
68 ; LIBCALL: callq __gnu_h2f_ieee
70 ; SOFTFLOAT: callq __gnu_h2f_ieee
71 ; SOFTFLOAT: callq __extendsfdf2
77 define i16 @test5(double %src) {
78 %val = tail call i16 @llvm.convert.to.fp16.f64(double %src)
82 ; LIBCALL: jmp __truncdfhf2
83 ; SOFTFLOAT: callq __truncdfhf2
84 ; F16C: jmp __truncdfhf2
86 declare float @llvm.convert.from.fp16.f32(i16) nounwind readnone
87 declare i16 @llvm.convert.to.fp16.f32(float) nounwind readnone
88 declare double @llvm.convert.from.fp16.f64(i16) nounwind readnone
89 declare i16 @llvm.convert.to.fp16.f64(double) nounwind readnone