1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv32 -mattr=+d,+zfh,+zvfh,+v -target-abi=ilp32d \
3 ; RUN: -verify-machineinstrs < %s | FileCheck %s --check-prefixes=CHECK,ZVFH
4 ; RUN: llc -mtriple=riscv64 -mattr=+d,+zfh,+zvfh,+v -target-abi=lp64d \
5 ; RUN: -verify-machineinstrs < %s | FileCheck %s --check-prefixes=CHECK,ZVFH
6 ; RUN: llc -mtriple=riscv32 -mattr=+d,+zfh,+zvfhmin,+v -target-abi=ilp32d \
7 ; RUN: -verify-machineinstrs < %s | FileCheck %s --check-prefixes=CHECK,ZVFHMIN
8 ; RUN: llc -mtriple=riscv64 -mattr=+d,+zfh,+zvfhmin,+v -target-abi=lp64d \
9 ; RUN: -verify-machineinstrs < %s | FileCheck %s --check-prefixes=CHECK,ZVFHMIN
11 declare half @llvm.vp.reduce.fadd.v2f16(half, <2 x half>, <2 x i1>, i32)
13 define half @vpreduce_fadd_v2f16(half %s, <2 x half> %v, <2 x i1> %m, i32 zeroext %evl) {
14 ; ZVFH-LABEL: vpreduce_fadd_v2f16:
16 ; ZVFH-NEXT: vsetivli zero, 1, e16, mf4, ta, ma
17 ; ZVFH-NEXT: vfmv.s.f v9, fa0
18 ; ZVFH-NEXT: vsetvli zero, a0, e16, mf4, ta, ma
19 ; ZVFH-NEXT: vfredusum.vs v9, v8, v9, v0.t
20 ; ZVFH-NEXT: vfmv.f.s fa0, v9
23 ; ZVFHMIN-LABEL: vpreduce_fadd_v2f16:
25 ; ZVFHMIN-NEXT: vsetivli zero, 2, e16, mf4, ta, ma
26 ; ZVFHMIN-NEXT: vfwcvt.f.f.v v9, v8
27 ; ZVFHMIN-NEXT: fcvt.s.h fa5, fa0
28 ; ZVFHMIN-NEXT: vsetvli zero, zero, e32, mf2, ta, ma
29 ; ZVFHMIN-NEXT: vfmv.s.f v8, fa5
30 ; ZVFHMIN-NEXT: vsetvli zero, a0, e32, mf2, ta, ma
31 ; ZVFHMIN-NEXT: vfredusum.vs v8, v9, v8, v0.t
32 ; ZVFHMIN-NEXT: vfmv.f.s fa5, v8
33 ; ZVFHMIN-NEXT: fcvt.h.s fa0, fa5
35 %r = call reassoc half @llvm.vp.reduce.fadd.v2f16(half %s, <2 x half> %v, <2 x i1> %m, i32 %evl)
39 define half @vpreduce_ord_fadd_v2f16(half %s, <2 x half> %v, <2 x i1> %m, i32 zeroext %evl) {
40 ; ZVFH-LABEL: vpreduce_ord_fadd_v2f16:
42 ; ZVFH-NEXT: vsetivli zero, 1, e16, mf4, ta, ma
43 ; ZVFH-NEXT: vfmv.s.f v9, fa0
44 ; ZVFH-NEXT: vsetvli zero, a0, e16, mf4, ta, ma
45 ; ZVFH-NEXT: vfredosum.vs v9, v8, v9, v0.t
46 ; ZVFH-NEXT: vfmv.f.s fa0, v9
49 ; ZVFHMIN-LABEL: vpreduce_ord_fadd_v2f16:
51 ; ZVFHMIN-NEXT: vsetivli zero, 2, e16, mf4, ta, ma
52 ; ZVFHMIN-NEXT: vfwcvt.f.f.v v9, v8
53 ; ZVFHMIN-NEXT: fcvt.s.h fa5, fa0
54 ; ZVFHMIN-NEXT: vsetvli zero, zero, e32, mf2, ta, ma
55 ; ZVFHMIN-NEXT: vfmv.s.f v8, fa5
56 ; ZVFHMIN-NEXT: vsetvli zero, a0, e32, mf2, ta, ma
57 ; ZVFHMIN-NEXT: vfredosum.vs v8, v9, v8, v0.t
58 ; ZVFHMIN-NEXT: vfmv.f.s fa5, v8
59 ; ZVFHMIN-NEXT: fcvt.h.s fa0, fa5
61 %r = call half @llvm.vp.reduce.fadd.v2f16(half %s, <2 x half> %v, <2 x i1> %m, i32 %evl)
65 declare half @llvm.vp.reduce.fadd.v4f16(half, <4 x half>, <4 x i1>, i32)
67 define half @vpreduce_fadd_v4f16(half %s, <4 x half> %v, <4 x i1> %m, i32 zeroext %evl) {
68 ; ZVFH-LABEL: vpreduce_fadd_v4f16:
70 ; ZVFH-NEXT: vsetivli zero, 1, e16, mf2, ta, ma
71 ; ZVFH-NEXT: vfmv.s.f v9, fa0
72 ; ZVFH-NEXT: vsetvli zero, a0, e16, mf2, ta, ma
73 ; ZVFH-NEXT: vfredusum.vs v9, v8, v9, v0.t
74 ; ZVFH-NEXT: vfmv.f.s fa0, v9
77 ; ZVFHMIN-LABEL: vpreduce_fadd_v4f16:
79 ; ZVFHMIN-NEXT: vsetivli zero, 4, e16, mf2, ta, ma
80 ; ZVFHMIN-NEXT: vfwcvt.f.f.v v9, v8
81 ; ZVFHMIN-NEXT: fcvt.s.h fa5, fa0
82 ; ZVFHMIN-NEXT: vsetvli zero, zero, e32, m1, ta, ma
83 ; ZVFHMIN-NEXT: vfmv.s.f v8, fa5
84 ; ZVFHMIN-NEXT: vsetvli zero, a0, e32, m1, ta, ma
85 ; ZVFHMIN-NEXT: vfredusum.vs v8, v9, v8, v0.t
86 ; ZVFHMIN-NEXT: vfmv.f.s fa5, v8
87 ; ZVFHMIN-NEXT: fcvt.h.s fa0, fa5
89 %r = call reassoc half @llvm.vp.reduce.fadd.v4f16(half %s, <4 x half> %v, <4 x i1> %m, i32 %evl)
93 define half @vpreduce_ord_fadd_v4f16(half %s, <4 x half> %v, <4 x i1> %m, i32 zeroext %evl) {
94 ; ZVFH-LABEL: vpreduce_ord_fadd_v4f16:
96 ; ZVFH-NEXT: vsetivli zero, 1, e16, mf2, ta, ma
97 ; ZVFH-NEXT: vfmv.s.f v9, fa0
98 ; ZVFH-NEXT: vsetvli zero, a0, e16, mf2, ta, ma
99 ; ZVFH-NEXT: vfredosum.vs v9, v8, v9, v0.t
100 ; ZVFH-NEXT: vfmv.f.s fa0, v9
103 ; ZVFHMIN-LABEL: vpreduce_ord_fadd_v4f16:
105 ; ZVFHMIN-NEXT: vsetivli zero, 4, e16, mf2, ta, ma
106 ; ZVFHMIN-NEXT: vfwcvt.f.f.v v9, v8
107 ; ZVFHMIN-NEXT: fcvt.s.h fa5, fa0
108 ; ZVFHMIN-NEXT: vsetvli zero, zero, e32, m1, ta, ma
109 ; ZVFHMIN-NEXT: vfmv.s.f v8, fa5
110 ; ZVFHMIN-NEXT: vsetvli zero, a0, e32, m1, ta, ma
111 ; ZVFHMIN-NEXT: vfredosum.vs v8, v9, v8, v0.t
112 ; ZVFHMIN-NEXT: vfmv.f.s fa5, v8
113 ; ZVFHMIN-NEXT: fcvt.h.s fa0, fa5
115 %r = call half @llvm.vp.reduce.fadd.v4f16(half %s, <4 x half> %v, <4 x i1> %m, i32 %evl)
119 declare float @llvm.vp.reduce.fadd.v2f32(float, <2 x float>, <2 x i1>, i32)
121 define float @vpreduce_fadd_v2f32(float %s, <2 x float> %v, <2 x i1> %m, i32 zeroext %evl) {
122 ; CHECK-LABEL: vpreduce_fadd_v2f32:
124 ; CHECK-NEXT: vsetivli zero, 1, e32, mf2, ta, ma
125 ; CHECK-NEXT: vfmv.s.f v9, fa0
126 ; CHECK-NEXT: vsetvli zero, a0, e32, mf2, ta, ma
127 ; CHECK-NEXT: vfredusum.vs v9, v8, v9, v0.t
128 ; CHECK-NEXT: vfmv.f.s fa0, v9
130 %r = call reassoc float @llvm.vp.reduce.fadd.v2f32(float %s, <2 x float> %v, <2 x i1> %m, i32 %evl)
134 define float @vpreduce_ord_fadd_v2f32(float %s, <2 x float> %v, <2 x i1> %m, i32 zeroext %evl) {
135 ; CHECK-LABEL: vpreduce_ord_fadd_v2f32:
137 ; CHECK-NEXT: vsetivli zero, 1, e32, mf2, ta, ma
138 ; CHECK-NEXT: vfmv.s.f v9, fa0
139 ; CHECK-NEXT: vsetvli zero, a0, e32, mf2, ta, ma
140 ; CHECK-NEXT: vfredosum.vs v9, v8, v9, v0.t
141 ; CHECK-NEXT: vfmv.f.s fa0, v9
143 %r = call float @llvm.vp.reduce.fadd.v2f32(float %s, <2 x float> %v, <2 x i1> %m, i32 %evl)
147 declare float @llvm.vp.reduce.fadd.v4f32(float, <4 x float>, <4 x i1>, i32)
149 define float @vpreduce_fadd_v4f32(float %s, <4 x float> %v, <4 x i1> %m, i32 zeroext %evl) {
150 ; CHECK-LABEL: vpreduce_fadd_v4f32:
152 ; CHECK-NEXT: vsetivli zero, 1, e32, m1, ta, ma
153 ; CHECK-NEXT: vfmv.s.f v9, fa0
154 ; CHECK-NEXT: vsetvli zero, a0, e32, m1, ta, ma
155 ; CHECK-NEXT: vfredusum.vs v9, v8, v9, v0.t
156 ; CHECK-NEXT: vfmv.f.s fa0, v9
158 %r = call reassoc float @llvm.vp.reduce.fadd.v4f32(float %s, <4 x float> %v, <4 x i1> %m, i32 %evl)
162 define float @vpreduce_ord_fadd_v4f32(float %s, <4 x float> %v, <4 x i1> %m, i32 zeroext %evl) {
163 ; CHECK-LABEL: vpreduce_ord_fadd_v4f32:
165 ; CHECK-NEXT: vsetivli zero, 1, e32, m1, ta, ma
166 ; CHECK-NEXT: vfmv.s.f v9, fa0
167 ; CHECK-NEXT: vsetvli zero, a0, e32, m1, ta, ma
168 ; CHECK-NEXT: vfredosum.vs v9, v8, v9, v0.t
169 ; CHECK-NEXT: vfmv.f.s fa0, v9
171 %r = call float @llvm.vp.reduce.fadd.v4f32(float %s, <4 x float> %v, <4 x i1> %m, i32 %evl)
175 declare float @llvm.vp.reduce.fadd.v64f32(float, <64 x float>, <64 x i1>, i32)
177 define float @vpreduce_fadd_v64f32(float %s, <64 x float> %v, <64 x i1> %m, i32 zeroext %evl) {
178 ; CHECK-LABEL: vpreduce_fadd_v64f32:
180 ; CHECK-NEXT: li a2, 32
181 ; CHECK-NEXT: vsetivli zero, 4, e8, mf2, ta, ma
182 ; CHECK-NEXT: vslidedown.vi v24, v0, 4
183 ; CHECK-NEXT: mv a1, a0
184 ; CHECK-NEXT: bltu a0, a2, .LBB8_2
185 ; CHECK-NEXT: # %bb.1:
186 ; CHECK-NEXT: li a1, 32
187 ; CHECK-NEXT: .LBB8_2:
188 ; CHECK-NEXT: vsetvli zero, zero, e32, m2, ta, ma
189 ; CHECK-NEXT: vfmv.s.f v25, fa0
190 ; CHECK-NEXT: vsetvli zero, a1, e32, m8, ta, ma
191 ; CHECK-NEXT: vfredusum.vs v25, v8, v25, v0.t
192 ; CHECK-NEXT: addi a1, a0, -32
193 ; CHECK-NEXT: sltu a0, a0, a1
194 ; CHECK-NEXT: addi a0, a0, -1
195 ; CHECK-NEXT: and a0, a0, a1
196 ; CHECK-NEXT: vmv1r.v v0, v24
197 ; CHECK-NEXT: vsetvli zero, a0, e32, m8, ta, ma
198 ; CHECK-NEXT: vfredusum.vs v25, v16, v25, v0.t
199 ; CHECK-NEXT: vfmv.f.s fa0, v25
201 %r = call reassoc float @llvm.vp.reduce.fadd.v64f32(float %s, <64 x float> %v, <64 x i1> %m, i32 %evl)
205 define float @vpreduce_ord_fadd_v64f32(float %s, <64 x float> %v, <64 x i1> %m, i32 zeroext %evl) {
206 ; CHECK-LABEL: vpreduce_ord_fadd_v64f32:
208 ; CHECK-NEXT: li a2, 32
209 ; CHECK-NEXT: vsetivli zero, 4, e8, mf2, ta, ma
210 ; CHECK-NEXT: vslidedown.vi v24, v0, 4
211 ; CHECK-NEXT: mv a1, a0
212 ; CHECK-NEXT: bltu a0, a2, .LBB9_2
213 ; CHECK-NEXT: # %bb.1:
214 ; CHECK-NEXT: li a1, 32
215 ; CHECK-NEXT: .LBB9_2:
216 ; CHECK-NEXT: vsetvli zero, zero, e32, m2, ta, ma
217 ; CHECK-NEXT: vfmv.s.f v25, fa0
218 ; CHECK-NEXT: vsetvli zero, a1, e32, m8, ta, ma
219 ; CHECK-NEXT: vfredosum.vs v25, v8, v25, v0.t
220 ; CHECK-NEXT: addi a1, a0, -32
221 ; CHECK-NEXT: sltu a0, a0, a1
222 ; CHECK-NEXT: addi a0, a0, -1
223 ; CHECK-NEXT: and a0, a0, a1
224 ; CHECK-NEXT: vmv1r.v v0, v24
225 ; CHECK-NEXT: vsetvli zero, a0, e32, m8, ta, ma
226 ; CHECK-NEXT: vfredosum.vs v25, v16, v25, v0.t
227 ; CHECK-NEXT: vfmv.f.s fa0, v25
229 %r = call float @llvm.vp.reduce.fadd.v64f32(float %s, <64 x float> %v, <64 x i1> %m, i32 %evl)
233 declare double @llvm.vp.reduce.fadd.v2f64(double, <2 x double>, <2 x i1>, i32)
235 define double @vpreduce_fadd_v2f64(double %s, <2 x double> %v, <2 x i1> %m, i32 zeroext %evl) {
236 ; CHECK-LABEL: vpreduce_fadd_v2f64:
238 ; CHECK-NEXT: vsetivli zero, 1, e64, m1, ta, ma
239 ; CHECK-NEXT: vfmv.s.f v9, fa0
240 ; CHECK-NEXT: vsetvli zero, a0, e64, m1, ta, ma
241 ; CHECK-NEXT: vfredusum.vs v9, v8, v9, v0.t
242 ; CHECK-NEXT: vfmv.f.s fa0, v9
244 %r = call reassoc double @llvm.vp.reduce.fadd.v2f64(double %s, <2 x double> %v, <2 x i1> %m, i32 %evl)
248 define double @vpreduce_ord_fadd_v2f64(double %s, <2 x double> %v, <2 x i1> %m, i32 zeroext %evl) {
249 ; CHECK-LABEL: vpreduce_ord_fadd_v2f64:
251 ; CHECK-NEXT: vsetivli zero, 1, e64, m1, ta, ma
252 ; CHECK-NEXT: vfmv.s.f v9, fa0
253 ; CHECK-NEXT: vsetvli zero, a0, e64, m1, ta, ma
254 ; CHECK-NEXT: vfredosum.vs v9, v8, v9, v0.t
255 ; CHECK-NEXT: vfmv.f.s fa0, v9
257 %r = call double @llvm.vp.reduce.fadd.v2f64(double %s, <2 x double> %v, <2 x i1> %m, i32 %evl)
261 declare double @llvm.vp.reduce.fadd.v3f64(double, <3 x double>, <3 x i1>, i32)
263 define double @vpreduce_fadd_v3f64(double %s, <3 x double> %v, <3 x i1> %m, i32 zeroext %evl) {
264 ; CHECK-LABEL: vpreduce_fadd_v3f64:
266 ; CHECK-NEXT: vsetivli zero, 1, e64, m1, ta, ma
267 ; CHECK-NEXT: vfmv.s.f v10, fa0
268 ; CHECK-NEXT: vsetvli zero, a0, e64, m2, ta, ma
269 ; CHECK-NEXT: vfredusum.vs v10, v8, v10, v0.t
270 ; CHECK-NEXT: vfmv.f.s fa0, v10
272 %r = call reassoc double @llvm.vp.reduce.fadd.v3f64(double %s, <3 x double> %v, <3 x i1> %m, i32 %evl)
276 define double @vpreduce_ord_fadd_v3f64(double %s, <3 x double> %v, <3 x i1> %m, i32 zeroext %evl) {
277 ; CHECK-LABEL: vpreduce_ord_fadd_v3f64:
279 ; CHECK-NEXT: vsetivli zero, 1, e64, m1, ta, ma
280 ; CHECK-NEXT: vfmv.s.f v10, fa0
281 ; CHECK-NEXT: vsetvli zero, a0, e64, m2, ta, ma
282 ; CHECK-NEXT: vfredosum.vs v10, v8, v10, v0.t
283 ; CHECK-NEXT: vfmv.f.s fa0, v10
285 %r = call double @llvm.vp.reduce.fadd.v3f64(double %s, <3 x double> %v, <3 x i1> %m, i32 %evl)
289 declare double @llvm.vp.reduce.fadd.v4f64(double, <4 x double>, <4 x i1>, i32)
291 define double @vpreduce_fadd_v4f64(double %s, <4 x double> %v, <4 x i1> %m, i32 zeroext %evl) {
292 ; CHECK-LABEL: vpreduce_fadd_v4f64:
294 ; CHECK-NEXT: vsetivli zero, 1, e64, m1, ta, ma
295 ; CHECK-NEXT: vfmv.s.f v10, fa0
296 ; CHECK-NEXT: vsetvli zero, a0, e64, m2, ta, ma
297 ; CHECK-NEXT: vfredusum.vs v10, v8, v10, v0.t
298 ; CHECK-NEXT: vfmv.f.s fa0, v10
300 %r = call reassoc double @llvm.vp.reduce.fadd.v4f64(double %s, <4 x double> %v, <4 x i1> %m, i32 %evl)
304 define double @vpreduce_ord_fadd_v4f64(double %s, <4 x double> %v, <4 x i1> %m, i32 zeroext %evl) {
305 ; CHECK-LABEL: vpreduce_ord_fadd_v4f64:
307 ; CHECK-NEXT: vsetivli zero, 1, e64, m1, ta, ma
308 ; CHECK-NEXT: vfmv.s.f v10, fa0
309 ; CHECK-NEXT: vsetvli zero, a0, e64, m2, ta, ma
310 ; CHECK-NEXT: vfredosum.vs v10, v8, v10, v0.t
311 ; CHECK-NEXT: vfmv.f.s fa0, v10
313 %r = call double @llvm.vp.reduce.fadd.v4f64(double %s, <4 x double> %v, <4 x i1> %m, i32 %evl)