1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 4
2 ; RUN: llc -mtriple=riscv64 -mattr=+v -verify-machineinstrs -target-abi=lp64d < %s | FileCheck %s
3 ; RUN: llc -mtriple=riscv64 -mattr=+v -verify-machineinstrs -target-abi=lp64d \
4 ; RUN: -riscv-disable-frm-insert-opt < %s | FileCheck %s --check-prefix=UNOPT
6 declare <vscale x 1 x float> @llvm.riscv.vfadd.nxv1f32.nxv1f32(
12 ; Test only save/restore frm once.
13 define <vscale x 1 x float> @test(<vscale x 1 x float> %0, <vscale x 1 x float> %1, i64 %2) nounwind {
15 ; CHECK: # %bb.0: # %entry
16 ; CHECK-NEXT: fsrmi a1, 0
17 ; CHECK-NEXT: vsetvli zero, a0, e32, mf2, ta, ma
18 ; CHECK-NEXT: vfadd.vv v8, v8, v9
19 ; CHECK-NEXT: vfadd.vv v8, v8, v8
24 ; UNOPT: # %bb.0: # %entry
25 ; UNOPT-NEXT: fsrmi a1, 0
26 ; UNOPT-NEXT: vsetvli zero, a0, e32, mf2, ta, ma
27 ; UNOPT-NEXT: vfadd.vv v8, v8, v9
29 ; UNOPT-NEXT: fsrmi a0, 0
30 ; UNOPT-NEXT: vfadd.vv v8, v8, v8
34 %a = call <vscale x 1 x float> @llvm.riscv.vfadd.nxv1f32.nxv1f32(
35 <vscale x 1 x float> undef,
36 <vscale x 1 x float> %0,
37 <vscale x 1 x float> %1,
39 %b = call <vscale x 1 x float> @llvm.riscv.vfadd.nxv1f32.nxv1f32(
40 <vscale x 1 x float> undef,
41 <vscale x 1 x float> %a,
42 <vscale x 1 x float> %a,
44 ret <vscale x 1 x float> %b
47 ; Test only restore frm once.
48 define <vscale x 1 x float> @test2(<vscale x 1 x float> %0, <vscale x 1 x float> %1, i64 %2) nounwind {
50 ; CHECK: # %bb.0: # %entry
51 ; CHECK-NEXT: fsrmi a1, 0
52 ; CHECK-NEXT: vsetvli zero, a0, e32, mf2, ta, ma
53 ; CHECK-NEXT: vfadd.vv v8, v8, v9
55 ; CHECK-NEXT: vfadd.vv v8, v8, v8
60 ; UNOPT: # %bb.0: # %entry
61 ; UNOPT-NEXT: fsrmi a1, 0
62 ; UNOPT-NEXT: vsetvli zero, a0, e32, mf2, ta, ma
63 ; UNOPT-NEXT: vfadd.vv v8, v8, v9
65 ; UNOPT-NEXT: fsrmi a0, 1
66 ; UNOPT-NEXT: vfadd.vv v8, v8, v8
70 %a = call <vscale x 1 x float> @llvm.riscv.vfadd.nxv1f32.nxv1f32(
71 <vscale x 1 x float> undef,
72 <vscale x 1 x float> %0,
73 <vscale x 1 x float> %1,
75 %b = call <vscale x 1 x float> @llvm.riscv.vfadd.nxv1f32.nxv1f32(
76 <vscale x 1 x float> undef,
77 <vscale x 1 x float> %a,
78 <vscale x 1 x float> %a,
80 ret <vscale x 1 x float> %b
84 define <vscale x 1 x float> @just_call(<vscale x 1 x float> %0) nounwind {
85 ; CHECK-LABEL: just_call:
86 ; CHECK: # %bb.0: # %entry
87 ; CHECK-NEXT: addi sp, sp, -48
88 ; CHECK-NEXT: sd ra, 40(sp) # 8-byte Folded Spill
89 ; CHECK-NEXT: csrr a0, vlenb
90 ; CHECK-NEXT: slli a0, a0, 1
91 ; CHECK-NEXT: sub sp, sp, a0
92 ; CHECK-NEXT: addi a0, sp, 32
93 ; CHECK-NEXT: vs1r.v v8, (a0) # Unknown-size Folded Spill
94 ; CHECK-NEXT: call foo
95 ; CHECK-NEXT: addi a0, sp, 32
96 ; CHECK-NEXT: vl1r.v v8, (a0) # Unknown-size Folded Reload
97 ; CHECK-NEXT: csrr a0, vlenb
98 ; CHECK-NEXT: slli a0, a0, 1
99 ; CHECK-NEXT: add sp, sp, a0
100 ; CHECK-NEXT: ld ra, 40(sp) # 8-byte Folded Reload
101 ; CHECK-NEXT: addi sp, sp, 48
104 ; UNOPT-LABEL: just_call:
105 ; UNOPT: # %bb.0: # %entry
106 ; UNOPT-NEXT: addi sp, sp, -48
107 ; UNOPT-NEXT: sd ra, 40(sp) # 8-byte Folded Spill
108 ; UNOPT-NEXT: csrr a0, vlenb
109 ; UNOPT-NEXT: slli a0, a0, 1
110 ; UNOPT-NEXT: sub sp, sp, a0
111 ; UNOPT-NEXT: addi a0, sp, 32
112 ; UNOPT-NEXT: vs1r.v v8, (a0) # Unknown-size Folded Spill
113 ; UNOPT-NEXT: call foo
114 ; UNOPT-NEXT: addi a0, sp, 32
115 ; UNOPT-NEXT: vl1r.v v8, (a0) # Unknown-size Folded Reload
116 ; UNOPT-NEXT: csrr a0, vlenb
117 ; UNOPT-NEXT: slli a0, a0, 1
118 ; UNOPT-NEXT: add sp, sp, a0
119 ; UNOPT-NEXT: ld ra, 40(sp) # 8-byte Folded Reload
120 ; UNOPT-NEXT: addi sp, sp, 48
124 ret <vscale x 1 x float> %0
127 define <vscale x 1 x float> @before_call1(<vscale x 1 x float> %0, <vscale x 1 x float> %1, i64 %2) nounwind {
128 ; CHECK-LABEL: before_call1:
129 ; CHECK: # %bb.0: # %entry
130 ; CHECK-NEXT: addi sp, sp, -48
131 ; CHECK-NEXT: sd ra, 40(sp) # 8-byte Folded Spill
132 ; CHECK-NEXT: csrr a1, vlenb
133 ; CHECK-NEXT: slli a1, a1, 1
134 ; CHECK-NEXT: sub sp, sp, a1
135 ; CHECK-NEXT: fsrmi a1, 0
136 ; CHECK-NEXT: vsetvli zero, a0, e32, mf2, ta, ma
137 ; CHECK-NEXT: vfadd.vv v8, v8, v9
138 ; CHECK-NEXT: addi a0, sp, 32
139 ; CHECK-NEXT: vs1r.v v8, (a0) # Unknown-size Folded Spill
140 ; CHECK-NEXT: fsrm a1
141 ; CHECK-NEXT: call foo
142 ; CHECK-NEXT: addi a0, sp, 32
143 ; CHECK-NEXT: vl1r.v v8, (a0) # Unknown-size Folded Reload
144 ; CHECK-NEXT: csrr a0, vlenb
145 ; CHECK-NEXT: slli a0, a0, 1
146 ; CHECK-NEXT: add sp, sp, a0
147 ; CHECK-NEXT: ld ra, 40(sp) # 8-byte Folded Reload
148 ; CHECK-NEXT: addi sp, sp, 48
151 ; UNOPT-LABEL: before_call1:
152 ; UNOPT: # %bb.0: # %entry
153 ; UNOPT-NEXT: addi sp, sp, -48
154 ; UNOPT-NEXT: sd ra, 40(sp) # 8-byte Folded Spill
155 ; UNOPT-NEXT: csrr a1, vlenb
156 ; UNOPT-NEXT: slli a1, a1, 1
157 ; UNOPT-NEXT: sub sp, sp, a1
158 ; UNOPT-NEXT: fsrmi a1, 0
159 ; UNOPT-NEXT: vsetvli zero, a0, e32, mf2, ta, ma
160 ; UNOPT-NEXT: vfadd.vv v8, v8, v9
161 ; UNOPT-NEXT: addi a0, sp, 32
162 ; UNOPT-NEXT: vs1r.v v8, (a0) # Unknown-size Folded Spill
163 ; UNOPT-NEXT: fsrm a1
164 ; UNOPT-NEXT: call foo
165 ; UNOPT-NEXT: addi a0, sp, 32
166 ; UNOPT-NEXT: vl1r.v v8, (a0) # Unknown-size Folded Reload
167 ; UNOPT-NEXT: csrr a0, vlenb
168 ; UNOPT-NEXT: slli a0, a0, 1
169 ; UNOPT-NEXT: add sp, sp, a0
170 ; UNOPT-NEXT: ld ra, 40(sp) # 8-byte Folded Reload
171 ; UNOPT-NEXT: addi sp, sp, 48
174 %a = call <vscale x 1 x float> @llvm.riscv.vfadd.nxv1f32.nxv1f32(
175 <vscale x 1 x float> undef,
176 <vscale x 1 x float> %0,
177 <vscale x 1 x float> %1,
180 ret <vscale x 1 x float> %a
183 define <vscale x 1 x float> @before_call2(<vscale x 1 x float> %0, <vscale x 1 x float> %1, i64 %2) nounwind {
184 ; CHECK-LABEL: before_call2:
185 ; CHECK: # %bb.0: # %entry
186 ; CHECK-NEXT: addi sp, sp, -48
187 ; CHECK-NEXT: sd ra, 40(sp) # 8-byte Folded Spill
188 ; CHECK-NEXT: csrr a1, vlenb
189 ; CHECK-NEXT: slli a1, a1, 1
190 ; CHECK-NEXT: sub sp, sp, a1
191 ; CHECK-NEXT: vsetvli zero, a0, e32, mf2, ta, ma
192 ; CHECK-NEXT: vfadd.vv v8, v8, v9
193 ; CHECK-NEXT: addi a0, sp, 32
194 ; CHECK-NEXT: vs1r.v v8, (a0) # Unknown-size Folded Spill
195 ; CHECK-NEXT: call foo
196 ; CHECK-NEXT: addi a0, sp, 32
197 ; CHECK-NEXT: vl1r.v v8, (a0) # Unknown-size Folded Reload
198 ; CHECK-NEXT: csrr a0, vlenb
199 ; CHECK-NEXT: slli a0, a0, 1
200 ; CHECK-NEXT: add sp, sp, a0
201 ; CHECK-NEXT: ld ra, 40(sp) # 8-byte Folded Reload
202 ; CHECK-NEXT: addi sp, sp, 48
205 ; UNOPT-LABEL: before_call2:
206 ; UNOPT: # %bb.0: # %entry
207 ; UNOPT-NEXT: addi sp, sp, -48
208 ; UNOPT-NEXT: sd ra, 40(sp) # 8-byte Folded Spill
209 ; UNOPT-NEXT: csrr a1, vlenb
210 ; UNOPT-NEXT: slli a1, a1, 1
211 ; UNOPT-NEXT: sub sp, sp, a1
212 ; UNOPT-NEXT: vsetvli zero, a0, e32, mf2, ta, ma
213 ; UNOPT-NEXT: vfadd.vv v8, v8, v9
214 ; UNOPT-NEXT: addi a0, sp, 32
215 ; UNOPT-NEXT: vs1r.v v8, (a0) # Unknown-size Folded Spill
216 ; UNOPT-NEXT: call foo
217 ; UNOPT-NEXT: addi a0, sp, 32
218 ; UNOPT-NEXT: vl1r.v v8, (a0) # Unknown-size Folded Reload
219 ; UNOPT-NEXT: csrr a0, vlenb
220 ; UNOPT-NEXT: slli a0, a0, 1
221 ; UNOPT-NEXT: add sp, sp, a0
222 ; UNOPT-NEXT: ld ra, 40(sp) # 8-byte Folded Reload
223 ; UNOPT-NEXT: addi sp, sp, 48
226 %a = call <vscale x 1 x float> @llvm.riscv.vfadd.nxv1f32.nxv1f32(
227 <vscale x 1 x float> undef,
228 <vscale x 1 x float> %0,
229 <vscale x 1 x float> %1,
232 ret <vscale x 1 x float> %a
235 define <vscale x 1 x float> @after_call1(<vscale x 1 x float> %0, <vscale x 1 x float> %1, i64 %2) nounwind {
236 ; CHECK-LABEL: after_call1:
237 ; CHECK: # %bb.0: # %entry
238 ; CHECK-NEXT: addi sp, sp, -48
239 ; CHECK-NEXT: sd ra, 40(sp) # 8-byte Folded Spill
240 ; CHECK-NEXT: csrr a1, vlenb
241 ; CHECK-NEXT: slli a1, a1, 1
242 ; CHECK-NEXT: sub sp, sp, a1
243 ; CHECK-NEXT: fsrmi a1, 0
244 ; CHECK-NEXT: vsetvli zero, a0, e32, mf2, ta, ma
245 ; CHECK-NEXT: vfadd.vv v8, v8, v9
246 ; CHECK-NEXT: addi a0, sp, 32
247 ; CHECK-NEXT: vs1r.v v8, (a0) # Unknown-size Folded Spill
248 ; CHECK-NEXT: fsrm a1
249 ; CHECK-NEXT: call foo
250 ; CHECK-NEXT: addi a0, sp, 32
251 ; CHECK-NEXT: vl1r.v v8, (a0) # Unknown-size Folded Reload
252 ; CHECK-NEXT: csrr a0, vlenb
253 ; CHECK-NEXT: slli a0, a0, 1
254 ; CHECK-NEXT: add sp, sp, a0
255 ; CHECK-NEXT: ld ra, 40(sp) # 8-byte Folded Reload
256 ; CHECK-NEXT: addi sp, sp, 48
259 ; UNOPT-LABEL: after_call1:
260 ; UNOPT: # %bb.0: # %entry
261 ; UNOPT-NEXT: addi sp, sp, -48
262 ; UNOPT-NEXT: sd ra, 40(sp) # 8-byte Folded Spill
263 ; UNOPT-NEXT: csrr a1, vlenb
264 ; UNOPT-NEXT: slli a1, a1, 1
265 ; UNOPT-NEXT: sub sp, sp, a1
266 ; UNOPT-NEXT: fsrmi a1, 0
267 ; UNOPT-NEXT: vsetvli zero, a0, e32, mf2, ta, ma
268 ; UNOPT-NEXT: vfadd.vv v8, v8, v9
269 ; UNOPT-NEXT: addi a0, sp, 32
270 ; UNOPT-NEXT: vs1r.v v8, (a0) # Unknown-size Folded Spill
271 ; UNOPT-NEXT: fsrm a1
272 ; UNOPT-NEXT: call foo
273 ; UNOPT-NEXT: addi a0, sp, 32
274 ; UNOPT-NEXT: vl1r.v v8, (a0) # Unknown-size Folded Reload
275 ; UNOPT-NEXT: csrr a0, vlenb
276 ; UNOPT-NEXT: slli a0, a0, 1
277 ; UNOPT-NEXT: add sp, sp, a0
278 ; UNOPT-NEXT: ld ra, 40(sp) # 8-byte Folded Reload
279 ; UNOPT-NEXT: addi sp, sp, 48
282 %a = call <vscale x 1 x float> @llvm.riscv.vfadd.nxv1f32.nxv1f32(
283 <vscale x 1 x float> undef,
284 <vscale x 1 x float> %0,
285 <vscale x 1 x float> %1,
288 ret <vscale x 1 x float> %a
291 define <vscale x 1 x float> @after_call2(<vscale x 1 x float> %0, <vscale x 1 x float> %1, i64 %2) nounwind {
292 ; CHECK-LABEL: after_call2:
293 ; CHECK: # %bb.0: # %entry
294 ; CHECK-NEXT: addi sp, sp, -48
295 ; CHECK-NEXT: sd ra, 40(sp) # 8-byte Folded Spill
296 ; CHECK-NEXT: csrr a1, vlenb
297 ; CHECK-NEXT: slli a1, a1, 1
298 ; CHECK-NEXT: sub sp, sp, a1
299 ; CHECK-NEXT: vsetvli zero, a0, e32, mf2, ta, ma
300 ; CHECK-NEXT: vfadd.vv v8, v8, v9
301 ; CHECK-NEXT: addi a0, sp, 32
302 ; CHECK-NEXT: vs1r.v v8, (a0) # Unknown-size Folded Spill
303 ; CHECK-NEXT: call foo
304 ; CHECK-NEXT: addi a0, sp, 32
305 ; CHECK-NEXT: vl1r.v v8, (a0) # Unknown-size Folded Reload
306 ; CHECK-NEXT: csrr a0, vlenb
307 ; CHECK-NEXT: slli a0, a0, 1
308 ; CHECK-NEXT: add sp, sp, a0
309 ; CHECK-NEXT: ld ra, 40(sp) # 8-byte Folded Reload
310 ; CHECK-NEXT: addi sp, sp, 48
313 ; UNOPT-LABEL: after_call2:
314 ; UNOPT: # %bb.0: # %entry
315 ; UNOPT-NEXT: addi sp, sp, -48
316 ; UNOPT-NEXT: sd ra, 40(sp) # 8-byte Folded Spill
317 ; UNOPT-NEXT: csrr a1, vlenb
318 ; UNOPT-NEXT: slli a1, a1, 1
319 ; UNOPT-NEXT: sub sp, sp, a1
320 ; UNOPT-NEXT: vsetvli zero, a0, e32, mf2, ta, ma
321 ; UNOPT-NEXT: vfadd.vv v8, v8, v9
322 ; UNOPT-NEXT: addi a0, sp, 32
323 ; UNOPT-NEXT: vs1r.v v8, (a0) # Unknown-size Folded Spill
324 ; UNOPT-NEXT: call foo
325 ; UNOPT-NEXT: addi a0, sp, 32
326 ; UNOPT-NEXT: vl1r.v v8, (a0) # Unknown-size Folded Reload
327 ; UNOPT-NEXT: csrr a0, vlenb
328 ; UNOPT-NEXT: slli a0, a0, 1
329 ; UNOPT-NEXT: add sp, sp, a0
330 ; UNOPT-NEXT: ld ra, 40(sp) # 8-byte Folded Reload
331 ; UNOPT-NEXT: addi sp, sp, 48
334 %a = call <vscale x 1 x float> @llvm.riscv.vfadd.nxv1f32.nxv1f32(
335 <vscale x 1 x float> undef,
336 <vscale x 1 x float> %0,
337 <vscale x 1 x float> %1,
340 ret <vscale x 1 x float> %a
343 define <vscale x 1 x float> @just_asm(<vscale x 1 x float> %0) nounwind {
344 ; CHECK-LABEL: just_asm:
345 ; CHECK: # %bb.0: # %entry
347 ; CHECK-NEXT: #NO_APP
350 ; UNOPT-LABEL: just_asm:
351 ; UNOPT: # %bb.0: # %entry
353 ; UNOPT-NEXT: #NO_APP
356 call void asm sideeffect "", ""()
357 ret <vscale x 1 x float> %0
360 define <vscale x 1 x float> @before_asm1(<vscale x 1 x float> %0, <vscale x 1 x float> %1, i64 %2) nounwind {
361 ; CHECK-LABEL: before_asm1:
362 ; CHECK: # %bb.0: # %entry
363 ; CHECK-NEXT: fsrmi a1, 0
364 ; CHECK-NEXT: vsetvli zero, a0, e32, mf2, ta, ma
365 ; CHECK-NEXT: vfadd.vv v8, v8, v9
366 ; CHECK-NEXT: fsrm a1
368 ; CHECK-NEXT: #NO_APP
371 ; UNOPT-LABEL: before_asm1:
372 ; UNOPT: # %bb.0: # %entry
373 ; UNOPT-NEXT: fsrmi a1, 0
374 ; UNOPT-NEXT: vsetvli zero, a0, e32, mf2, ta, ma
375 ; UNOPT-NEXT: vfadd.vv v8, v8, v9
376 ; UNOPT-NEXT: fsrm a1
378 ; UNOPT-NEXT: #NO_APP
381 %a = call <vscale x 1 x float> @llvm.riscv.vfadd.nxv1f32.nxv1f32(
382 <vscale x 1 x float> undef,
383 <vscale x 1 x float> %0,
384 <vscale x 1 x float> %1,
386 call void asm sideeffect "", ""()
387 ret <vscale x 1 x float> %a
390 define <vscale x 1 x float> @before_asm2(<vscale x 1 x float> %0, <vscale x 1 x float> %1, i64 %2) nounwind {
391 ; CHECK-LABEL: before_asm2:
392 ; CHECK: # %bb.0: # %entry
393 ; CHECK-NEXT: vsetvli zero, a0, e32, mf2, ta, ma
394 ; CHECK-NEXT: vfadd.vv v8, v8, v9
396 ; CHECK-NEXT: #NO_APP
399 ; UNOPT-LABEL: before_asm2:
400 ; UNOPT: # %bb.0: # %entry
401 ; UNOPT-NEXT: vsetvli zero, a0, e32, mf2, ta, ma
402 ; UNOPT-NEXT: vfadd.vv v8, v8, v9
404 ; UNOPT-NEXT: #NO_APP
407 %a = call <vscale x 1 x float> @llvm.riscv.vfadd.nxv1f32.nxv1f32(
408 <vscale x 1 x float> undef,
409 <vscale x 1 x float> %0,
410 <vscale x 1 x float> %1,
412 call void asm sideeffect "", ""()
413 ret <vscale x 1 x float> %a
416 define <vscale x 1 x float> @after_asm1(<vscale x 1 x float> %0, <vscale x 1 x float> %1, i64 %2) nounwind {
417 ; CHECK-LABEL: after_asm1:
418 ; CHECK: # %bb.0: # %entry
419 ; CHECK-NEXT: fsrmi a1, 0
420 ; CHECK-NEXT: vsetvli zero, a0, e32, mf2, ta, ma
421 ; CHECK-NEXT: vfadd.vv v8, v8, v9
422 ; CHECK-NEXT: fsrm a1
424 ; CHECK-NEXT: #NO_APP
427 ; UNOPT-LABEL: after_asm1:
428 ; UNOPT: # %bb.0: # %entry
429 ; UNOPT-NEXT: fsrmi a1, 0
430 ; UNOPT-NEXT: vsetvli zero, a0, e32, mf2, ta, ma
431 ; UNOPT-NEXT: vfadd.vv v8, v8, v9
432 ; UNOPT-NEXT: fsrm a1
434 ; UNOPT-NEXT: #NO_APP
437 %a = call <vscale x 1 x float> @llvm.riscv.vfadd.nxv1f32.nxv1f32(
438 <vscale x 1 x float> undef,
439 <vscale x 1 x float> %0,
440 <vscale x 1 x float> %1,
442 call void asm sideeffect "", ""()
443 ret <vscale x 1 x float> %a
446 define <vscale x 1 x float> @after_asm2(<vscale x 1 x float> %0, <vscale x 1 x float> %1, i64 %2) nounwind {
447 ; CHECK-LABEL: after_asm2:
448 ; CHECK: # %bb.0: # %entry
449 ; CHECK-NEXT: vsetvli zero, a0, e32, mf2, ta, ma
450 ; CHECK-NEXT: vfadd.vv v8, v8, v9
452 ; CHECK-NEXT: #NO_APP
455 ; UNOPT-LABEL: after_asm2:
456 ; UNOPT: # %bb.0: # %entry
457 ; UNOPT-NEXT: vsetvli zero, a0, e32, mf2, ta, ma
458 ; UNOPT-NEXT: vfadd.vv v8, v8, v9
460 ; UNOPT-NEXT: #NO_APP
463 %a = call <vscale x 1 x float> @llvm.riscv.vfadd.nxv1f32.nxv1f32(
464 <vscale x 1 x float> undef,
465 <vscale x 1 x float> %0,
466 <vscale x 1 x float> %1,
468 call void asm sideeffect "", ""()
469 ret <vscale x 1 x float> %a
472 ; Test restoring frm before reading frm and doing nothing with following
473 ; dynamic rounding mode operations.
474 ; TODO: The frrm could be elided.
475 declare i32 @llvm.get.rounding()
476 define <vscale x 1 x float> @test5(<vscale x 1 x float> %0, <vscale x 1 x float> %1, i64 %2, ptr %p) nounwind {
477 ; CHECK-LABEL: test5:
478 ; CHECK: # %bb.0: # %entry
479 ; CHECK-NEXT: fsrmi a2, 0
480 ; CHECK-NEXT: vsetvli zero, a0, e32, mf2, ta, ma
481 ; CHECK-NEXT: vfadd.vv v8, v8, v9
482 ; CHECK-NEXT: fsrm a2
483 ; CHECK-NEXT: frrm a0
484 ; CHECK-NEXT: slli a0, a0, 2
485 ; CHECK-NEXT: lui a2, 66
486 ; CHECK-NEXT: addiw a2, a2, 769
487 ; CHECK-NEXT: srl a0, a2, a0
488 ; CHECK-NEXT: andi a0, a0, 7
489 ; CHECK-NEXT: vfadd.vv v8, v8, v8
490 ; CHECK-NEXT: sw a0, 0(a1)
493 ; UNOPT-LABEL: test5:
494 ; UNOPT: # %bb.0: # %entry
495 ; UNOPT-NEXT: fsrmi a2, 0
496 ; UNOPT-NEXT: vsetvli zero, a0, e32, mf2, ta, ma
497 ; UNOPT-NEXT: vfadd.vv v8, v8, v9
498 ; UNOPT-NEXT: fsrm a2
499 ; UNOPT-NEXT: frrm a0
500 ; UNOPT-NEXT: slli a0, a0, 2
501 ; UNOPT-NEXT: lui a2, 66
502 ; UNOPT-NEXT: addiw a2, a2, 769
503 ; UNOPT-NEXT: srl a0, a2, a0
504 ; UNOPT-NEXT: andi a0, a0, 7
505 ; UNOPT-NEXT: vfadd.vv v8, v8, v8
506 ; UNOPT-NEXT: sw a0, 0(a1)
509 %a = call <vscale x 1 x float> @llvm.riscv.vfadd.nxv1f32.nxv1f32(
510 <vscale x 1 x float> undef,
511 <vscale x 1 x float> %0,
512 <vscale x 1 x float> %1,
514 %rm = call i32 @llvm.get.rounding()
515 store i32 %rm, ptr %p, align 4
516 %b = call <vscale x 1 x float> @llvm.riscv.vfadd.nxv1f32.nxv1f32(
517 <vscale x 1 x float> undef,
518 <vscale x 1 x float> %a,
519 <vscale x 1 x float> %a,
521 ret <vscale x 1 x float> %b
524 ; Test not set FRM for vfadd with DYN after WriteFRMImm.
525 declare void @llvm.set.rounding(i32)
526 define <vscale x 1 x float> @after_fsrm1(<vscale x 1 x float> %0, <vscale x 1 x float> %1, i64 %2) nounwind {
527 ; CHECK-LABEL: after_fsrm1:
528 ; CHECK: # %bb.0: # %entry
529 ; CHECK-NEXT: fsrmi 4
530 ; CHECK-NEXT: vsetvli zero, a0, e32, mf2, ta, ma
531 ; CHECK-NEXT: vfadd.vv v8, v8, v9
534 ; UNOPT-LABEL: after_fsrm1:
535 ; UNOPT: # %bb.0: # %entry
536 ; UNOPT-NEXT: fsrmi 4
537 ; UNOPT-NEXT: vsetvli zero, a0, e32, mf2, ta, ma
538 ; UNOPT-NEXT: vfadd.vv v8, v8, v9
541 call void @llvm.set.rounding(i32 4)
542 %a = call <vscale x 1 x float> @llvm.riscv.vfadd.nxv1f32.nxv1f32(
543 <vscale x 1 x float> undef,
544 <vscale x 1 x float> %0,
545 <vscale x 1 x float> %1,
547 ret <vscale x 1 x float> %a
550 ; Test not set FRM for vfadd with a known rm after WriteFRMImm with same rm.
551 define <vscale x 1 x float> @after_fsrm2(<vscale x 1 x float> %0, <vscale x 1 x float> %1, i64 %2) nounwind {
552 ; CHECK-LABEL: after_fsrm2:
553 ; CHECK: # %bb.0: # %entry
554 ; CHECK-NEXT: fsrmi 4
555 ; CHECK-NEXT: vsetvli zero, a0, e32, mf2, ta, ma
556 ; CHECK-NEXT: vfadd.vv v8, v8, v9
559 ; UNOPT-LABEL: after_fsrm2:
560 ; UNOPT: # %bb.0: # %entry
561 ; UNOPT-NEXT: fsrmi 4
562 ; UNOPT-NEXT: fsrmi a1, 4
563 ; UNOPT-NEXT: vsetvli zero, a0, e32, mf2, ta, ma
564 ; UNOPT-NEXT: vfadd.vv v8, v8, v9
565 ; UNOPT-NEXT: fsrm a1
568 call void @llvm.set.rounding(i32 4)
569 %a = call <vscale x 1 x float> @llvm.riscv.vfadd.nxv1f32.nxv1f32(
570 <vscale x 1 x float> undef,
571 <vscale x 1 x float> %0,
572 <vscale x 1 x float> %1,
574 ret <vscale x 1 x float> %a
577 ; Test not set FRM for vfadd with a known rm after WriteFRMImm with same rm.
578 define <vscale x 1 x float> @after_fsrm3(<vscale x 1 x float> %0, <vscale x 1 x float> %1, i64 %2) nounwind {
579 ; CHECK-LABEL: after_fsrm3:
580 ; CHECK: # %bb.0: # %entry
581 ; CHECK-NEXT: fsrmi 4
582 ; CHECK-NEXT: fsrmi a1, 5
583 ; CHECK-NEXT: vsetvli zero, a0, e32, mf2, ta, ma
584 ; CHECK-NEXT: vfadd.vv v8, v8, v9
585 ; CHECK-NEXT: fsrm a1
588 ; UNOPT-LABEL: after_fsrm3:
589 ; UNOPT: # %bb.0: # %entry
590 ; UNOPT-NEXT: fsrmi 4
591 ; UNOPT-NEXT: fsrmi a1, 5
592 ; UNOPT-NEXT: vsetvli zero, a0, e32, mf2, ta, ma
593 ; UNOPT-NEXT: vfadd.vv v8, v8, v9
594 ; UNOPT-NEXT: fsrm a1
597 call void @llvm.set.rounding(i32 4)
598 %a = call <vscale x 1 x float> @llvm.riscv.vfadd.nxv1f32.nxv1f32(
599 <vscale x 1 x float> undef,
600 <vscale x 1 x float> %0,
601 <vscale x 1 x float> %1,
603 ret <vscale x 1 x float> %a
606 ; Test not set FRM for the vfadd after WriteFRM.
607 define <vscale x 1 x float> @after_fsrm4(<vscale x 1 x float> %0, <vscale x 1 x float> %1, i32 %rm, i64 %2) nounwind {
608 ; CHECK-LABEL: after_fsrm4:
609 ; CHECK: # %bb.0: # %entry
610 ; CHECK-NEXT: slli a0, a0, 32
611 ; CHECK-NEXT: srli a0, a0, 30
612 ; CHECK-NEXT: lui a2, 66
613 ; CHECK-NEXT: addiw a2, a2, 769
614 ; CHECK-NEXT: srl a0, a2, a0
615 ; CHECK-NEXT: andi a0, a0, 7
616 ; CHECK-NEXT: fsrm a0
617 ; CHECK-NEXT: vsetvli zero, a1, e32, mf2, ta, ma
618 ; CHECK-NEXT: vfadd.vv v8, v8, v9
621 ; UNOPT-LABEL: after_fsrm4:
622 ; UNOPT: # %bb.0: # %entry
623 ; UNOPT-NEXT: slli a0, a0, 32
624 ; UNOPT-NEXT: srli a0, a0, 30
625 ; UNOPT-NEXT: lui a2, 66
626 ; UNOPT-NEXT: addiw a2, a2, 769
627 ; UNOPT-NEXT: srl a0, a2, a0
628 ; UNOPT-NEXT: andi a0, a0, 7
629 ; UNOPT-NEXT: fsrm a0
630 ; UNOPT-NEXT: vsetvli zero, a1, e32, mf2, ta, ma
631 ; UNOPT-NEXT: vfadd.vv v8, v8, v9
634 call void @llvm.set.rounding(i32 %rm)
635 %a = call <vscale x 1 x float> @llvm.riscv.vfadd.nxv1f32.nxv1f32(
636 <vscale x 1 x float> undef,
637 <vscale x 1 x float> %0,
638 <vscale x 1 x float> %1,
640 ret <vscale x 1 x float> %a