Home | History | Annotate | Download | only in X86
      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.f32(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, i16* %src, align 2
     37   %2 = tail call float @llvm.convert.from.fp16.f32(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.f32(float %src)
     49   %2 = tail call float @llvm.convert.from.fp16.f32(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 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)
     65   ret double %2
     66 }
     67 ; CHECK-LABEL: test4:
     68 ; LIBCALL: callq  __gnu_h2f_ieee
     69 ; LIBCALL: cvtss2sd
     70 ; SOFTFLOAT: callq  __gnu_h2f_ieee
     71 ; SOFTFLOAT: callq __extendsfdf2
     72 ; F16C: vcvtph2ps
     73 ; F16C: vcvtss2sd
     74 ; F16C: ret
     75 
     76 
     77 define i16 @test5(double %src) {
     78   %val = tail call i16 @llvm.convert.to.fp16.f64(double %src)
     79   ret i16 %val
     80 }
     81 ; CHECK-LABEL: test5:
     82 ; LIBCALL: jmp  __truncdfhf2
     83 ; SOFTFLOAT: callq  __truncdfhf2
     84 ; F16C: jmp __truncdfhf2
     85 
     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
     90