2015-10-08 00:58:49 +08:00
|
|
|
; RUN: llc -mtriple=armv7a--none-eabi < %s | FileCheck --check-prefix=CHECK --check-prefix=CHECK-HARDFLOAT-EABI %s
|
|
|
|
; RUN: llc -mtriple=armv7a--none-gnueabi < %s | FileCheck --check-prefix=CHECK --check-prefix=CHECK-HARDFLOAT-GNU %s
|
2016-06-25 05:14:33 +08:00
|
|
|
; RUN: llc -mtriple=armv7a--none-musleabi < %s | FileCheck --check-prefix=CHECK --check-prefix=CHECK-HARDFLOAT-GNU %s
|
2015-10-08 00:58:49 +08:00
|
|
|
; RUN: llc -mtriple=armv8-eabihf < %s | FileCheck --check-prefix=CHECK --check-prefix=CHECK-ARMV8 %s
|
|
|
|
; RUN: llc -mtriple=thumbv7m-eabi < %s | FileCheck --check-prefix=CHECK --check-prefix=CHECK-SOFTFLOAT-EABI %s
|
|
|
|
; RUN: llc -mtriple=thumbv7m-gnueabi < %s | FileCheck --check-prefix=CHECK --check-prefix=CHECK-SOFTFLOAT-GNU %s
|
2016-06-25 05:14:33 +08:00
|
|
|
; RUN: llc -mtriple=thumbv7m-musleabi < %s | FileCheck --check-prefix=CHECK --check-prefix=CHECK-SOFTFLOAT-GNU %s
|
2014-07-29 17:56:38 +08:00
|
|
|
|
2016-01-15 03:45:36 +08:00
|
|
|
;; +fp16 is special: it has f32->f16 (unlike v7), but not f64->f16 (unlike v8).
|
|
|
|
;; This exposes unsafe-fp-math optimization opportunities; test that.
|
|
|
|
; RUN: llc -mattr=+vfp3,+fp16 < %s |\
|
|
|
|
; RUN: FileCheck --check-prefix=CHECK --check-prefix=CHECK-FP16 --check-prefix=CHECK-FP16-SAFE %s
|
|
|
|
; RUN: llc -mattr=+vfp3,+fp16 < %s -enable-unsafe-fp-math |\
|
|
|
|
; RUN: FileCheck --check-prefix=CHECK --check-prefix=CHECK-FP16 --check-prefix=CHECK-FP16-UNSAFE %s
|
|
|
|
|
2010-03-15 02:42:43 +08:00
|
|
|
target 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"
|
2014-08-11 17:12:32 +08:00
|
|
|
target triple = "armv7---eabihf"
|
2010-03-15 02:42:43 +08:00
|
|
|
|
|
|
|
@x = global i16 12902
|
|
|
|
@y = global i16 0
|
|
|
|
@z = common global i16 0
|
|
|
|
|
2014-08-11 17:12:32 +08:00
|
|
|
define void @foo() nounwind {
|
2013-07-14 14:24:09 +08:00
|
|
|
; CHECK-LABEL: foo:
|
2010-03-15 02:42:43 +08:00
|
|
|
entry:
|
2015-02-28 05:17:42 +08:00
|
|
|
%0 = load i16, i16* @x, align 2
|
|
|
|
%1 = load i16, i16* @y, align 2
|
2014-07-17 18:51:23 +08:00
|
|
|
%2 = tail call float @llvm.convert.from.fp16.f32(i16 %0)
|
2015-10-08 00:58:49 +08:00
|
|
|
; CHECK-HARDFLOAT-EABI: __aeabi_h2f
|
|
|
|
; CHECK-HARDFLOAT-GNU: __gnu_h2f_ieee
|
2012-08-15 07:36:01 +08:00
|
|
|
; CHECK-FP16: vcvtb.f32.f16
|
2014-07-17 19:27:04 +08:00
|
|
|
; CHECK-ARMv8: vcvtb.f32.f16
|
2015-10-08 00:58:49 +08:00
|
|
|
; CHECK-SOFTFLOAT-EABI: __aeabi_h2f
|
|
|
|
; CHECK-SOFTFLOAT-GNU: __gnu_h2f_ieee
|
2014-07-17 18:51:23 +08:00
|
|
|
%3 = tail call float @llvm.convert.from.fp16.f32(i16 %1)
|
2015-10-08 00:58:49 +08:00
|
|
|
; CHECK-HARDFLOAT-EABI: __aeabi_h2f
|
|
|
|
; CHECK-HARDFLOAT-GNU: __gnu_h2f_ieee
|
2012-08-15 07:36:01 +08:00
|
|
|
; CHECK-FP16: vcvtb.f32.f16
|
2014-07-17 19:27:04 +08:00
|
|
|
; CHECK-ARMV8: vcvtb.f32.f16
|
2015-10-08 00:58:49 +08:00
|
|
|
; CHECK-SOFTFLOAT-EABI: __aeabi_h2f
|
|
|
|
; CHECK-SOFTFLOAT-GNU: __gnu_h2f_ieee
|
2010-03-15 02:42:43 +08:00
|
|
|
%4 = fadd float %2, %3
|
2014-07-17 18:51:23 +08:00
|
|
|
%5 = tail call i16 @llvm.convert.to.fp16.f32(float %4)
|
2015-10-08 00:58:49 +08:00
|
|
|
; CHECK-HARDFLOAT-EABI: __aeabi_f2h
|
|
|
|
; CHECK-HARDFLOAT-GNU: __gnu_f2h_ieee
|
2012-08-15 07:36:01 +08:00
|
|
|
; CHECK-FP16: vcvtb.f16.f32
|
2014-07-17 19:27:04 +08:00
|
|
|
; CHECK-ARMV8: vcvtb.f16.f32
|
2015-10-08 00:58:49 +08:00
|
|
|
; CHECK-SOFTFLOAT-EABI: __aeabi_f2h
|
|
|
|
; CHECK-SOFTFLOAT-GNU: __gnu_f2h_ieee
|
2010-03-15 02:42:43 +08:00
|
|
|
store i16 %5, i16* @x, align 2
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2014-08-11 17:12:32 +08:00
|
|
|
define double @test_from_fp16(i16 %in) {
|
2014-07-17 19:27:04 +08:00
|
|
|
; CHECK-LABEL: test_from_fp16:
|
|
|
|
%val = call double @llvm.convert.from.fp16.f64(i16 %in)
|
2015-10-08 00:58:49 +08:00
|
|
|
; CHECK-HARDFLOAT-EABI: bl __aeabi_h2f
|
|
|
|
; CHECK-HARDFLOAT-EABI: vmov [[TMP:s[0-9]+]], r0
|
|
|
|
; CHECK-HARDFLOAT-EABI: vcvt.f64.f32 {{d[0-9]+}}, [[TMP]]
|
|
|
|
|
|
|
|
; CHECK-HARDFLOAT-GNU: bl __gnu_h2f_ieee
|
|
|
|
; CHECK-HARDFLOAT-GNU: vmov [[TMP:s[0-9]+]], r0
|
|
|
|
; CHECK-HARDFLOAT-GNU: vcvt.f64.f32 {{d[0-9]+}}, [[TMP]]
|
2014-07-17 19:27:04 +08:00
|
|
|
|
|
|
|
; CHECK-FP16: vmov [[TMP16:s[0-9]+]], r0
|
|
|
|
; CHECK-FP16: vcvtb.f32.f16 [[TMP32:s[0-9]+]], [[TMP16]]
|
|
|
|
; CHECK-FP16: vcvt.f64.f32 d0, [[TMP32]]
|
|
|
|
|
|
|
|
; CHECK-ARMV8: vmov [[TMP:s[0-9]+]], r0
|
|
|
|
; CHECK-ARMV8: vcvtb.f64.f16 d0, [[TMP]]
|
2014-07-29 17:56:38 +08:00
|
|
|
|
2015-10-08 00:58:49 +08:00
|
|
|
; CHECK-SOFTFLOAT-EABI: bl __aeabi_h2f
|
|
|
|
; CHECK-SOFTFLOAT-EABI: bl __aeabi_f2d
|
|
|
|
|
|
|
|
; CHECK-SOFTFLOAT-GNU: bl __gnu_h2f_ieee
|
|
|
|
; CHECK-SOFTFLOAT-GNU: bl __aeabi_f2d
|
2014-07-17 19:27:04 +08:00
|
|
|
ret double %val
|
|
|
|
}
|
|
|
|
|
2014-08-11 17:12:32 +08:00
|
|
|
define i16 @test_to_fp16(double %in) {
|
2014-07-17 19:27:04 +08:00
|
|
|
; CHECK-LABEL: test_to_fp16:
|
|
|
|
%val = call i16 @llvm.convert.to.fp16.f64(double %in)
|
2015-10-08 00:58:49 +08:00
|
|
|
; CHECK-HARDFLOAT-EABI: bl __aeabi_d2h
|
|
|
|
|
|
|
|
; CHECK-HARDFLOAT-GNU: bl __aeabi_d2h
|
2014-07-17 19:27:04 +08:00
|
|
|
|
2016-01-15 03:45:36 +08:00
|
|
|
; CHECK-FP16-SAFE: bl __aeabi_d2h
|
|
|
|
|
|
|
|
; CHECK-FP16-UNSAFE: vcvt.f32.f64 s0, d0
|
|
|
|
; CHECK-FP16-UNSAFE-NEXT: vcvtb.f16.f32 s0, s0
|
2014-07-17 19:27:04 +08:00
|
|
|
|
|
|
|
; CHECK-ARMV8: vcvtb.f16.f64 [[TMP:s[0-9]+]], d0
|
|
|
|
; CHECK-ARMV8: vmov r0, [[TMP]]
|
2014-07-29 17:56:38 +08:00
|
|
|
|
2015-10-08 00:58:49 +08:00
|
|
|
; CHECK-SOFTFLOAT-EABI: bl __aeabi_d2h
|
|
|
|
|
|
|
|
; CHECK-SOFTFLOAT-GNU: bl __aeabi_d2h
|
2014-07-17 19:27:04 +08:00
|
|
|
ret i16 %val
|
|
|
|
}
|
|
|
|
|
2014-07-17 18:51:23 +08:00
|
|
|
declare float @llvm.convert.from.fp16.f32(i16) nounwind readnone
|
2014-07-17 19:27:04 +08:00
|
|
|
declare double @llvm.convert.from.fp16.f64(i16) nounwind readnone
|
2010-03-15 02:42:43 +08:00
|
|
|
|
2014-07-17 18:51:23 +08:00
|
|
|
declare i16 @llvm.convert.to.fp16.f32(float) nounwind readnone
|
2014-07-17 19:27:04 +08:00
|
|
|
declare i16 @llvm.convert.to.fp16.f64(double) nounwind readnone
|