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: mv a3, a2
11 ; RV32ZDINX-NEXT: addi a0, a0, 2047
12 ; RV32ZDINX-NEXT: mv a2, a1
13 ; RV32ZDINX-NEXT: sw a2, -3(a0)
14 ; RV32ZDINX-NEXT: sw a3, 1(a0)
17 ; RV64ZDINX-LABEL: foo:
18 ; RV64ZDINX: # %bb.0: # %entry
19 ; RV64ZDINX-NEXT: sd a1, 2044(a0)
22 %add.ptr = getelementptr inbounds i8, ptr %p, i64 2044
23 store double %d, ptr %add.ptr, align 8
27 define void @foo2(ptr nocapture %p, double %d) nounwind {
28 ; RV32ZDINX-LABEL: foo2:
29 ; RV32ZDINX: # %bb.0: # %entry
30 ; RV32ZDINX-NEXT: mv a3, a2
31 ; RV32ZDINX-NEXT: mv a2, a1
32 ; RV32ZDINX-NEXT: fadd.d a2, a2, a2
33 ; RV32ZDINX-NEXT: addi a0, a0, 2047
34 ; RV32ZDINX-NEXT: sw a2, -3(a0)
35 ; RV32ZDINX-NEXT: sw a3, 1(a0)
38 ; RV64ZDINX-LABEL: foo2:
39 ; RV64ZDINX: # %bb.0: # %entry
40 ; RV64ZDINX-NEXT: fadd.d a1, a1, a1
41 ; RV64ZDINX-NEXT: sd a1, 2044(a0)
44 %a = fadd double %d, %d
45 %add.ptr = getelementptr inbounds i8, ptr %p, i64 2044
46 store double %a, ptr %add.ptr, align 8
50 @d = global double 4.2, align 8
52 define void @foo3(ptr nocapture %p) nounwind {
53 ; RV32ZDINX-LABEL: foo3:
54 ; RV32ZDINX: # %bb.0: # %entry
55 ; RV32ZDINX-NEXT: lui a1, %hi(d)
56 ; RV32ZDINX-NEXT: lw a2, %lo(d)(a1)
57 ; RV32ZDINX-NEXT: lw a3, %lo(d+4)(a1)
58 ; RV32ZDINX-NEXT: addi a0, a0, 2047
59 ; RV32ZDINX-NEXT: sw a2, -3(a0)
60 ; RV32ZDINX-NEXT: sw a3, 1(a0)
63 ; RV64ZDINX-LABEL: foo3:
64 ; RV64ZDINX: # %bb.0: # %entry
65 ; RV64ZDINX-NEXT: lui a1, %hi(d)
66 ; RV64ZDINX-NEXT: ld a1, %lo(d)(a1)
67 ; RV64ZDINX-NEXT: sd a1, 2044(a0)
70 %0 = load double, ptr @d, align 8
71 %add.ptr = getelementptr inbounds i8, ptr %p, i64 2044
72 store double %0, ptr %add.ptr, align 8
76 define void @foo4(ptr %p) nounwind {
77 ; RV32ZDINX-LABEL: foo4:
78 ; RV32ZDINX: # %bb.0: # %entry
79 ; RV32ZDINX-NEXT: addi sp, sp, -16
80 ; RV32ZDINX-NEXT: addi a1, a0, 2047
81 ; RV32ZDINX-NEXT: lw a2, -3(a1)
82 ; RV32ZDINX-NEXT: lw a3, 1(a1)
83 ; RV32ZDINX-NEXT: sw a0, 8(sp)
84 ; RV32ZDINX-NEXT: lui a0, %hi(d)
85 ; RV32ZDINX-NEXT: sw a2, %lo(d)(a0)
86 ; RV32ZDINX-NEXT: sw a3, %lo(d+4)(a0)
87 ; RV32ZDINX-NEXT: addi sp, sp, 16
90 ; RV64ZDINX-LABEL: foo4:
91 ; RV64ZDINX: # %bb.0: # %entry
92 ; RV64ZDINX-NEXT: addi sp, sp, -16
93 ; RV64ZDINX-NEXT: ld a1, 2044(a0)
94 ; RV64ZDINX-NEXT: sd a0, 8(sp)
95 ; RV64ZDINX-NEXT: lui a0, %hi(d)
96 ; RV64ZDINX-NEXT: sd a1, %lo(d)(a0)
97 ; RV64ZDINX-NEXT: addi sp, sp, 16
100 %p.addr = alloca ptr, align 8
101 store ptr %p, ptr %p.addr, align 8
102 %0 = load ptr, ptr %p.addr, align 8
103 %add.ptr = getelementptr inbounds i8, ptr %0, i64 2044
104 %1 = load double, ptr %add.ptr, align 8
105 store double %1, ptr @d, align 8
109 define void @foo5(ptr nocapture %p, double %d) nounwind {
110 ; RV32ZDINX-LABEL: foo5:
111 ; RV32ZDINX: # %bb.0: # %entry
112 ; RV32ZDINX-NEXT: mv a3, a2
113 ; RV32ZDINX-NEXT: addi a0, a0, -2048
114 ; RV32ZDINX-NEXT: mv a2, a1
115 ; RV32ZDINX-NEXT: sw a2, -1(a0)
116 ; RV32ZDINX-NEXT: sw a3, 3(a0)
117 ; RV32ZDINX-NEXT: ret
119 ; RV64ZDINX-LABEL: foo5:
120 ; RV64ZDINX: # %bb.0: # %entry
121 ; RV64ZDINX-NEXT: addi a0, a0, -2048
122 ; RV64ZDINX-NEXT: sd a1, -1(a0)
123 ; RV64ZDINX-NEXT: ret
125 %add.ptr = getelementptr inbounds i8, ptr %p, i64 -2049
126 store double %d, ptr %add.ptr, align 8
130 define void @foo6(ptr %p, double %d) nounwind {
131 ; RV32ZDINX-LABEL: foo6:
132 ; RV32ZDINX: # %bb.0: # %entry
133 ; RV32ZDINX-NEXT: lui a3, %hi(.LCPI5_0)
134 ; RV32ZDINX-NEXT: lw a4, %lo(.LCPI5_0)(a3)
135 ; RV32ZDINX-NEXT: lw a5, %lo(.LCPI5_0+4)(a3)
136 ; RV32ZDINX-NEXT: mv a3, a2
137 ; RV32ZDINX-NEXT: mv a2, a1
138 ; RV32ZDINX-NEXT: fadd.d a2, a2, a4
139 ; RV32ZDINX-NEXT: addi a0, a0, 2047
140 ; RV32ZDINX-NEXT: sw a2, -3(a0)
141 ; RV32ZDINX-NEXT: sw a3, 1(a0)
142 ; RV32ZDINX-NEXT: ret
144 ; RV64ZDINX-LABEL: foo6:
145 ; RV64ZDINX: # %bb.0: # %entry
146 ; RV64ZDINX-NEXT: lui a2, %hi(.LCPI5_0)
147 ; RV64ZDINX-NEXT: ld a2, %lo(.LCPI5_0)(a2)
148 ; RV64ZDINX-NEXT: fadd.d a1, a1, a2
149 ; RV64ZDINX-NEXT: sd a1, 2044(a0)
150 ; RV64ZDINX-NEXT: ret
152 %add = fadd double %d, 3.140000e+00
153 %add.ptr = getelementptr inbounds i8, ptr %p, i64 2044
154 store double %add, ptr %add.ptr, align 8