source: icGREP/icgrep-devel/llvm-3.8.0.src/test/CodeGen/ARM/fp16.ll @ 5027

Last change on this file since 5027 was 5027, checked in by cameron, 3 years ago

Upgrade to llvm 3.8

File size: 3.3 KB
Line 
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 -mattr=+vfp3,+fp16 < %s | FileCheck --check-prefix=CHECK --check-prefix=CHECK-FP16 %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
8target 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"
9target triple = "armv7---eabihf"
10
11@x = global i16 12902
12@y = global i16 0
13@z = common global i16 0
14
15define void @foo() nounwind {
16; CHECK-LABEL: foo:
17entry:
18  %0 = load i16, i16* @x, align 2
19  %1 = load i16, i16* @y, align 2
20  %2 = tail call float @llvm.convert.from.fp16.f32(i16 %0)
21; CHECK-HARDFLOAT-EABI: __aeabi_h2f
22; CHECK-HARDFLOAT-GNU: __gnu_h2f_ieee
23; CHECK-FP16: vcvtb.f32.f16
24; CHECK-ARMv8: vcvtb.f32.f16
25; CHECK-SOFTFLOAT-EABI: __aeabi_h2f
26; CHECK-SOFTFLOAT-GNU: __gnu_h2f_ieee
27  %3 = tail call float @llvm.convert.from.fp16.f32(i16 %1)
28; CHECK-HARDFLOAT-EABI: __aeabi_h2f
29; CHECK-HARDFLOAT-GNU: __gnu_h2f_ieee
30; CHECK-FP16: vcvtb.f32.f16
31; CHECK-ARMV8: vcvtb.f32.f16
32; CHECK-SOFTFLOAT-EABI: __aeabi_h2f
33; CHECK-SOFTFLOAT-GNU: __gnu_h2f_ieee
34  %4 = fadd float %2, %3
35  %5 = tail call i16 @llvm.convert.to.fp16.f32(float %4)
36; CHECK-HARDFLOAT-EABI: __aeabi_f2h
37; CHECK-HARDFLOAT-GNU: __gnu_f2h_ieee
38; CHECK-FP16: vcvtb.f16.f32
39; CHECK-ARMV8: vcvtb.f16.f32
40; CHECK-SOFTFLOAT-EABI: __aeabi_f2h
41; CHECK-SOFTFLOAT-GNU: __gnu_f2h_ieee
42  store i16 %5, i16* @x, align 2
43  ret void
44}
45
46define double @test_from_fp16(i16 %in) {
47; CHECK-LABEL: test_from_fp16:
48  %val = call double @llvm.convert.from.fp16.f64(i16 %in)
49; CHECK-HARDFLOAT-EABI: bl __aeabi_h2f
50; CHECK-HARDFLOAT-EABI: vmov [[TMP:s[0-9]+]], r0
51; CHECK-HARDFLOAT-EABI: vcvt.f64.f32 {{d[0-9]+}}, [[TMP]]
52
53; CHECK-HARDFLOAT-GNU: bl __gnu_h2f_ieee
54; CHECK-HARDFLOAT-GNU: vmov [[TMP:s[0-9]+]], r0
55; CHECK-HARDFLOAT-GNU: vcvt.f64.f32 {{d[0-9]+}}, [[TMP]]
56
57; CHECK-FP16: vmov [[TMP16:s[0-9]+]], r0
58; CHECK-FP16: vcvtb.f32.f16 [[TMP32:s[0-9]+]], [[TMP16]]
59; CHECK-FP16: vcvt.f64.f32 d0, [[TMP32]]
60
61; CHECK-ARMV8: vmov [[TMP:s[0-9]+]], r0
62; CHECK-ARMV8: vcvtb.f64.f16 d0, [[TMP]]
63
64; CHECK-SOFTFLOAT-EABI: bl __aeabi_h2f
65; CHECK-SOFTFLOAT-EABI: bl __aeabi_f2d
66
67; CHECK-SOFTFLOAT-GNU: bl __gnu_h2f_ieee
68; CHECK-SOFTFLOAT-GNU: bl __aeabi_f2d
69  ret double %val
70}
71
72define i16 @test_to_fp16(double %in) {
73; CHECK-LABEL: test_to_fp16:
74  %val = call i16 @llvm.convert.to.fp16.f64(double %in)
75; CHECK-HARDFLOAT-EABI: bl __aeabi_d2h
76
77; CHECK-HARDFLOAT-GNU: bl __aeabi_d2h
78
79; CHECK-FP16: bl __aeabi_d2h
80
81; CHECK-ARMV8: vcvtb.f16.f64 [[TMP:s[0-9]+]], d0
82; CHECK-ARMV8: vmov r0, [[TMP]]
83
84; CHECK-SOFTFLOAT-EABI: bl __aeabi_d2h
85
86; CHECK-SOFTFLOAT-GNU: bl __aeabi_d2h
87  ret i16 %val
88}
89
90declare float @llvm.convert.from.fp16.f32(i16) nounwind readnone
91declare double @llvm.convert.from.fp16.f64(i16) nounwind readnone
92
93declare i16 @llvm.convert.to.fp16.f32(float) nounwind readnone
94declare i16 @llvm.convert.to.fp16.f64(double) nounwind readnone
Note: See TracBrowser for help on using the repository browser.