1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv64 < %s | FileCheck --check-prefix=RV64I %s
3 ; RUN: llc -mtriple=riscv32 < %s | FileCheck --check-prefix=RV32I %s
4 @var = external global i32
9 ; RV64I-NEXT: lui a0, 1
10 ; RV64I-NEXT: addiw a0, a0, 16
11 ; RV64I-NEXT: sub sp, sp, a0
12 ; RV64I-NEXT: .cfi_def_cfa_offset 4112
13 ; RV64I-NEXT: lui a0, %hi(var)
14 ; RV64I-NEXT: lw a1, %lo(var)(a0)
15 ; RV64I-NEXT: lw a2, %lo(var)(a0)
16 ; RV64I-NEXT: lw a3, %lo(var)(a0)
17 ; RV64I-NEXT: lw a4, %lo(var)(a0)
18 ; RV64I-NEXT: lw a5, %lo(var)(a0)
19 ; RV64I-NEXT: lw a6, %lo(var)(a0)
20 ; RV64I-NEXT: lw a7, %lo(var)(a0)
21 ; RV64I-NEXT: lw t0, %lo(var)(a0)
22 ; RV64I-NEXT: lw t1, %lo(var)(a0)
23 ; RV64I-NEXT: lw t2, %lo(var)(a0)
24 ; RV64I-NEXT: lw t3, %lo(var)(a0)
25 ; RV64I-NEXT: lw t4, %lo(var)(a0)
26 ; RV64I-NEXT: lw t5, %lo(var)(a0)
27 ; RV64I-NEXT: lw t6, %lo(var)(a0)
28 ; RV64I-NEXT: sd s0, 0(sp)
29 ; RV64I-NEXT: lui s0, 1
30 ; RV64I-NEXT: add s0, sp, s0
31 ; RV64I-NEXT: sw a1, 12(s0)
32 ; RV64I-NEXT: ld s0, 0(sp)
33 ; RV64I-NEXT: sw a1, %lo(var)(a0)
34 ; RV64I-NEXT: sw a2, %lo(var)(a0)
35 ; RV64I-NEXT: sw a3, %lo(var)(a0)
36 ; RV64I-NEXT: sw a4, %lo(var)(a0)
37 ; RV64I-NEXT: sw a5, %lo(var)(a0)
38 ; RV64I-NEXT: sw a6, %lo(var)(a0)
39 ; RV64I-NEXT: sw a7, %lo(var)(a0)
40 ; RV64I-NEXT: sw t0, %lo(var)(a0)
41 ; RV64I-NEXT: sw t1, %lo(var)(a0)
42 ; RV64I-NEXT: sw t2, %lo(var)(a0)
43 ; RV64I-NEXT: sw t3, %lo(var)(a0)
44 ; RV64I-NEXT: sw t4, %lo(var)(a0)
45 ; RV64I-NEXT: sw t5, %lo(var)(a0)
46 ; RV64I-NEXT: sw t6, %lo(var)(a0)
47 ; RV64I-NEXT: lui a0, 1
48 ; RV64I-NEXT: addiw a0, a0, 16
49 ; RV64I-NEXT: add sp, sp, a0
54 ; RV32I-NEXT: lui a0, 1
55 ; RV32I-NEXT: addi a0, a0, 16
56 ; RV32I-NEXT: sub sp, sp, a0
57 ; RV32I-NEXT: .cfi_def_cfa_offset 4112
58 ; RV32I-NEXT: lui a0, %hi(var)
59 ; RV32I-NEXT: lw a1, %lo(var)(a0)
60 ; RV32I-NEXT: lw a2, %lo(var)(a0)
61 ; RV32I-NEXT: lw a3, %lo(var)(a0)
62 ; RV32I-NEXT: lw a4, %lo(var)(a0)
63 ; RV32I-NEXT: lw a5, %lo(var)(a0)
64 ; RV32I-NEXT: lw a6, %lo(var)(a0)
65 ; RV32I-NEXT: lw a7, %lo(var)(a0)
66 ; RV32I-NEXT: lw t0, %lo(var)(a0)
67 ; RV32I-NEXT: lw t1, %lo(var)(a0)
68 ; RV32I-NEXT: lw t2, %lo(var)(a0)
69 ; RV32I-NEXT: lw t3, %lo(var)(a0)
70 ; RV32I-NEXT: lw t4, %lo(var)(a0)
71 ; RV32I-NEXT: lw t5, %lo(var)(a0)
72 ; RV32I-NEXT: lw t6, %lo(var)(a0)
73 ; RV32I-NEXT: sw s0, 0(sp)
74 ; RV32I-NEXT: lui s0, 1
75 ; RV32I-NEXT: add s0, sp, s0
76 ; RV32I-NEXT: sw a1, 12(s0)
77 ; RV32I-NEXT: lw s0, 0(sp)
78 ; RV32I-NEXT: sw a1, %lo(var)(a0)
79 ; RV32I-NEXT: sw a2, %lo(var)(a0)
80 ; RV32I-NEXT: sw a3, %lo(var)(a0)
81 ; RV32I-NEXT: sw a4, %lo(var)(a0)
82 ; RV32I-NEXT: sw a5, %lo(var)(a0)
83 ; RV32I-NEXT: sw a6, %lo(var)(a0)
84 ; RV32I-NEXT: sw a7, %lo(var)(a0)
85 ; RV32I-NEXT: sw t0, %lo(var)(a0)
86 ; RV32I-NEXT: sw t1, %lo(var)(a0)
87 ; RV32I-NEXT: sw t2, %lo(var)(a0)
88 ; RV32I-NEXT: sw t3, %lo(var)(a0)
89 ; RV32I-NEXT: sw t4, %lo(var)(a0)
90 ; RV32I-NEXT: sw t5, %lo(var)(a0)
91 ; RV32I-NEXT: sw t6, %lo(var)(a0)
92 ; RV32I-NEXT: lui a0, 1
93 ; RV32I-NEXT: addi a0, a0, 16
94 ; RV32I-NEXT: add sp, sp, a0
96 %space = alloca i32, align 4
97 %stackspace = alloca[1024 x i32], align 4
99 ;; Load values to increase register pressure.
100 %v0 = load volatile i32, ptr @var
101 %v1 = load volatile i32, ptr @var
102 %v2 = load volatile i32, ptr @var
103 %v3 = load volatile i32, ptr @var
104 %v4 = load volatile i32, ptr @var
105 %v5 = load volatile i32, ptr @var
106 %v6 = load volatile i32, ptr @var
107 %v7 = load volatile i32, ptr @var
108 %v8 = load volatile i32, ptr @var
109 %v9 = load volatile i32, ptr @var
110 %v10 = load volatile i32, ptr @var
111 %v11 = load volatile i32, ptr @var
112 %v12 = load volatile i32, ptr @var
113 %v13 = load volatile i32, ptr @var
115 store volatile i32 %v0, ptr %space
117 ;; store values so they are used.
118 store volatile i32 %v0, ptr @var
119 store volatile i32 %v1, ptr @var
120 store volatile i32 %v2, ptr @var
121 store volatile i32 %v3, ptr @var
122 store volatile i32 %v4, ptr @var
123 store volatile i32 %v5, ptr @var
124 store volatile i32 %v6, ptr @var
125 store volatile i32 %v7, ptr @var
126 store volatile i32 %v8, ptr @var
127 store volatile i32 %v9, ptr @var
128 store volatile i32 %v10, ptr @var
129 store volatile i32 %v11, ptr @var
130 store volatile i32 %v12, ptr @var
131 store volatile i32 %v13, ptr @var
136 define void @shrink_wrap(i1 %c) {
137 ; RV64I-LABEL: shrink_wrap:
139 ; RV64I-NEXT: andi a0, a0, 1
140 ; RV64I-NEXT: bnez a0, .LBB1_2
141 ; RV64I-NEXT: # %bb.1: # %bar
142 ; RV64I-NEXT: lui a0, 1
143 ; RV64I-NEXT: addiw a0, a0, 16
144 ; RV64I-NEXT: sub sp, sp, a0
145 ; RV64I-NEXT: .cfi_def_cfa_offset 4112
146 ; RV64I-NEXT: lui a0, %hi(var)
147 ; RV64I-NEXT: lw a1, %lo(var)(a0)
148 ; RV64I-NEXT: lw a2, %lo(var)(a0)
149 ; RV64I-NEXT: lw a3, %lo(var)(a0)
150 ; RV64I-NEXT: lw a4, %lo(var)(a0)
151 ; RV64I-NEXT: lw a5, %lo(var)(a0)
152 ; RV64I-NEXT: lw a6, %lo(var)(a0)
153 ; RV64I-NEXT: lw a7, %lo(var)(a0)
154 ; RV64I-NEXT: lw t0, %lo(var)(a0)
155 ; RV64I-NEXT: lw t1, %lo(var)(a0)
156 ; RV64I-NEXT: lw t2, %lo(var)(a0)
157 ; RV64I-NEXT: lw t3, %lo(var)(a0)
158 ; RV64I-NEXT: lw t4, %lo(var)(a0)
159 ; RV64I-NEXT: lw t5, %lo(var)(a0)
160 ; RV64I-NEXT: lw t6, %lo(var)(a0)
161 ; RV64I-NEXT: sd s0, 0(sp)
162 ; RV64I-NEXT: lui s0, 1
163 ; RV64I-NEXT: add s0, sp, s0
164 ; RV64I-NEXT: sw a1, 12(s0)
165 ; RV64I-NEXT: ld s0, 0(sp)
166 ; RV64I-NEXT: sw a1, %lo(var)(a0)
167 ; RV64I-NEXT: sw a2, %lo(var)(a0)
168 ; RV64I-NEXT: sw a3, %lo(var)(a0)
169 ; RV64I-NEXT: sw a4, %lo(var)(a0)
170 ; RV64I-NEXT: sw a5, %lo(var)(a0)
171 ; RV64I-NEXT: sw a6, %lo(var)(a0)
172 ; RV64I-NEXT: sw a7, %lo(var)(a0)
173 ; RV64I-NEXT: sw t0, %lo(var)(a0)
174 ; RV64I-NEXT: sw t1, %lo(var)(a0)
175 ; RV64I-NEXT: sw t2, %lo(var)(a0)
176 ; RV64I-NEXT: sw t3, %lo(var)(a0)
177 ; RV64I-NEXT: sw t4, %lo(var)(a0)
178 ; RV64I-NEXT: sw t5, %lo(var)(a0)
179 ; RV64I-NEXT: sw t6, %lo(var)(a0)
180 ; RV64I-NEXT: lui a0, 1
181 ; RV64I-NEXT: addiw a0, a0, 16
182 ; RV64I-NEXT: add sp, sp, a0
183 ; RV64I-NEXT: .LBB1_2: # %foo
186 ; RV32I-LABEL: shrink_wrap:
188 ; RV32I-NEXT: andi a0, a0, 1
189 ; RV32I-NEXT: bnez a0, .LBB1_2
190 ; RV32I-NEXT: # %bb.1: # %bar
191 ; RV32I-NEXT: lui a0, 1
192 ; RV32I-NEXT: addi a0, a0, 16
193 ; RV32I-NEXT: sub sp, sp, a0
194 ; RV32I-NEXT: .cfi_def_cfa_offset 4112
195 ; RV32I-NEXT: lui a0, %hi(var)
196 ; RV32I-NEXT: lw a1, %lo(var)(a0)
197 ; RV32I-NEXT: lw a2, %lo(var)(a0)
198 ; RV32I-NEXT: lw a3, %lo(var)(a0)
199 ; RV32I-NEXT: lw a4, %lo(var)(a0)
200 ; RV32I-NEXT: lw a5, %lo(var)(a0)
201 ; RV32I-NEXT: lw a6, %lo(var)(a0)
202 ; RV32I-NEXT: lw a7, %lo(var)(a0)
203 ; RV32I-NEXT: lw t0, %lo(var)(a0)
204 ; RV32I-NEXT: lw t1, %lo(var)(a0)
205 ; RV32I-NEXT: lw t2, %lo(var)(a0)
206 ; RV32I-NEXT: lw t3, %lo(var)(a0)
207 ; RV32I-NEXT: lw t4, %lo(var)(a0)
208 ; RV32I-NEXT: lw t5, %lo(var)(a0)
209 ; RV32I-NEXT: lw t6, %lo(var)(a0)
210 ; RV32I-NEXT: sw s0, 0(sp)
211 ; RV32I-NEXT: lui s0, 1
212 ; RV32I-NEXT: add s0, sp, s0
213 ; RV32I-NEXT: sw a1, 12(s0)
214 ; RV32I-NEXT: lw s0, 0(sp)
215 ; RV32I-NEXT: sw a1, %lo(var)(a0)
216 ; RV32I-NEXT: sw a2, %lo(var)(a0)
217 ; RV32I-NEXT: sw a3, %lo(var)(a0)
218 ; RV32I-NEXT: sw a4, %lo(var)(a0)
219 ; RV32I-NEXT: sw a5, %lo(var)(a0)
220 ; RV32I-NEXT: sw a6, %lo(var)(a0)
221 ; RV32I-NEXT: sw a7, %lo(var)(a0)
222 ; RV32I-NEXT: sw t0, %lo(var)(a0)
223 ; RV32I-NEXT: sw t1, %lo(var)(a0)
224 ; RV32I-NEXT: sw t2, %lo(var)(a0)
225 ; RV32I-NEXT: sw t3, %lo(var)(a0)
226 ; RV32I-NEXT: sw t4, %lo(var)(a0)
227 ; RV32I-NEXT: sw t5, %lo(var)(a0)
228 ; RV32I-NEXT: sw t6, %lo(var)(a0)
229 ; RV32I-NEXT: lui a0, 1
230 ; RV32I-NEXT: addi a0, a0, 16
231 ; RV32I-NEXT: add sp, sp, a0
232 ; RV32I-NEXT: .LBB1_2: # %foo
234 %space = alloca i32, align 4
235 %stackspace = alloca[1024 x i32], align 4
236 br i1 %c, label %foo, label %bar
240 ;; Load values to increase register pressure.
241 %v0 = load volatile i32, ptr @var
242 %v1 = load volatile i32, ptr @var
243 %v2 = load volatile i32, ptr @var
244 %v3 = load volatile i32, ptr @var
245 %v4 = load volatile i32, ptr @var
246 %v5 = load volatile i32, ptr @var
247 %v6 = load volatile i32, ptr @var
248 %v7 = load volatile i32, ptr @var
249 %v8 = load volatile i32, ptr @var
250 %v9 = load volatile i32, ptr @var
251 %v10 = load volatile i32, ptr @var
252 %v11 = load volatile i32, ptr @var
253 %v12 = load volatile i32, ptr @var
254 %v13 = load volatile i32, ptr @var
256 store volatile i32 %v0, ptr %space
258 ;; store values so they are used.
259 store volatile i32 %v0, ptr @var
260 store volatile i32 %v1, ptr @var
261 store volatile i32 %v2, ptr @var
262 store volatile i32 %v3, ptr @var
263 store volatile i32 %v4, ptr @var
264 store volatile i32 %v5, ptr @var
265 store volatile i32 %v6, ptr @var
266 store volatile i32 %v7, ptr @var
267 store volatile i32 %v8, ptr @var
268 store volatile i32 %v9, ptr @var
269 store volatile i32 %v10, ptr @var
270 store volatile i32 %v11, ptr @var
271 store volatile i32 %v12, ptr @var
272 store volatile i32 %v13, ptr @var