Revert r216805 "[MachineCombiner][AArch64] Use the correct register class for MADD...
[oota-llvm.git] / test / CodeGen / AArch64 / fp16-instructions.ll
1 ; RUN: llc < %s -mtriple=aarch64-none-eabi | FileCheck %s
2
3 define half @add_h(half %a, half %b) {
4 entry:
5 ; CHECK-LABEL: add_h:
6 ; CHECK-DAG: fcvt [[OP1:s[0-9]+]], h0
7 ; CHECK-DAG: fcvt [[OP2:s[0-9]+]], h1
8 ; CHECK: fadd [[RES:s[0-9]+]], [[OP1]], [[OP2]]
9 ; CHECK: fcvt h0, [[RES]]
10   %0 = fadd half %a, %b
11   ret half %0
12 }
13
14
15 define half @sub_h(half %a, half %b) {
16 entry:
17 ; CHECK-LABEL: sub_h:
18 ; CHECK-DAG: fcvt [[OP1:s[0-9]+]], h0
19 ; CHECK-DAG: fcvt [[OP2:s[0-9]+]], h1
20 ; CHECK: fsub [[RES:s[0-9]+]], [[OP1]], [[OP2]]
21 ; CHECK: fcvt h0, [[RES]]
22   %0 = fsub half %a, %b
23   ret half %0
24 }
25
26
27 define half @mul_h(half %a, half %b) {
28 entry:
29 ; CHECK-LABEL: mul_h:
30 ; CHECK-DAG: fcvt [[OP1:s[0-9]+]], h0
31 ; CHECK-DAG: fcvt [[OP2:s[0-9]+]], h1
32 ; CHECK: fmul [[RES:s[0-9]+]], [[OP1]], [[OP2]]
33 ; CHECK: fcvt h0, [[RES]]
34   %0 = fmul half %a, %b
35   ret half %0
36 }
37
38
39 define half @div_h(half %a, half %b) {
40 entry:
41 ; CHECK-LABEL: div_h:
42 ; CHECK-DAG: fcvt [[OP1:s[0-9]+]], h0
43 ; CHECK-DAG: fcvt [[OP2:s[0-9]+]], h1
44 ; CHECK: fdiv [[RES:s[0-9]+]], [[OP1]], [[OP2]]
45 ; CHECK: fcvt h0, [[RES]]
46   %0 = fdiv half %a, %b
47   ret half %0
48 }
49
50
51 define half @load_h(half* %a) {
52 entry:
53 ; CHECK-LABEL: load_h:
54 ; CHECK: ldr h0, [x0]
55   %0 = load half* %a, align 4
56   ret half %0
57 }
58
59
60 define void @store_h(half* %a, half %b) {
61 entry:
62 ; CHECK-LABEL: store_h:
63 ; CHECK: str h0, [x0]
64   store half %b, half* %a, align 4
65   ret void
66 }
67
68 define half @s_to_h(float %a) {
69 ; CHECK-LABEL: s_to_h:
70 ; CHECK: fcvt h0, s0
71   %1 = fptrunc float %a to half
72   ret half %1
73 }
74
75 define half @d_to_h(double %a) {
76 ; CHECK-LABEL: d_to_h:
77 ; CHECK: fcvt h0, d0
78   %1 = fptrunc double %a to half
79   ret half %1
80 }
81
82 define float @h_to_s(half %a) {
83 ; CHECK-LABEL: h_to_s:
84 ; CHECK: fcvt s0, h0
85   %1 = fpext half %a to float
86   ret float %1
87 }
88
89 define double @h_to_d(half %a) {
90 ; CHECK-LABEL: h_to_d:
91 ; CHECK: fcvt d0, h0
92   %1 = fpext half %a to double
93   ret double %1
94 }
95
96 define half @bitcast_i_to_h(i16 %a) {
97 ; CHECK-LABEL: bitcast_i_to_h:
98 ; CHECK: fmov s0, w0
99   %1 = bitcast i16 %a to half
100   ret half %1
101 }
102
103
104 define i16 @bitcast_h_to_i(half %a) {
105 ; CHECK-LABEL: bitcast_h_to_i:
106 ; CHECK: fmov w0, s0
107   %1 = bitcast half %a to i16
108   ret i16 %1
109 }