1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: sed 's/iXLen/i32/g' %s | llc -mtriple=riscv32 -mattr=+zfh \
3 ; RUN: -verify-machineinstrs -target-abi ilp32f | \
4 ; RUN: FileCheck -check-prefixes=CHECKIZFH %s
5 ; RUN: sed 's/iXLen/i64/g' %s | llc -mtriple=riscv64 -mattr=+zfh \
6 ; RUN: -verify-machineinstrs -target-abi lp64f | \
7 ; RUN: FileCheck -check-prefixes=CHECKIZFH %s
8 ; RUN: sed 's/iXLen/i32/g' %s | llc -mtriple=riscv32 -mattr=+zhinx \
9 ; RUN: -verify-machineinstrs -target-abi ilp32 | \
10 ; RUN: FileCheck -check-prefixes=CHECKIZHINX %s
11 ; RUN: sed 's/iXLen/i64/g' %s | llc -mtriple=riscv64 -mattr=+zhinx \
12 ; RUN: -verify-machineinstrs -target-abi lp64 | \
13 ; RUN: FileCheck -check-prefixes=CHECKIZHINX %s
15 declare half @llvm.minimum.f16(half, half)
17 define half @fminimum_f16(half %a, half %b) nounwind {
18 ; CHECKIZFH-LABEL: fminimum_f16:
20 ; CHECKIZFH-NEXT: feq.h a0, fa0, fa0
21 ; CHECKIZFH-NEXT: fmv.h fa5, fa1
22 ; CHECKIZFH-NEXT: beqz a0, .LBB0_3
23 ; CHECKIZFH-NEXT: # %bb.1:
24 ; CHECKIZFH-NEXT: feq.h a0, fa1, fa1
25 ; CHECKIZFH-NEXT: beqz a0, .LBB0_4
26 ; CHECKIZFH-NEXT: .LBB0_2:
27 ; CHECKIZFH-NEXT: fmin.h fa0, fa0, fa5
29 ; CHECKIZFH-NEXT: .LBB0_3:
30 ; CHECKIZFH-NEXT: fmv.h fa5, fa0
31 ; CHECKIZFH-NEXT: feq.h a0, fa1, fa1
32 ; CHECKIZFH-NEXT: bnez a0, .LBB0_2
33 ; CHECKIZFH-NEXT: .LBB0_4:
34 ; CHECKIZFH-NEXT: fmin.h fa0, fa1, fa5
37 ; CHECKIZHINX-LABEL: fminimum_f16:
38 ; CHECKIZHINX: # %bb.0:
39 ; CHECKIZHINX-NEXT: feq.h a3, a0, a0
40 ; CHECKIZHINX-NEXT: mv a2, a1
41 ; CHECKIZHINX-NEXT: beqz a3, .LBB0_3
42 ; CHECKIZHINX-NEXT: # %bb.1:
43 ; CHECKIZHINX-NEXT: feq.h a3, a1, a1
44 ; CHECKIZHINX-NEXT: beqz a3, .LBB0_4
45 ; CHECKIZHINX-NEXT: .LBB0_2:
46 ; CHECKIZHINX-NEXT: fmin.h a0, a0, a2
47 ; CHECKIZHINX-NEXT: ret
48 ; CHECKIZHINX-NEXT: .LBB0_3:
49 ; CHECKIZHINX-NEXT: mv a2, a0
50 ; CHECKIZHINX-NEXT: feq.h a3, a1, a1
51 ; CHECKIZHINX-NEXT: bnez a3, .LBB0_2
52 ; CHECKIZHINX-NEXT: .LBB0_4:
53 ; CHECKIZHINX-NEXT: fmin.h a0, a1, a2
54 ; CHECKIZHINX-NEXT: ret
55 %1 = call half @llvm.minimum.f16(half %a, half %b)
59 declare half @llvm.maximum.f16(half, half)
61 define half @fmaximum_f16(half %a, half %b) nounwind {
62 ; CHECKIZFH-LABEL: fmaximum_f16:
64 ; CHECKIZFH-NEXT: feq.h a0, fa0, fa0
65 ; CHECKIZFH-NEXT: fmv.h fa5, fa1
66 ; CHECKIZFH-NEXT: beqz a0, .LBB1_3
67 ; CHECKIZFH-NEXT: # %bb.1:
68 ; CHECKIZFH-NEXT: feq.h a0, fa1, fa1
69 ; CHECKIZFH-NEXT: beqz a0, .LBB1_4
70 ; CHECKIZFH-NEXT: .LBB1_2:
71 ; CHECKIZFH-NEXT: fmax.h fa0, fa0, fa5
73 ; CHECKIZFH-NEXT: .LBB1_3:
74 ; CHECKIZFH-NEXT: fmv.h fa5, fa0
75 ; CHECKIZFH-NEXT: feq.h a0, fa1, fa1
76 ; CHECKIZFH-NEXT: bnez a0, .LBB1_2
77 ; CHECKIZFH-NEXT: .LBB1_4:
78 ; CHECKIZFH-NEXT: fmax.h fa0, fa1, fa5
81 ; CHECKIZHINX-LABEL: fmaximum_f16:
82 ; CHECKIZHINX: # %bb.0:
83 ; CHECKIZHINX-NEXT: feq.h a3, a0, a0
84 ; CHECKIZHINX-NEXT: mv a2, a1
85 ; CHECKIZHINX-NEXT: beqz a3, .LBB1_3
86 ; CHECKIZHINX-NEXT: # %bb.1:
87 ; CHECKIZHINX-NEXT: feq.h a3, a1, a1
88 ; CHECKIZHINX-NEXT: beqz a3, .LBB1_4
89 ; CHECKIZHINX-NEXT: .LBB1_2:
90 ; CHECKIZHINX-NEXT: fmax.h a0, a0, a2
91 ; CHECKIZHINX-NEXT: ret
92 ; CHECKIZHINX-NEXT: .LBB1_3:
93 ; CHECKIZHINX-NEXT: mv a2, a0
94 ; CHECKIZHINX-NEXT: feq.h a3, a1, a1
95 ; CHECKIZHINX-NEXT: bnez a3, .LBB1_2
96 ; CHECKIZHINX-NEXT: .LBB1_4:
97 ; CHECKIZHINX-NEXT: fmax.h a0, a1, a2
98 ; CHECKIZHINX-NEXT: ret
99 %1 = call half @llvm.maximum.f16(half %a, half %b)
103 define half @fminimum_nnan_f16(half %a, half %b) nounwind {
104 ; CHECKIZFH-LABEL: fminimum_nnan_f16:
105 ; CHECKIZFH: # %bb.0:
106 ; CHECKIZFH-NEXT: fmin.h fa0, fa0, fa1
107 ; CHECKIZFH-NEXT: ret
109 ; CHECKIZHINX-LABEL: fminimum_nnan_f16:
110 ; CHECKIZHINX: # %bb.0:
111 ; CHECKIZHINX-NEXT: fmin.h a0, a0, a1
112 ; CHECKIZHINX-NEXT: ret
113 %1 = call nnan half @llvm.minimum.f16(half %a, half %b)
117 define half @fmaximum_nnan_f16(half %a, half %b) nounwind {
118 ; CHECKIZFH-LABEL: fmaximum_nnan_f16:
119 ; CHECKIZFH: # %bb.0:
120 ; CHECKIZFH-NEXT: fmax.h fa0, fa0, fa1
121 ; CHECKIZFH-NEXT: ret
123 ; CHECKIZHINX-LABEL: fmaximum_nnan_f16:
124 ; CHECKIZHINX: # %bb.0:
125 ; CHECKIZHINX-NEXT: fmax.h a0, a0, a1
126 ; CHECKIZHINX-NEXT: ret
127 %1 = call nnan half @llvm.maximum.f16(half %a, half %b)
131 define half @fminimum_nnan_attr_f16(half %a, half %b) nounwind "no-nans-fp-math"="true" {
132 ; CHECKIZFH-LABEL: fminimum_nnan_attr_f16:
133 ; CHECKIZFH: # %bb.0:
134 ; CHECKIZFH-NEXT: fmin.h fa0, fa0, fa1
135 ; CHECKIZFH-NEXT: ret
137 ; CHECKIZHINX-LABEL: fminimum_nnan_attr_f16:
138 ; CHECKIZHINX: # %bb.0:
139 ; CHECKIZHINX-NEXT: fmin.h a0, a0, a1
140 ; CHECKIZHINX-NEXT: ret
141 %1 = call half @llvm.minimum.f16(half %a, half %b)
145 define half @fminimum_nnan_op_f16(half %a, half %b) nounwind {
146 ; CHECKIZFH-LABEL: fminimum_nnan_op_f16:
147 ; CHECKIZFH: # %bb.0:
148 ; CHECKIZFH-NEXT: feq.h a0, fa0, fa0
149 ; CHECKIZFH-NEXT: bnez a0, .LBB5_2
150 ; CHECKIZFH-NEXT: # %bb.1:
151 ; CHECKIZFH-NEXT: fmin.h fa0, fa0, fa0
152 ; CHECKIZFH-NEXT: ret
153 ; CHECKIZFH-NEXT: .LBB5_2:
154 ; CHECKIZFH-NEXT: fadd.h fa5, fa0, fa0
155 ; CHECKIZFH-NEXT: fmin.h fa0, fa0, fa5
156 ; CHECKIZFH-NEXT: ret
158 ; CHECKIZHINX-LABEL: fminimum_nnan_op_f16:
159 ; CHECKIZHINX: # %bb.0:
160 ; CHECKIZHINX-NEXT: feq.h a1, a0, a0
161 ; CHECKIZHINX-NEXT: bnez a1, .LBB5_2
162 ; CHECKIZHINX-NEXT: # %bb.1:
163 ; CHECKIZHINX-NEXT: fmin.h a0, a0, a0
164 ; CHECKIZHINX-NEXT: ret
165 ; CHECKIZHINX-NEXT: .LBB5_2:
166 ; CHECKIZHINX-NEXT: fadd.h a1, a0, a0
167 ; CHECKIZHINX-NEXT: fmin.h a0, a0, a1
168 ; CHECKIZHINX-NEXT: ret
169 %c = fadd nnan half %a, %a
170 %1 = call half @llvm.minimum.f16(half %a, half %c)
174 define half @fmaximum_nnan_op_f16(half %a, half %b) nounwind {
175 ; CHECKIZFH-LABEL: fmaximum_nnan_op_f16:
176 ; CHECKIZFH: # %bb.0:
177 ; CHECKIZFH-NEXT: fadd.h fa5, fa0, fa1
178 ; CHECKIZFH-NEXT: fsub.h fa4, fa0, fa1
179 ; CHECKIZFH-NEXT: fmax.h fa0, fa5, fa4
180 ; CHECKIZFH-NEXT: ret
182 ; CHECKIZHINX-LABEL: fmaximum_nnan_op_f16:
183 ; CHECKIZHINX: # %bb.0:
184 ; CHECKIZHINX-NEXT: fadd.h a2, a0, a1
185 ; CHECKIZHINX-NEXT: fsub.h a0, a0, a1
186 ; CHECKIZHINX-NEXT: fmax.h a0, a2, a0
187 ; CHECKIZHINX-NEXT: ret
188 %c = fadd nnan half %a, %b
189 %d = fsub nnan half %a, %b
190 %1 = call half @llvm.maximum.f16(half %c, half %d)