1; RUN: llc -mtriple=armv7a--none-eabi < %s | FileCheck --check-prefix=CHECK --check-prefix=CHECK-HARDFLOAT-EABI %s 2; RUN: llc -mtriple=armv7a--none-gnueabi < %s | FileCheck --check-prefix=CHECK --check-prefix=CHECK-HARDFLOAT-GNU %s 3; RUN: llc -mtriple=armv7a--none-musleabi < %s | FileCheck --check-prefix=CHECK --check-prefix=CHECK-HARDFLOAT-GNU %s 4; RUN: llc -mtriple=armv8-eabihf < %s | FileCheck --check-prefix=CHECK --check-prefix=CHECK-ARMV8 %s 5; RUN: llc -mtriple=thumbv7m-eabi < %s | FileCheck --check-prefix=CHECK --check-prefix=CHECK-SOFTFLOAT-EABI %s 6; RUN: llc -mtriple=thumbv7m-gnueabi < %s | FileCheck --check-prefix=CHECK --check-prefix=CHECK-SOFTFLOAT-GNU %s 7; RUN: llc -mtriple=thumbv7m-musleabi < %s | FileCheck --check-prefix=CHECK --check-prefix=CHECK-SOFTFLOAT-GNU %s 8 9;; +fp16 is special: it has f32->f16 (unlike v7), but not f64->f16 (unlike v8). 10;; This exposes unsafe-fp-math optimization opportunities; test that. 11; RUN: llc -mattr=+vfp3,+fp16 < %s |\ 12; RUN: FileCheck --check-prefix=CHECK --check-prefix=CHECK-FP16 --check-prefix=CHECK-FP16-SAFE %s 13; RUN: llc -mattr=+vfp3,+fp16 < %s -enable-unsafe-fp-math |\ 14; RUN: FileCheck --check-prefix=CHECK --check-prefix=CHECK-FP16 --check-prefix=CHECK-FP16-UNSAFE %s 15 16target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-n32" 17target triple = "armv7---eabihf" 18 19@x = global i16 12902 20@y = global i16 0 21@z = common global i16 0 22 23define void @foo() nounwind { 24; CHECK-LABEL: foo: 25entry: 26 %0 = load i16, i16* @x, align 2 27 %1 = load i16, i16* @y, align 2 28 %2 = tail call float @llvm.convert.from.fp16.f32(i16 %0) 29; CHECK-HARDFLOAT-EABI: __aeabi_h2f 30; CHECK-HARDFLOAT-GNU: __gnu_h2f_ieee 31; CHECK-FP16: vcvtb.f32.f16 32; CHECK-ARMV8: vcvtb.f32.f16 33; CHECK-SOFTFLOAT-EABI: __aeabi_h2f 34; CHECK-SOFTFLOAT-GNU: __gnu_h2f_ieee 35 %3 = tail call float @llvm.convert.from.fp16.f32(i16 %1) 36; CHECK-HARDFLOAT-EABI: __aeabi_h2f 37; CHECK-HARDFLOAT-GNU: __gnu_h2f_ieee 38; CHECK-FP16: vcvtb.f32.f16 39; CHECK-ARMV8: vcvtb.f32.f16 40; CHECK-SOFTFLOAT-EABI: __aeabi_h2f 41; CHECK-SOFTFLOAT-GNU: __gnu_h2f_ieee 42 %4 = fadd float %2, %3 43 %5 = tail call i16 @llvm.convert.to.fp16.f32(float %4) 44; CHECK-HARDFLOAT-EABI: __aeabi_f2h 45; CHECK-HARDFLOAT-GNU: __gnu_f2h_ieee 46; CHECK-FP16: vcvtb.f16.f32 47; CHECK-ARMV8: vcvtb.f16.f32 48; CHECK-SOFTFLOAT-EABI: __aeabi_f2h 49; CHECK-SOFTFLOAT-GNU: __gnu_f2h_ieee 50 store i16 %5, i16* @x, align 2 51 ret void 52} 53 54define double @test_from_fp16(i16 %in) { 55; CHECK-LABEL: test_from_fp16: 56 %val = call double @llvm.convert.from.fp16.f64(i16 %in) 57; CHECK-HARDFLOAT-EABI: bl __aeabi_h2f 58; CHECK-HARDFLOAT-EABI: vmov [[TMP:s[0-9]+]], r0 59; CHECK-HARDFLOAT-EABI: vcvt.f64.f32 {{d[0-9]+}}, [[TMP]] 60 61; CHECK-HARDFLOAT-GNU: bl __gnu_h2f_ieee 62; CHECK-HARDFLOAT-GNU: vmov [[TMP:s[0-9]+]], r0 63; CHECK-HARDFLOAT-GNU: vcvt.f64.f32 {{d[0-9]+}}, [[TMP]] 64 65; CHECK-FP16: vmov [[TMP16:s[0-9]+]], r0 66; CHECK-FP16: vcvtb.f32.f16 [[TMP32:s[0-9]+]], [[TMP16]] 67; CHECK-FP16: vcvt.f64.f32 d0, [[TMP32]] 68 69; CHECK-ARMV8: vmov [[TMP:s[0-9]+]], r0 70; CHECK-ARMV8: vcvtb.f64.f16 d0, [[TMP]] 71 72; CHECK-SOFTFLOAT-EABI: bl __aeabi_h2f 73; CHECK-SOFTFLOAT-EABI: bl __aeabi_f2d 74 75; CHECK-SOFTFLOAT-GNU: bl __gnu_h2f_ieee 76; CHECK-SOFTFLOAT-GNU: bl __aeabi_f2d 77 ret double %val 78} 79 80define i16 @test_to_fp16(double %in) { 81; CHECK-LABEL: test_to_fp16: 82 %val = call i16 @llvm.convert.to.fp16.f64(double %in) 83; CHECK-HARDFLOAT-EABI: bl __aeabi_d2h 84 85; CHECK-HARDFLOAT-GNU: bl __aeabi_d2h 86 87; CHECK-FP16-SAFE: bl __aeabi_d2h 88 89; CHECK-FP16-UNSAFE: vcvt.f32.f64 s0, d0 90; CHECK-FP16-UNSAFE-NEXT: vcvtb.f16.f32 s0, s0 91 92; CHECK-ARMV8: vcvtb.f16.f64 [[TMP:s[0-9]+]], d0 93; CHECK-ARMV8: vmov r0, [[TMP]] 94 95; CHECK-SOFTFLOAT-EABI: bl __aeabi_d2h 96 97; CHECK-SOFTFLOAT-GNU: bl __aeabi_d2h 98 ret i16 %val 99} 100 101declare float @llvm.convert.from.fp16.f32(i16) nounwind readnone 102declare double @llvm.convert.from.fp16.f64(i16) nounwind readnone 103 104declare i16 @llvm.convert.to.fp16.f32(float) nounwind readnone 105declare i16 @llvm.convert.to.fp16.f64(double) nounwind readnone 106