1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv32 -mattr=+d -target-abi=ilp32 -verify-machineinstrs < %s \
3 ; RUN: | FileCheck -check-prefix=RV32IFD %s
4 ; RUN: llc -mtriple=riscv64 -mattr=+d -target-abi=lp64 -verify-machineinstrs < %s \
5 ; RUN: | FileCheck -check-prefix=RV64IFD %s
6 ; RUN: llc -mtriple=riscv32 -mattr=+zdinx -target-abi=ilp32 -verify-machineinstrs < %s \
7 ; RUN: | FileCheck -check-prefix=RV32IZFINXZDINX %s
8 ; RUN: llc -mtriple=riscv64 -mattr=+zdinx -target-abi=lp64 -verify-machineinstrs < %s \
9 ; RUN: | FileCheck -check-prefix=RV64IZFINXZDINX %s
11 define double @func(double %d, i32 %n) nounwind {
12 ; RV32IFD-LABEL: func:
13 ; RV32IFD: # %bb.0: # %entry
14 ; RV32IFD-NEXT: addi sp, sp, -32
15 ; RV32IFD-NEXT: sw ra, 28(sp) # 4-byte Folded Spill
16 ; RV32IFD-NEXT: sw a0, 16(sp)
17 ; RV32IFD-NEXT: sw a1, 20(sp)
18 ; RV32IFD-NEXT: fld fa5, 16(sp)
19 ; RV32IFD-NEXT: beqz a2, .LBB0_2
20 ; RV32IFD-NEXT: # %bb.1: # %if.else
21 ; RV32IFD-NEXT: addi a2, a2, -1
22 ; RV32IFD-NEXT: fsd fa5, 16(sp)
23 ; RV32IFD-NEXT: lw a0, 16(sp)
24 ; RV32IFD-NEXT: lw a1, 20(sp)
25 ; RV32IFD-NEXT: fsd fa5, 8(sp) # 8-byte Folded Spill
26 ; RV32IFD-NEXT: call func
27 ; RV32IFD-NEXT: sw a0, 16(sp)
28 ; RV32IFD-NEXT: sw a1, 20(sp)
29 ; RV32IFD-NEXT: fld fa5, 16(sp)
30 ; RV32IFD-NEXT: fld fa4, 8(sp) # 8-byte Folded Reload
31 ; RV32IFD-NEXT: fadd.d fa5, fa5, fa4
32 ; RV32IFD-NEXT: .LBB0_2: # %return
33 ; RV32IFD-NEXT: fsd fa5, 16(sp)
34 ; RV32IFD-NEXT: lw a0, 16(sp)
35 ; RV32IFD-NEXT: lw a1, 20(sp)
36 ; RV32IFD-NEXT: lw ra, 28(sp) # 4-byte Folded Reload
37 ; RV32IFD-NEXT: addi sp, sp, 32
40 ; RV64IFD-LABEL: func:
41 ; RV64IFD: # %bb.0: # %entry
42 ; RV64IFD-NEXT: sext.w a2, a1
43 ; RV64IFD-NEXT: fmv.d.x fa5, a0
44 ; RV64IFD-NEXT: beqz a2, .LBB0_2
45 ; RV64IFD-NEXT: # %bb.1: # %if.else
46 ; RV64IFD-NEXT: addi sp, sp, -16
47 ; RV64IFD-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
48 ; RV64IFD-NEXT: addiw a1, a1, -1
49 ; RV64IFD-NEXT: fmv.x.d a0, fa5
50 ; RV64IFD-NEXT: fsd fa5, 0(sp) # 8-byte Folded Spill
51 ; RV64IFD-NEXT: call func
52 ; RV64IFD-NEXT: fmv.d.x fa5, a0
53 ; RV64IFD-NEXT: fld fa4, 0(sp) # 8-byte Folded Reload
54 ; RV64IFD-NEXT: fadd.d fa5, fa5, fa4
55 ; RV64IFD-NEXT: fmv.x.d a0, fa5
56 ; RV64IFD-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
57 ; RV64IFD-NEXT: addi sp, sp, 16
59 ; RV64IFD-NEXT: .LBB0_2: # %return
60 ; RV64IFD-NEXT: fmv.x.d a0, fa5
63 ; RV32IZFINXZDINX-LABEL: func:
64 ; RV32IZFINXZDINX: # %bb.0: # %entry
65 ; RV32IZFINXZDINX-NEXT: addi sp, sp, -32
66 ; RV32IZFINXZDINX-NEXT: sw ra, 28(sp) # 4-byte Folded Spill
67 ; RV32IZFINXZDINX-NEXT: sw s0, 24(sp) # 4-byte Folded Spill
68 ; RV32IZFINXZDINX-NEXT: sw s1, 20(sp) # 4-byte Folded Spill
69 ; RV32IZFINXZDINX-NEXT: sw a0, 8(sp)
70 ; RV32IZFINXZDINX-NEXT: sw a1, 12(sp)
71 ; RV32IZFINXZDINX-NEXT: lw s0, 8(sp)
72 ; RV32IZFINXZDINX-NEXT: lw s1, 12(sp)
73 ; RV32IZFINXZDINX-NEXT: beqz a2, .LBB0_2
74 ; RV32IZFINXZDINX-NEXT: # %bb.1: # %if.else
75 ; RV32IZFINXZDINX-NEXT: addi a2, a2, -1
76 ; RV32IZFINXZDINX-NEXT: sw s0, 8(sp)
77 ; RV32IZFINXZDINX-NEXT: sw s1, 12(sp)
78 ; RV32IZFINXZDINX-NEXT: lw a0, 8(sp)
79 ; RV32IZFINXZDINX-NEXT: lw a1, 12(sp)
80 ; RV32IZFINXZDINX-NEXT: call func
81 ; RV32IZFINXZDINX-NEXT: sw a0, 8(sp)
82 ; RV32IZFINXZDINX-NEXT: sw a1, 12(sp)
83 ; RV32IZFINXZDINX-NEXT: lw a0, 8(sp)
84 ; RV32IZFINXZDINX-NEXT: lw a1, 12(sp)
85 ; RV32IZFINXZDINX-NEXT: fadd.d a0, a0, s0
86 ; RV32IZFINXZDINX-NEXT: sw a0, 8(sp)
87 ; RV32IZFINXZDINX-NEXT: sw a1, 12(sp)
88 ; RV32IZFINXZDINX-NEXT: j .LBB0_3
89 ; RV32IZFINXZDINX-NEXT: .LBB0_2: # %return
90 ; RV32IZFINXZDINX-NEXT: sw s0, 8(sp)
91 ; RV32IZFINXZDINX-NEXT: sw s1, 12(sp)
92 ; RV32IZFINXZDINX-NEXT: .LBB0_3: # %return
93 ; RV32IZFINXZDINX-NEXT: lw a0, 8(sp)
94 ; RV32IZFINXZDINX-NEXT: lw a1, 12(sp)
95 ; RV32IZFINXZDINX-NEXT: lw ra, 28(sp) # 4-byte Folded Reload
96 ; RV32IZFINXZDINX-NEXT: lw s0, 24(sp) # 4-byte Folded Reload
97 ; RV32IZFINXZDINX-NEXT: lw s1, 20(sp) # 4-byte Folded Reload
98 ; RV32IZFINXZDINX-NEXT: addi sp, sp, 32
99 ; RV32IZFINXZDINX-NEXT: ret
101 ; RV64IZFINXZDINX-LABEL: func:
102 ; RV64IZFINXZDINX: # %bb.0: # %entry
103 ; RV64IZFINXZDINX-NEXT: sext.w a2, a1
104 ; RV64IZFINXZDINX-NEXT: beqz a2, .LBB0_2
105 ; RV64IZFINXZDINX-NEXT: # %bb.1: # %if.else
106 ; RV64IZFINXZDINX-NEXT: addi sp, sp, -16
107 ; RV64IZFINXZDINX-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
108 ; RV64IZFINXZDINX-NEXT: sd s0, 0(sp) # 8-byte Folded Spill
109 ; RV64IZFINXZDINX-NEXT: addiw a1, a1, -1
110 ; RV64IZFINXZDINX-NEXT: mv s0, a0
111 ; RV64IZFINXZDINX-NEXT: call func
112 ; RV64IZFINXZDINX-NEXT: fadd.d a0, a0, s0
113 ; RV64IZFINXZDINX-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
114 ; RV64IZFINXZDINX-NEXT: ld s0, 0(sp) # 8-byte Folded Reload
115 ; RV64IZFINXZDINX-NEXT: addi sp, sp, 16
116 ; RV64IZFINXZDINX-NEXT: .LBB0_2: # %return
117 ; RV64IZFINXZDINX-NEXT: ret
119 %cmp = icmp eq i32 %n, 0
120 br i1 %cmp, label %return, label %if.else
123 %sub = add i32 %n, -1
124 %call = tail call double @func(double %d, i32 %sub)
125 %add = fadd double %call, %d