1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv32 -verify-machineinstrs < %s \
3 ; RUN: | FileCheck -check-prefix=RV32IF %s
4 ; RUN: llc -mtriple=riscv64 -verify-machineinstrs < %s \
5 ; RUN: | FileCheck -check-prefix=RV64IF %s
7 ; This file provides a simple sanity check of float and double operations for
8 ; RV32I and RV64I. This is primarily intended to ensure that custom
9 ; legalisation or DAG combines aren't incorrectly triggered when the F
10 ; extension isn't enabled.
12 ; TODO: f32 parameters on RV64 with a soft-float ABI are anyext.
14 define float @float_test(float %a, float %b) nounwind {
15 ; RV32IF-LABEL: float_test:
17 ; RV32IF-NEXT: addi sp, sp, -16
18 ; RV32IF-NEXT: sw ra, 12(sp)
19 ; RV32IF-NEXT: sw s0, 8(sp)
20 ; RV32IF-NEXT: mv s0, a1
21 ; RV32IF-NEXT: call __addsf3
22 ; RV32IF-NEXT: mv a1, s0
23 ; RV32IF-NEXT: call __divsf3
24 ; RV32IF-NEXT: lw s0, 8(sp)
25 ; RV32IF-NEXT: lw ra, 12(sp)
26 ; RV32IF-NEXT: addi sp, sp, 16
29 ; RV64IF-LABEL: float_test:
31 ; RV64IF-NEXT: addi sp, sp, -16
32 ; RV64IF-NEXT: sd ra, 8(sp)
33 ; RV64IF-NEXT: sd s0, 0(sp)
34 ; RV64IF-NEXT: slli a0, a0, 32
35 ; RV64IF-NEXT: srli a0, a0, 32
36 ; RV64IF-NEXT: slli a1, a1, 32
37 ; RV64IF-NEXT: srli s0, a1, 32
38 ; RV64IF-NEXT: mv a1, s0
39 ; RV64IF-NEXT: call __addsf3
40 ; RV64IF-NEXT: mv a1, s0
41 ; RV64IF-NEXT: call __divsf3
42 ; RV64IF-NEXT: ld s0, 0(sp)
43 ; RV64IF-NEXT: ld ra, 8(sp)
44 ; RV64IF-NEXT: addi sp, sp, 16
46 %1 = fadd float %a, %b
47 %2 = fdiv float %1, %b
51 define double @double_test(double %a, double %b) nounwind {
52 ; RV32IF-LABEL: double_test:
54 ; RV32IF-NEXT: addi sp, sp, -16
55 ; RV32IF-NEXT: sw ra, 12(sp)
56 ; RV32IF-NEXT: sw s0, 8(sp)
57 ; RV32IF-NEXT: sw s1, 4(sp)
58 ; RV32IF-NEXT: mv s0, a3
59 ; RV32IF-NEXT: mv s1, a2
60 ; RV32IF-NEXT: call __adddf3
61 ; RV32IF-NEXT: mv a2, s1
62 ; RV32IF-NEXT: mv a3, s0
63 ; RV32IF-NEXT: call __divdf3
64 ; RV32IF-NEXT: lw s1, 4(sp)
65 ; RV32IF-NEXT: lw s0, 8(sp)
66 ; RV32IF-NEXT: lw ra, 12(sp)
67 ; RV32IF-NEXT: addi sp, sp, 16
70 ; RV64IF-LABEL: double_test:
72 ; RV64IF-NEXT: addi sp, sp, -16
73 ; RV64IF-NEXT: sd ra, 8(sp)
74 ; RV64IF-NEXT: sd s0, 0(sp)
75 ; RV64IF-NEXT: mv s0, a1
76 ; RV64IF-NEXT: call __adddf3
77 ; RV64IF-NEXT: mv a1, s0
78 ; RV64IF-NEXT: call __divdf3
79 ; RV64IF-NEXT: ld s0, 0(sp)
80 ; RV64IF-NEXT: ld ra, 8(sp)
81 ; RV64IF-NEXT: addi sp, sp, 16
83 %1 = fadd double %a, %b
84 %2 = fdiv double %1, %b