1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv32 -mattr=+zdinx -verify-machineinstrs < %s \
3 ; RUN: -target-abi=ilp32 | FileCheck -check-prefix=RV32ZDINX %s
4 ; RUN: llc -mtriple=riscv64 -mattr=+zdinx -verify-machineinstrs < %s \
5 ; RUN: -target-abi=lp64 | FileCheck -check-prefix=RV64ZDINX %s
7 define void @foo(ptr nocapture %p, double %d) nounwind {
8 ; RV32ZDINX-LABEL: foo:
9 ; RV32ZDINX: # %bb.0: # %entry
10 ; RV32ZDINX-NEXT: addi sp, sp, -16
11 ; RV32ZDINX-NEXT: sw a1, 8(sp)
12 ; RV32ZDINX-NEXT: sw a2, 12(sp)
13 ; RV32ZDINX-NEXT: lw a2, 8(sp)
14 ; RV32ZDINX-NEXT: lw a3, 12(sp)
15 ; RV32ZDINX-NEXT: addi a0, a0, 2047
16 ; RV32ZDINX-NEXT: sw a2, -3(a0)
17 ; RV32ZDINX-NEXT: sw a3, 1(a0)
18 ; RV32ZDINX-NEXT: addi sp, sp, 16
21 ; RV64ZDINX-LABEL: foo:
22 ; RV64ZDINX: # %bb.0: # %entry
23 ; RV64ZDINX-NEXT: sd a1, 2044(a0)
26 %add.ptr = getelementptr inbounds i8, ptr %p, i64 2044
27 store double %d, ptr %add.ptr, align 8
31 define void @foo2(ptr nocapture %p, double %d) nounwind {
32 ; RV32ZDINX-LABEL: foo2:
33 ; RV32ZDINX: # %bb.0: # %entry
34 ; RV32ZDINX-NEXT: addi sp, sp, -16
35 ; RV32ZDINX-NEXT: sw a1, 8(sp)
36 ; RV32ZDINX-NEXT: sw a2, 12(sp)
37 ; RV32ZDINX-NEXT: lw a2, 8(sp)
38 ; RV32ZDINX-NEXT: lw a3, 12(sp)
39 ; RV32ZDINX-NEXT: fadd.d a2, a2, a2
40 ; RV32ZDINX-NEXT: addi a0, a0, 2047
41 ; RV32ZDINX-NEXT: sw a2, -3(a0)
42 ; RV32ZDINX-NEXT: sw a3, 1(a0)
43 ; RV32ZDINX-NEXT: addi sp, sp, 16
46 ; RV64ZDINX-LABEL: foo2:
47 ; RV64ZDINX: # %bb.0: # %entry
48 ; RV64ZDINX-NEXT: fadd.d a1, a1, a1
49 ; RV64ZDINX-NEXT: sd a1, 2044(a0)
52 %a = fadd double %d, %d
53 %add.ptr = getelementptr inbounds i8, ptr %p, i64 2044
54 store double %a, ptr %add.ptr, align 8
58 @d = global double 4.2, align 8
60 define void @foo3(ptr nocapture %p) nounwind {
61 ; RV32ZDINX-LABEL: foo3:
62 ; RV32ZDINX: # %bb.0: # %entry
63 ; RV32ZDINX-NEXT: lui a1, %hi(d)
64 ; RV32ZDINX-NEXT: lw a2, %lo(d)(a1)
65 ; RV32ZDINX-NEXT: lw a3, %lo(d+4)(a1)
66 ; RV32ZDINX-NEXT: addi a0, a0, 2047
67 ; RV32ZDINX-NEXT: sw a2, -3(a0)
68 ; RV32ZDINX-NEXT: sw a3, 1(a0)
71 ; RV64ZDINX-LABEL: foo3:
72 ; RV64ZDINX: # %bb.0: # %entry
73 ; RV64ZDINX-NEXT: lui a1, %hi(d)
74 ; RV64ZDINX-NEXT: ld a1, %lo(d)(a1)
75 ; RV64ZDINX-NEXT: sd a1, 2044(a0)
78 %0 = load double, ptr @d, align 8
79 %add.ptr = getelementptr inbounds i8, ptr %p, i64 2044
80 store double %0, ptr %add.ptr, align 8
84 define void @foo4(ptr %p) nounwind {
85 ; RV32ZDINX-LABEL: foo4:
86 ; RV32ZDINX: # %bb.0: # %entry
87 ; RV32ZDINX-NEXT: addi sp, sp, -16
88 ; RV32ZDINX-NEXT: addi a1, a0, 2047
89 ; RV32ZDINX-NEXT: lw a2, -3(a1)
90 ; RV32ZDINX-NEXT: lw a3, 1(a1)
91 ; RV32ZDINX-NEXT: sw a0, 8(sp)
92 ; RV32ZDINX-NEXT: lui a0, %hi(d)
93 ; RV32ZDINX-NEXT: sw a2, %lo(d)(a0)
94 ; RV32ZDINX-NEXT: sw a3, %lo(d+4)(a0)
95 ; RV32ZDINX-NEXT: addi sp, sp, 16
98 ; RV64ZDINX-LABEL: foo4:
99 ; RV64ZDINX: # %bb.0: # %entry
100 ; RV64ZDINX-NEXT: addi sp, sp, -16
101 ; RV64ZDINX-NEXT: ld a1, 2044(a0)
102 ; RV64ZDINX-NEXT: sd a0, 8(sp)
103 ; RV64ZDINX-NEXT: lui a0, %hi(d)
104 ; RV64ZDINX-NEXT: sd a1, %lo(d)(a0)
105 ; RV64ZDINX-NEXT: addi sp, sp, 16
106 ; RV64ZDINX-NEXT: ret
108 %p.addr = alloca ptr, align 8
109 store ptr %p, ptr %p.addr, align 8
110 %0 = load ptr, ptr %p.addr, align 8
111 %add.ptr = getelementptr inbounds i8, ptr %0, i64 2044
112 %1 = load double, ptr %add.ptr, align 8
113 store double %1, ptr @d, align 8
117 define void @foo5(ptr nocapture %p, double %d) nounwind {
118 ; RV32ZDINX-LABEL: foo5:
119 ; RV32ZDINX: # %bb.0: # %entry
120 ; RV32ZDINX-NEXT: addi sp, sp, -16
121 ; RV32ZDINX-NEXT: sw a1, 8(sp)
122 ; RV32ZDINX-NEXT: sw a2, 12(sp)
123 ; RV32ZDINX-NEXT: lw a2, 8(sp)
124 ; RV32ZDINX-NEXT: lw a3, 12(sp)
125 ; RV32ZDINX-NEXT: addi a0, a0, -2048
126 ; RV32ZDINX-NEXT: sw a2, -1(a0)
127 ; RV32ZDINX-NEXT: sw a3, 3(a0)
128 ; RV32ZDINX-NEXT: addi sp, sp, 16
129 ; RV32ZDINX-NEXT: ret
131 ; RV64ZDINX-LABEL: foo5:
132 ; RV64ZDINX: # %bb.0: # %entry
133 ; RV64ZDINX-NEXT: addi a0, a0, -2048
134 ; RV64ZDINX-NEXT: sd a1, -1(a0)
135 ; RV64ZDINX-NEXT: ret
137 %add.ptr = getelementptr inbounds i8, ptr %p, i64 -2049
138 store double %d, ptr %add.ptr, align 8
142 define void @foo6(ptr %p, double %d) nounwind {
143 ; RV32ZDINX-LABEL: foo6:
144 ; RV32ZDINX: # %bb.0: # %entry
145 ; RV32ZDINX-NEXT: addi sp, sp, -16
146 ; RV32ZDINX-NEXT: sw a1, 8(sp)
147 ; RV32ZDINX-NEXT: sw a2, 12(sp)
148 ; RV32ZDINX-NEXT: lw a2, 8(sp)
149 ; RV32ZDINX-NEXT: lw a3, 12(sp)
150 ; RV32ZDINX-NEXT: lui a1, %hi(.LCPI5_0)
151 ; RV32ZDINX-NEXT: lw a4, %lo(.LCPI5_0)(a1)
152 ; RV32ZDINX-NEXT: lw a5, %lo(.LCPI5_0+4)(a1)
153 ; RV32ZDINX-NEXT: fadd.d a2, a2, a4
154 ; RV32ZDINX-NEXT: addi a0, a0, 2047
155 ; RV32ZDINX-NEXT: sw a2, -3(a0)
156 ; RV32ZDINX-NEXT: sw a3, 1(a0)
157 ; RV32ZDINX-NEXT: addi sp, sp, 16
158 ; RV32ZDINX-NEXT: ret
160 ; RV64ZDINX-LABEL: foo6:
161 ; RV64ZDINX: # %bb.0: # %entry
162 ; RV64ZDINX-NEXT: lui a2, %hi(.LCPI5_0)
163 ; RV64ZDINX-NEXT: ld a2, %lo(.LCPI5_0)(a2)
164 ; RV64ZDINX-NEXT: fadd.d a1, a1, a2
165 ; RV64ZDINX-NEXT: sd a1, 2044(a0)
166 ; RV64ZDINX-NEXT: ret
168 %add = fadd double %d, 3.140000e+00
169 %add.ptr = getelementptr inbounds i8, ptr %p, i64 2044
170 store double %add, ptr %add.ptr, align 8