1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv32 -mattr=+zfh -verify-machineinstrs \
3 ; RUN: -target-abi ilp32f < %s | FileCheck %s
4 ; RUN: llc -mtriple=riscv64 -mattr=+zfh -verify-machineinstrs \
5 ; RUN: -target-abi lp64f < %s | FileCheck %s
6 ; RUN: llc -mtriple=riscv32 -mattr=+zhinx -verify-machineinstrs \
7 ; RUN: -target-abi ilp32 < %s \
8 ; RUN: | FileCheck -check-prefix=RV32IZHINX %s
9 ; RUN: llc -mtriple=riscv64 -mattr=+zhinx -verify-machineinstrs \
10 ; RUN: -target-abi lp64 < %s \
11 ; RUN: | FileCheck -check-prefix=RV64IZHINX %s
12 ; RUN: llc -mtriple=riscv32 -mattr=+zfhmin -verify-machineinstrs \
13 ; RUN: -target-abi ilp32f < %s | FileCheck -check-prefixes=CHECKIZFHMIN %s
14 ; RUN: llc -mtriple=riscv64 -mattr=+zfhmin -verify-machineinstrs \
15 ; RUN: -target-abi lp64f < %s | FileCheck -check-prefixes=CHECKIZFHMIN %s
16 ; RUN: llc -mtriple=riscv32 -mattr=+zhinxmin -verify-machineinstrs \
17 ; RUN: -target-abi ilp32 < %s \
18 ; RUN: | FileCheck -check-prefixes=CHECKIZHINXMIN %s
19 ; RUN: llc -mtriple=riscv64 -mattr=+zhinxmin -verify-machineinstrs \
20 ; RUN: -target-abi lp64 < %s \
21 ; RUN: | FileCheck -check-prefixes=CHECKIZHINXMIN %s
23 ; TODO: constant pool shouldn't be necessary for RV32IZfh and RV64IZfh
24 define half @half_imm() nounwind {
25 ; CHECK-LABEL: half_imm:
27 ; CHECK-NEXT: lui a0, %hi(.LCPI0_0)
28 ; CHECK-NEXT: flh fa0, %lo(.LCPI0_0)(a0)
31 ; RV32IZHINX-LABEL: half_imm:
32 ; RV32IZHINX: # %bb.0:
33 ; RV32IZHINX-NEXT: lui a0, %hi(.LCPI0_0)
34 ; RV32IZHINX-NEXT: lh a0, %lo(.LCPI0_0)(a0)
35 ; RV32IZHINX-NEXT: ret
37 ; RV64IZHINX-LABEL: half_imm:
38 ; RV64IZHINX: # %bb.0:
39 ; RV64IZHINX-NEXT: lui a0, %hi(.LCPI0_0)
40 ; RV64IZHINX-NEXT: lh a0, %lo(.LCPI0_0)(a0)
41 ; RV64IZHINX-NEXT: ret
43 ; CHECKIZFHMIN-LABEL: half_imm:
44 ; CHECKIZFHMIN: # %bb.0:
45 ; CHECKIZFHMIN-NEXT: lui a0, %hi(.LCPI0_0)
46 ; CHECKIZFHMIN-NEXT: flh fa0, %lo(.LCPI0_0)(a0)
47 ; CHECKIZFHMIN-NEXT: ret
49 ; CHECKIZHINXMIN-LABEL: half_imm:
50 ; CHECKIZHINXMIN: # %bb.0:
51 ; CHECKIZHINXMIN-NEXT: lui a0, %hi(.LCPI0_0)
52 ; CHECKIZHINXMIN-NEXT: lh a0, %lo(.LCPI0_0)(a0)
53 ; CHECKIZHINXMIN-NEXT: ret
57 define half @half_imm_op(half %a) nounwind {
58 ; CHECK-LABEL: half_imm_op:
60 ; CHECK-NEXT: lui a0, %hi(.LCPI1_0)
61 ; CHECK-NEXT: flh fa5, %lo(.LCPI1_0)(a0)
62 ; CHECK-NEXT: fadd.h fa0, fa0, fa5
65 ; RV32IZHINX-LABEL: half_imm_op:
66 ; RV32IZHINX: # %bb.0:
67 ; RV32IZHINX-NEXT: lui a1, %hi(.LCPI1_0)
68 ; RV32IZHINX-NEXT: lh a1, %lo(.LCPI1_0)(a1)
69 ; RV32IZHINX-NEXT: fadd.h a0, a0, a1
70 ; RV32IZHINX-NEXT: ret
72 ; RV64IZHINX-LABEL: half_imm_op:
73 ; RV64IZHINX: # %bb.0:
74 ; RV64IZHINX-NEXT: lui a1, %hi(.LCPI1_0)
75 ; RV64IZHINX-NEXT: lh a1, %lo(.LCPI1_0)(a1)
76 ; RV64IZHINX-NEXT: fadd.h a0, a0, a1
77 ; RV64IZHINX-NEXT: ret
79 ; CHECKIZFHMIN-LABEL: half_imm_op:
80 ; CHECKIZFHMIN: # %bb.0:
81 ; CHECKIZFHMIN-NEXT: fcvt.s.h fa5, fa0
82 ; CHECKIZFHMIN-NEXT: lui a0, 260096
83 ; CHECKIZFHMIN-NEXT: fmv.w.x fa4, a0
84 ; CHECKIZFHMIN-NEXT: fadd.s fa5, fa5, fa4
85 ; CHECKIZFHMIN-NEXT: fcvt.h.s fa0, fa5
86 ; CHECKIZFHMIN-NEXT: ret
88 ; CHECKIZHINXMIN-LABEL: half_imm_op:
89 ; CHECKIZHINXMIN: # %bb.0:
90 ; CHECKIZHINXMIN-NEXT: fcvt.s.h a0, a0
91 ; CHECKIZHINXMIN-NEXT: lui a1, 260096
92 ; CHECKIZHINXMIN-NEXT: fadd.s a0, a0, a1
93 ; CHECKIZHINXMIN-NEXT: fcvt.h.s a0, a0
94 ; CHECKIZHINXMIN-NEXT: ret
95 %1 = fadd half %a, 1.0
99 define half @half_positive_zero(ptr %pf) nounwind {
100 ; CHECK-LABEL: half_positive_zero:
102 ; CHECK-NEXT: fmv.h.x fa0, zero
105 ; RV32IZHINX-LABEL: half_positive_zero:
106 ; RV32IZHINX: # %bb.0:
107 ; RV32IZHINX-NEXT: li a0, 0
108 ; RV32IZHINX-NEXT: ret
110 ; RV64IZHINX-LABEL: half_positive_zero:
111 ; RV64IZHINX: # %bb.0:
112 ; RV64IZHINX-NEXT: li a0, 0
113 ; RV64IZHINX-NEXT: ret
115 ; CHECKIZFHMIN-LABEL: half_positive_zero:
116 ; CHECKIZFHMIN: # %bb.0:
117 ; CHECKIZFHMIN-NEXT: fmv.h.x fa0, zero
118 ; CHECKIZFHMIN-NEXT: ret
120 ; CHECKIZHINXMIN-LABEL: half_positive_zero:
121 ; CHECKIZHINXMIN: # %bb.0:
122 ; CHECKIZHINXMIN-NEXT: li a0, 0
123 ; CHECKIZHINXMIN-NEXT: ret
127 define half @half_negative_zero(ptr %pf) nounwind {
128 ; CHECK-LABEL: half_negative_zero:
130 ; CHECK-NEXT: lui a0, 1048568
131 ; CHECK-NEXT: fmv.h.x fa0, a0
134 ; RV32IZHINX-LABEL: half_negative_zero:
135 ; RV32IZHINX: # %bb.0:
136 ; RV32IZHINX-NEXT: lui a0, 1048568
137 ; RV32IZHINX-NEXT: ret
139 ; RV64IZHINX-LABEL: half_negative_zero:
140 ; RV64IZHINX: # %bb.0:
141 ; RV64IZHINX-NEXT: lui a0, 1048568
142 ; RV64IZHINX-NEXT: ret
144 ; CHECKIZFHMIN-LABEL: half_negative_zero:
145 ; CHECKIZFHMIN: # %bb.0:
146 ; CHECKIZFHMIN-NEXT: lui a0, 1048568
147 ; CHECKIZFHMIN-NEXT: fmv.h.x fa0, a0
148 ; CHECKIZFHMIN-NEXT: ret
150 ; CHECKIZHINXMIN-LABEL: half_negative_zero:
151 ; CHECKIZHINXMIN: # %bb.0:
152 ; CHECKIZHINXMIN-NEXT: lui a0, 1048568
153 ; CHECKIZHINXMIN-NEXT: ret