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 5 6 ; This is a test for float to half float conversions on x86-64. 7 ; 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. 15 ; 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 21 22 23 define void @test1(float %src, i16* %dest) { 24 %1 = tail call i16 @llvm.convert.to.fp16(float %src) 25 store i16 %1, i16* %dest, align 2 26 ret void 27 } 28 ; CHECK-LABEL: test1 29 ; LIBCALL: callq __gnu_f2h_ieee 30 ; SOFTFLOAT: callq __gnu_f2h_ieee 31 ; F16C: vcvtps2ph 32 ; CHECK: ret 33 34 35 define float @test2(i16* nocapture %src) { 36 %1 = load i16* %src, align 2 37 %2 = tail call float @llvm.convert.from.fp16(i16 %1) 38 ret float %2 39 } 40 ; CHECK-LABEL: test2: 41 ; LIBCALL: jmp __gnu_h2f_ieee 42 ; SOFTFLOAT: callq __gnu_h2f_ieee 43 ; F16C: vcvtph2ps 44 ; F16C: ret 45 46 47 define float @test3(float %src) nounwind uwtable readnone { 48 %1 = tail call i16 @llvm.convert.to.fp16(float %src) 49 %2 = tail call float @llvm.convert.from.fp16(i16 %1) 50 ret float %2 51 } 52 53 ; CHECK-LABEL: test3: 54 ; LIBCALL: callq __gnu_f2h_ieee 55 ; LIBCALL: jmp __gnu_h2f_ieee 56 ; SOFTFLOAT: callq __gnu_f2h_ieee 57 ; SOFTFLOAT: callq __gnu_h2f_ieee 58 ; F16C: vcvtps2ph 59 ; F16C-NEXT: vcvtph2ps 60 ; F16C: ret 61 62 declare float @llvm.convert.from.fp16(i16) nounwind readnone 63 declare i16 @llvm.convert.to.fp16(float) nounwind readnone 64 65