1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv32 -mattr=+d -mattr=+xtheadmemidx -mattr=+m -verify-machineinstrs < %s \
3 ; RUN: | FileCheck %s -check-prefix=RV32XTHEADMEMIDX
4 ; RUN: llc -mtriple=riscv64 -mattr=+d -mattr=+xtheadmemidx -mattr=+m -verify-machineinstrs < %s \
5 ; RUN: | FileCheck %s -check-prefix=RV64XTHEADMEMIDX
7 define ptr @lbia(ptr %base, ptr %addr.2, i8 %a) {
8 ; RV32XTHEADMEMIDX-LABEL: lbia:
9 ; RV32XTHEADMEMIDX: # %bb.0:
10 ; RV32XTHEADMEMIDX-NEXT: th.lbia a3, (a0), -1, 0
11 ; RV32XTHEADMEMIDX-NEXT: add a2, a3, a2
12 ; RV32XTHEADMEMIDX-NEXT: sb a2, 0(a1)
13 ; RV32XTHEADMEMIDX-NEXT: ret
15 ; RV64XTHEADMEMIDX-LABEL: lbia:
16 ; RV64XTHEADMEMIDX: # %bb.0:
17 ; RV64XTHEADMEMIDX-NEXT: th.lbia a3, (a0), -1, 0
18 ; RV64XTHEADMEMIDX-NEXT: add a2, a3, a2
19 ; RV64XTHEADMEMIDX-NEXT: sb a2, 0(a1)
20 ; RV64XTHEADMEMIDX-NEXT: ret
21 %addr = getelementptr i8, ptr %base, i8 0
22 %ld = load i8, ptr %addr
23 %addr.1 = getelementptr i8, ptr %base, i8 -1
25 store i8 %res, ptr %addr.2
29 define ptr @lbib(ptr %base, i8 %a) {
30 ; RV32XTHEADMEMIDX-LABEL: lbib:
31 ; RV32XTHEADMEMIDX: # %bb.0:
32 ; RV32XTHEADMEMIDX-NEXT: th.lbib a2, (a0), 1, 0
33 ; RV32XTHEADMEMIDX-NEXT: add a1, a2, a1
34 ; RV32XTHEADMEMIDX-NEXT: sb a1, 1(a0)
35 ; RV32XTHEADMEMIDX-NEXT: ret
37 ; RV64XTHEADMEMIDX-LABEL: lbib:
38 ; RV64XTHEADMEMIDX: # %bb.0:
39 ; RV64XTHEADMEMIDX-NEXT: th.lbib a2, (a0), 1, 0
40 ; RV64XTHEADMEMIDX-NEXT: add a1, a2, a1
41 ; RV64XTHEADMEMIDX-NEXT: sb a1, 1(a0)
42 ; RV64XTHEADMEMIDX-NEXT: ret
43 %addr = getelementptr i8, ptr %base, i8 1
44 %ld = load i8, ptr %addr
45 %addr.1 = getelementptr i8, ptr %base, i8 2
47 store i8 %res, ptr %addr.1
51 define ptr @lbuia(ptr %base, ptr %addr.2, i64 %a) {
52 ; RV32XTHEADMEMIDX-LABEL: lbuia:
53 ; RV32XTHEADMEMIDX: # %bb.0:
54 ; RV32XTHEADMEMIDX-NEXT: th.lbuia a4, (a0), -1, 0
55 ; RV32XTHEADMEMIDX-NEXT: add a2, a4, a2
56 ; RV32XTHEADMEMIDX-NEXT: sltu a4, a2, a4
57 ; RV32XTHEADMEMIDX-NEXT: add a3, a3, a4
58 ; RV32XTHEADMEMIDX-NEXT: sw a2, 0(a1)
59 ; RV32XTHEADMEMIDX-NEXT: sw a3, 4(a1)
60 ; RV32XTHEADMEMIDX-NEXT: ret
62 ; RV64XTHEADMEMIDX-LABEL: lbuia:
63 ; RV64XTHEADMEMIDX: # %bb.0:
64 ; RV64XTHEADMEMIDX-NEXT: th.lbuia a3, (a0), -1, 0
65 ; RV64XTHEADMEMIDX-NEXT: add a2, a3, a2
66 ; RV64XTHEADMEMIDX-NEXT: sd a2, 0(a1)
67 ; RV64XTHEADMEMIDX-NEXT: ret
68 %addr = getelementptr i8, ptr %base, i8 0
69 %ld = load i8, ptr %addr
70 %zext = zext i8 %ld to i64
71 %addr.1 = getelementptr i8, ptr %base, i8 -1
72 %res = add i64 %zext, %a
73 store i64 %res, ptr %addr.2
77 define ptr @lbuib(ptr %base, i64 %a, ptr %addr.1) {
78 ; RV32XTHEADMEMIDX-LABEL: lbuib:
79 ; RV32XTHEADMEMIDX: # %bb.0:
80 ; RV32XTHEADMEMIDX-NEXT: th.lbuib a4, (a0), 1, 0
81 ; RV32XTHEADMEMIDX-NEXT: add a1, a4, a1
82 ; RV32XTHEADMEMIDX-NEXT: sltu a4, a1, a4
83 ; RV32XTHEADMEMIDX-NEXT: add a2, a2, a4
84 ; RV32XTHEADMEMIDX-NEXT: sw a1, 0(a3)
85 ; RV32XTHEADMEMIDX-NEXT: sw a2, 4(a3)
86 ; RV32XTHEADMEMIDX-NEXT: ret
88 ; RV64XTHEADMEMIDX-LABEL: lbuib:
89 ; RV64XTHEADMEMIDX: # %bb.0:
90 ; RV64XTHEADMEMIDX-NEXT: th.lbuib a3, (a0), 1, 0
91 ; RV64XTHEADMEMIDX-NEXT: add a1, a3, a1
92 ; RV64XTHEADMEMIDX-NEXT: sd a1, 0(a2)
93 ; RV64XTHEADMEMIDX-NEXT: ret
94 %addr = getelementptr i8, ptr %base, i8 1
95 %ld = load i8, ptr %addr
96 %zext = zext i8 %ld to i64
97 %res = add i64 %zext, %a
98 store i64 %res, ptr %addr.1
102 define ptr @lhia(ptr %base, ptr %addr.2, i16 %a) {
103 ; RV32XTHEADMEMIDX-LABEL: lhia:
104 ; RV32XTHEADMEMIDX: # %bb.0:
105 ; RV32XTHEADMEMIDX-NEXT: th.lhia a3, (a0), -16, 1
106 ; RV32XTHEADMEMIDX-NEXT: add a2, a3, a2
107 ; RV32XTHEADMEMIDX-NEXT: sh a2, 0(a1)
108 ; RV32XTHEADMEMIDX-NEXT: ret
110 ; RV64XTHEADMEMIDX-LABEL: lhia:
111 ; RV64XTHEADMEMIDX: # %bb.0:
112 ; RV64XTHEADMEMIDX-NEXT: th.lhia a3, (a0), -16, 1
113 ; RV64XTHEADMEMIDX-NEXT: add a2, a3, a2
114 ; RV64XTHEADMEMIDX-NEXT: sh a2, 0(a1)
115 ; RV64XTHEADMEMIDX-NEXT: ret
116 %addr = getelementptr i16, ptr %base, i16 0
117 %ld = load i16, ptr %addr
118 %addr.1 = getelementptr i16, ptr %base, i16 -16
119 %res = add i16 %ld, %a
120 store i16 %res, ptr %addr.2
124 define ptr @lhib(ptr %base, i16 %a) {
125 ; RV32XTHEADMEMIDX-LABEL: lhib:
126 ; RV32XTHEADMEMIDX: # %bb.0:
127 ; RV32XTHEADMEMIDX-NEXT: th.lhib a2, (a0), 2, 0
128 ; RV32XTHEADMEMIDX-NEXT: add a1, a2, a1
129 ; RV32XTHEADMEMIDX-NEXT: sh a1, 2(a0)
130 ; RV32XTHEADMEMIDX-NEXT: ret
132 ; RV64XTHEADMEMIDX-LABEL: lhib:
133 ; RV64XTHEADMEMIDX: # %bb.0:
134 ; RV64XTHEADMEMIDX-NEXT: th.lhib a2, (a0), 2, 0
135 ; RV64XTHEADMEMIDX-NEXT: add a1, a2, a1
136 ; RV64XTHEADMEMIDX-NEXT: sh a1, 2(a0)
137 ; RV64XTHEADMEMIDX-NEXT: ret
138 %addr = getelementptr i16, ptr %base, i16 1
139 %ld = load i16, ptr %addr
140 %addr.1 = getelementptr i16, ptr %base, i16 2
141 %res = add i16 %ld, %a
142 store i16 %res, ptr %addr.1
146 define ptr @lhuia(ptr %base, ptr %addr.2, i64 %a) {
147 ; RV32XTHEADMEMIDX-LABEL: lhuia:
148 ; RV32XTHEADMEMIDX: # %bb.0:
149 ; RV32XTHEADMEMIDX-NEXT: th.lhuia a4, (a0), -16, 1
150 ; RV32XTHEADMEMIDX-NEXT: add a2, a4, a2
151 ; RV32XTHEADMEMIDX-NEXT: sltu a4, a2, a4
152 ; RV32XTHEADMEMIDX-NEXT: add a3, a3, a4
153 ; RV32XTHEADMEMIDX-NEXT: sw a2, 0(a1)
154 ; RV32XTHEADMEMIDX-NEXT: sw a3, 4(a1)
155 ; RV32XTHEADMEMIDX-NEXT: ret
157 ; RV64XTHEADMEMIDX-LABEL: lhuia:
158 ; RV64XTHEADMEMIDX: # %bb.0:
159 ; RV64XTHEADMEMIDX-NEXT: th.lhuia a3, (a0), -16, 1
160 ; RV64XTHEADMEMIDX-NEXT: add a2, a3, a2
161 ; RV64XTHEADMEMIDX-NEXT: sd a2, 0(a1)
162 ; RV64XTHEADMEMIDX-NEXT: ret
163 %addr = getelementptr i16, ptr %base, i16 0
164 %ld = load i16, ptr %addr
165 %zext = zext i16 %ld to i64
166 %addr.1 = getelementptr i16, ptr %base, i16 -16
167 %res = add i64 %zext, %a
168 store i64 %res, ptr %addr.2
172 define ptr @lhuib(ptr %base, i64 %a, ptr %addr.1) {
173 ; RV32XTHEADMEMIDX-LABEL: lhuib:
174 ; RV32XTHEADMEMIDX: # %bb.0:
175 ; RV32XTHEADMEMIDX-NEXT: th.lhuib a4, (a0), 2, 0
176 ; RV32XTHEADMEMIDX-NEXT: add a1, a4, a1
177 ; RV32XTHEADMEMIDX-NEXT: sltu a4, a1, a4
178 ; RV32XTHEADMEMIDX-NEXT: add a2, a2, a4
179 ; RV32XTHEADMEMIDX-NEXT: sw a1, 0(a3)
180 ; RV32XTHEADMEMIDX-NEXT: sw a2, 4(a3)
181 ; RV32XTHEADMEMIDX-NEXT: ret
183 ; RV64XTHEADMEMIDX-LABEL: lhuib:
184 ; RV64XTHEADMEMIDX: # %bb.0:
185 ; RV64XTHEADMEMIDX-NEXT: th.lhuib a3, (a0), 2, 0
186 ; RV64XTHEADMEMIDX-NEXT: add a1, a3, a1
187 ; RV64XTHEADMEMIDX-NEXT: sd a1, 0(a2)
188 ; RV64XTHEADMEMIDX-NEXT: ret
189 %addr = getelementptr i16, ptr %base, i16 1
190 %ld = load i16, ptr %addr
191 %zext = zext i16 %ld to i64
192 %res = add i64 %zext, %a
193 store i64 %res, ptr %addr.1
197 define ptr @lwia(ptr %base, ptr %addr.2, i32 %a) {
198 ; RV32XTHEADMEMIDX-LABEL: lwia:
199 ; RV32XTHEADMEMIDX: # %bb.0:
200 ; RV32XTHEADMEMIDX-NEXT: th.lwia a3, (a0), -16, 2
201 ; RV32XTHEADMEMIDX-NEXT: add a2, a3, a2
202 ; RV32XTHEADMEMIDX-NEXT: sw a2, 0(a1)
203 ; RV32XTHEADMEMIDX-NEXT: ret
205 ; RV64XTHEADMEMIDX-LABEL: lwia:
206 ; RV64XTHEADMEMIDX: # %bb.0:
207 ; RV64XTHEADMEMIDX-NEXT: th.lwia a3, (a0), -16, 2
208 ; RV64XTHEADMEMIDX-NEXT: add a2, a3, a2
209 ; RV64XTHEADMEMIDX-NEXT: sw a2, 0(a1)
210 ; RV64XTHEADMEMIDX-NEXT: ret
211 %addr = getelementptr i32, ptr %base, i32 0
212 %ld = load i32, ptr %addr
213 %addr.1 = getelementptr i32, ptr %base, i32 -16
214 %res = add i32 %ld, %a
215 store i32 %res, ptr %addr.2
219 define ptr @lwib(ptr %base, i32 %a) {
220 ; RV32XTHEADMEMIDX-LABEL: lwib:
221 ; RV32XTHEADMEMIDX: # %bb.0:
222 ; RV32XTHEADMEMIDX-NEXT: th.lwib a2, (a0), 4, 0
223 ; RV32XTHEADMEMIDX-NEXT: add a1, a2, a1
224 ; RV32XTHEADMEMIDX-NEXT: sw a1, 4(a0)
225 ; RV32XTHEADMEMIDX-NEXT: ret
227 ; RV64XTHEADMEMIDX-LABEL: lwib:
228 ; RV64XTHEADMEMIDX: # %bb.0:
229 ; RV64XTHEADMEMIDX-NEXT: th.lwib a2, (a0), 4, 0
230 ; RV64XTHEADMEMIDX-NEXT: add a1, a2, a1
231 ; RV64XTHEADMEMIDX-NEXT: sw a1, 4(a0)
232 ; RV64XTHEADMEMIDX-NEXT: ret
233 %addr = getelementptr i32, ptr %base, i32 1
234 %ld = load i32, ptr %addr
235 %addr.1 = getelementptr i32, ptr %base, i32 2
236 %res = add i32 %ld, %a
237 store i32 %res, ptr %addr.1
241 define ptr @lwuia(ptr %base, ptr %addr.2, i64 %a) {
242 ; RV32XTHEADMEMIDX-LABEL: lwuia:
243 ; RV32XTHEADMEMIDX: # %bb.0:
244 ; RV32XTHEADMEMIDX-NEXT: th.lwia a4, (a0), -16, 2
245 ; RV32XTHEADMEMIDX-NEXT: add a2, a4, a2
246 ; RV32XTHEADMEMIDX-NEXT: sltu a4, a2, a4
247 ; RV32XTHEADMEMIDX-NEXT: add a3, a3, a4
248 ; RV32XTHEADMEMIDX-NEXT: sw a2, 0(a1)
249 ; RV32XTHEADMEMIDX-NEXT: sw a3, 4(a1)
250 ; RV32XTHEADMEMIDX-NEXT: ret
252 ; RV64XTHEADMEMIDX-LABEL: lwuia:
253 ; RV64XTHEADMEMIDX: # %bb.0:
254 ; RV64XTHEADMEMIDX-NEXT: th.lwuia a3, (a0), -16, 2
255 ; RV64XTHEADMEMIDX-NEXT: add a2, a3, a2
256 ; RV64XTHEADMEMIDX-NEXT: sd a2, 0(a1)
257 ; RV64XTHEADMEMIDX-NEXT: ret
258 %addr = getelementptr i32, ptr %base, i32 0
259 %ld = load i32, ptr %addr
260 %zext = zext i32 %ld to i64
261 %addr.1 = getelementptr i32, ptr %base, i32 -16
262 %res = add i64 %zext, %a
263 store i64 %res, ptr %addr.2
267 define ptr @lwuib(ptr %base, i64 %a, ptr %addr.1) {
268 ; RV32XTHEADMEMIDX-LABEL: lwuib:
269 ; RV32XTHEADMEMIDX: # %bb.0:
270 ; RV32XTHEADMEMIDX-NEXT: th.lwib a4, (a0), 4, 0
271 ; RV32XTHEADMEMIDX-NEXT: add a1, a4, a1
272 ; RV32XTHEADMEMIDX-NEXT: sltu a4, a1, a4
273 ; RV32XTHEADMEMIDX-NEXT: add a2, a2, a4
274 ; RV32XTHEADMEMIDX-NEXT: sw a1, 0(a3)
275 ; RV32XTHEADMEMIDX-NEXT: sw a2, 4(a3)
276 ; RV32XTHEADMEMIDX-NEXT: ret
278 ; RV64XTHEADMEMIDX-LABEL: lwuib:
279 ; RV64XTHEADMEMIDX: # %bb.0:
280 ; RV64XTHEADMEMIDX-NEXT: th.lwuib a3, (a0), 4, 0
281 ; RV64XTHEADMEMIDX-NEXT: add a1, a3, a1
282 ; RV64XTHEADMEMIDX-NEXT: sd a1, 0(a2)
283 ; RV64XTHEADMEMIDX-NEXT: ret
284 %addr = getelementptr i32, ptr %base, i32 1
285 %ld = load i32, ptr %addr
286 %zext = zext i32 %ld to i64
287 %res = add i64 %zext, %a
288 store i64 %res, ptr %addr.1
292 define ptr @ldia(ptr %base, ptr %addr.2, i64 %a) {
293 ; RV32XTHEADMEMIDX-LABEL: ldia:
294 ; RV32XTHEADMEMIDX: # %bb.0:
295 ; RV32XTHEADMEMIDX-NEXT: lw a4, 4(a0)
296 ; RV32XTHEADMEMIDX-NEXT: lw a5, 0(a0)
297 ; RV32XTHEADMEMIDX-NEXT: addi a0, a0, -128
298 ; RV32XTHEADMEMIDX-NEXT: add a3, a4, a3
299 ; RV32XTHEADMEMIDX-NEXT: add a2, a5, a2
300 ; RV32XTHEADMEMIDX-NEXT: sltu a4, a2, a5
301 ; RV32XTHEADMEMIDX-NEXT: add a3, a3, a4
302 ; RV32XTHEADMEMIDX-NEXT: sw a2, 0(a1)
303 ; RV32XTHEADMEMIDX-NEXT: sw a3, 4(a1)
304 ; RV32XTHEADMEMIDX-NEXT: ret
306 ; RV64XTHEADMEMIDX-LABEL: ldia:
307 ; RV64XTHEADMEMIDX: # %bb.0:
308 ; RV64XTHEADMEMIDX-NEXT: th.ldia a3, (a0), -16, 3
309 ; RV64XTHEADMEMIDX-NEXT: add a2, a3, a2
310 ; RV64XTHEADMEMIDX-NEXT: sd a2, 0(a1)
311 ; RV64XTHEADMEMIDX-NEXT: ret
312 %addr = getelementptr i64, ptr %base, i64 0
313 %ld = load i64, ptr %addr
314 %addr.1 = getelementptr i64, ptr %base, i64 -16
315 %res = add i64 %ld, %a
316 store i64 %res, ptr %addr.2
320 define ptr @ldib(ptr %base, i64 %a) {
321 ; RV32XTHEADMEMIDX-LABEL: ldib:
322 ; RV32XTHEADMEMIDX: # %bb.0:
323 ; RV32XTHEADMEMIDX-NEXT: th.lwib a3, (a0), 8, 0
324 ; RV32XTHEADMEMIDX-NEXT: lw a4, 4(a0)
325 ; RV32XTHEADMEMIDX-NEXT: add a1, a3, a1
326 ; RV32XTHEADMEMIDX-NEXT: sltu a3, a1, a3
327 ; RV32XTHEADMEMIDX-NEXT: add a2, a2, a3
328 ; RV32XTHEADMEMIDX-NEXT: add a2, a4, a2
329 ; RV32XTHEADMEMIDX-NEXT: sw a1, 8(a0)
330 ; RV32XTHEADMEMIDX-NEXT: sw a2, 12(a0)
331 ; RV32XTHEADMEMIDX-NEXT: ret
333 ; RV64XTHEADMEMIDX-LABEL: ldib:
334 ; RV64XTHEADMEMIDX: # %bb.0:
335 ; RV64XTHEADMEMIDX-NEXT: th.ldib a2, (a0), 8, 0
336 ; RV64XTHEADMEMIDX-NEXT: add a1, a2, a1
337 ; RV64XTHEADMEMIDX-NEXT: sd a1, 8(a0)
338 ; RV64XTHEADMEMIDX-NEXT: ret
339 %addr = getelementptr i64, ptr %base, i64 1
340 %ld = load i64, ptr %addr
341 %addr.1 = getelementptr i64, ptr %base, i64 2
342 %res = add i64 %ld, %a
343 store i64 %res, ptr %addr.1
347 define ptr @sbia(ptr %base, i8 %a, i8 %b) {
348 ; RV32XTHEADMEMIDX-LABEL: sbia:
349 ; RV32XTHEADMEMIDX: # %bb.0:
350 ; RV32XTHEADMEMIDX-NEXT: add a1, a1, a2
351 ; RV32XTHEADMEMIDX-NEXT: th.sbia a1, (a0), 1, 0
352 ; RV32XTHEADMEMIDX-NEXT: ret
354 ; RV64XTHEADMEMIDX-LABEL: sbia:
355 ; RV64XTHEADMEMIDX: # %bb.0:
356 ; RV64XTHEADMEMIDX-NEXT: add a1, a1, a2
357 ; RV64XTHEADMEMIDX-NEXT: th.sbia a1, (a0), 1, 0
358 ; RV64XTHEADMEMIDX-NEXT: ret
359 %addr.1 = getelementptr i8, ptr %base, i8 1
361 store i8 %res, ptr %base
365 define ptr @sbib(ptr %base, i8 %a, i8 %b) {
366 ; RV32XTHEADMEMIDX-LABEL: sbib:
367 ; RV32XTHEADMEMIDX: # %bb.0:
368 ; RV32XTHEADMEMIDX-NEXT: add a1, a1, a2
369 ; RV32XTHEADMEMIDX-NEXT: th.sbib a1, (a0), 1, 0
370 ; RV32XTHEADMEMIDX-NEXT: ret
372 ; RV64XTHEADMEMIDX-LABEL: sbib:
373 ; RV64XTHEADMEMIDX: # %bb.0:
374 ; RV64XTHEADMEMIDX-NEXT: add a1, a1, a2
375 ; RV64XTHEADMEMIDX-NEXT: th.sbib a1, (a0), 1, 0
376 ; RV64XTHEADMEMIDX-NEXT: ret
377 %addr.1 = getelementptr i8, ptr %base, i8 1
379 store i8 %res, ptr %addr.1
383 define ptr @shia(ptr %base, i16 %a, i16 %b) {
384 ; RV32XTHEADMEMIDX-LABEL: shia:
385 ; RV32XTHEADMEMIDX: # %bb.0:
386 ; RV32XTHEADMEMIDX-NEXT: add a1, a1, a2
387 ; RV32XTHEADMEMIDX-NEXT: th.shia a1, (a0), -9, 1
388 ; RV32XTHEADMEMIDX-NEXT: ret
390 ; RV64XTHEADMEMIDX-LABEL: shia:
391 ; RV64XTHEADMEMIDX: # %bb.0:
392 ; RV64XTHEADMEMIDX-NEXT: add a1, a1, a2
393 ; RV64XTHEADMEMIDX-NEXT: th.shia a1, (a0), -9, 1
394 ; RV64XTHEADMEMIDX-NEXT: ret
395 %addr.1 = getelementptr i16, ptr %base, i16 -9
396 %res = add i16 %a, %b
397 store i16 %res, ptr %base
401 define ptr @shib(ptr %base, i16 %a, i16 %b) {
402 ; RV32XTHEADMEMIDX-LABEL: shib:
403 ; RV32XTHEADMEMIDX: # %bb.0:
404 ; RV32XTHEADMEMIDX-NEXT: add a1, a1, a2
405 ; RV32XTHEADMEMIDX-NEXT: th.shib a1, (a0), 2, 0
406 ; RV32XTHEADMEMIDX-NEXT: ret
408 ; RV64XTHEADMEMIDX-LABEL: shib:
409 ; RV64XTHEADMEMIDX: # %bb.0:
410 ; RV64XTHEADMEMIDX-NEXT: add a1, a1, a2
411 ; RV64XTHEADMEMIDX-NEXT: th.shib a1, (a0), 2, 0
412 ; RV64XTHEADMEMIDX-NEXT: ret
413 %addr.1 = getelementptr i16, ptr %base, i16 1
414 %res = add i16 %a, %b
415 store i16 %res, ptr %addr.1
419 define ptr @swia(ptr %base, i32 %a, i32 %b) {
420 ; RV32XTHEADMEMIDX-LABEL: swia:
421 ; RV32XTHEADMEMIDX: # %bb.0:
422 ; RV32XTHEADMEMIDX-NEXT: add a1, a1, a2
423 ; RV32XTHEADMEMIDX-NEXT: th.swia a1, (a0), 8, 2
424 ; RV32XTHEADMEMIDX-NEXT: ret
426 ; RV64XTHEADMEMIDX-LABEL: swia:
427 ; RV64XTHEADMEMIDX: # %bb.0:
428 ; RV64XTHEADMEMIDX-NEXT: add a1, a1, a2
429 ; RV64XTHEADMEMIDX-NEXT: th.swia a1, (a0), 8, 2
430 ; RV64XTHEADMEMIDX-NEXT: ret
431 %addr.1 = getelementptr i32, ptr %base, i32 8
432 %res = add i32 %a, %b
433 store i32 %res, ptr %base
437 define ptr @swib(ptr %base, i32 %a, i32 %b) {
438 ; RV32XTHEADMEMIDX-LABEL: swib:
439 ; RV32XTHEADMEMIDX: # %bb.0:
440 ; RV32XTHEADMEMIDX-NEXT: add a1, a1, a2
441 ; RV32XTHEADMEMIDX-NEXT: th.swib a1, (a0), -13, 3
442 ; RV32XTHEADMEMIDX-NEXT: ret
444 ; RV64XTHEADMEMIDX-LABEL: swib:
445 ; RV64XTHEADMEMIDX: # %bb.0:
446 ; RV64XTHEADMEMIDX-NEXT: add a1, a1, a2
447 ; RV64XTHEADMEMIDX-NEXT: th.swib a1, (a0), -13, 3
448 ; RV64XTHEADMEMIDX-NEXT: ret
449 %addr.1 = getelementptr i32, ptr %base, i32 -26
450 %res = add i32 %a, %b
451 store i32 %res, ptr %addr.1
455 define ptr @sdia(ptr %base, i64 %a, i64 %b) {
456 ; RV32XTHEADMEMIDX-LABEL: sdia:
457 ; RV32XTHEADMEMIDX: # %bb.0:
458 ; RV32XTHEADMEMIDX-NEXT: addi a5, a0, 64
459 ; RV32XTHEADMEMIDX-NEXT: add a2, a2, a4
460 ; RV32XTHEADMEMIDX-NEXT: add a3, a1, a3
461 ; RV32XTHEADMEMIDX-NEXT: sltu a1, a3, a1
462 ; RV32XTHEADMEMIDX-NEXT: add a1, a2, a1
463 ; RV32XTHEADMEMIDX-NEXT: sw a3, 0(a0)
464 ; RV32XTHEADMEMIDX-NEXT: sw a1, 4(a0)
465 ; RV32XTHEADMEMIDX-NEXT: mv a0, a5
466 ; RV32XTHEADMEMIDX-NEXT: ret
468 ; RV64XTHEADMEMIDX-LABEL: sdia:
469 ; RV64XTHEADMEMIDX: # %bb.0:
470 ; RV64XTHEADMEMIDX-NEXT: add a1, a1, a2
471 ; RV64XTHEADMEMIDX-NEXT: th.sdia a1, (a0), 8, 3
472 ; RV64XTHEADMEMIDX-NEXT: ret
473 %addr.1 = getelementptr i64, ptr %base, i64 8
474 %res = add i64 %a, %b
475 store i64 %res, ptr %base
479 define ptr @sdib(ptr %base, i64 %a, i64 %b) {
480 ; RV32XTHEADMEMIDX-LABEL: sdib:
481 ; RV32XTHEADMEMIDX: # %bb.0:
482 ; RV32XTHEADMEMIDX-NEXT: add a2, a2, a4
483 ; RV32XTHEADMEMIDX-NEXT: add a3, a1, a3
484 ; RV32XTHEADMEMIDX-NEXT: sltu a1, a3, a1
485 ; RV32XTHEADMEMIDX-NEXT: add a1, a2, a1
486 ; RV32XTHEADMEMIDX-NEXT: th.swib a3, (a0), 8, 0
487 ; RV32XTHEADMEMIDX-NEXT: sw a1, 4(a0)
488 ; RV32XTHEADMEMIDX-NEXT: ret
490 ; RV64XTHEADMEMIDX-LABEL: sdib:
491 ; RV64XTHEADMEMIDX: # %bb.0:
492 ; RV64XTHEADMEMIDX-NEXT: add a1, a1, a2
493 ; RV64XTHEADMEMIDX-NEXT: th.sdib a1, (a0), 8, 0
494 ; RV64XTHEADMEMIDX-NEXT: ret
495 %addr.1 = getelementptr i64, ptr %base, i64 1
496 %res = add i64 %a, %b
497 store i64 %res, ptr %addr.1
501 define i8 @lrb_anyext(ptr %a, i64 %b) {
502 ; RV32XTHEADMEMIDX-LABEL: lrb_anyext:
503 ; RV32XTHEADMEMIDX: # %bb.0:
504 ; RV32XTHEADMEMIDX-NEXT: th.lrb a0, a0, a1, 0
505 ; RV32XTHEADMEMIDX-NEXT: ret
507 ; RV64XTHEADMEMIDX-LABEL: lrb_anyext:
508 ; RV64XTHEADMEMIDX: # %bb.0:
509 ; RV64XTHEADMEMIDX-NEXT: th.lrb a0, a0, a1, 0
510 ; RV64XTHEADMEMIDX-NEXT: ret
511 %1 = getelementptr i8, ptr %a, i64 %b
512 %2 = load i8, ptr %1, align 1
516 define i64 @lrb(ptr %a, i64 %b) {
517 ; RV32XTHEADMEMIDX-LABEL: lrb:
518 ; RV32XTHEADMEMIDX: # %bb.0:
519 ; RV32XTHEADMEMIDX-NEXT: th.lrb a1, a0, a1, 0
520 ; RV32XTHEADMEMIDX-NEXT: srai a2, a1, 31
521 ; RV32XTHEADMEMIDX-NEXT: add a0, a1, a1
522 ; RV32XTHEADMEMIDX-NEXT: sltu a1, a0, a1
523 ; RV32XTHEADMEMIDX-NEXT: add a2, a2, a2
524 ; RV32XTHEADMEMIDX-NEXT: add a1, a2, a1
525 ; RV32XTHEADMEMIDX-NEXT: ret
527 ; RV64XTHEADMEMIDX-LABEL: lrb:
528 ; RV64XTHEADMEMIDX: # %bb.0:
529 ; RV64XTHEADMEMIDX-NEXT: th.lrb a0, a0, a1, 0
530 ; RV64XTHEADMEMIDX-NEXT: add a0, a0, a0
531 ; RV64XTHEADMEMIDX-NEXT: ret
532 %1 = getelementptr i8, ptr %a, i64 %b
533 %2 = load i8, ptr %1, align 1
534 %3 = sext i8 %2 to i64
539 define i8 @lurb_anyext(ptr %a, i32 %b) {
540 ; RV32XTHEADMEMIDX-LABEL: lurb_anyext:
541 ; RV32XTHEADMEMIDX: # %bb.0:
542 ; RV32XTHEADMEMIDX-NEXT: th.lrb a0, a0, a1, 0
543 ; RV32XTHEADMEMIDX-NEXT: ret
545 ; RV64XTHEADMEMIDX-LABEL: lurb_anyext:
546 ; RV64XTHEADMEMIDX: # %bb.0:
547 ; RV64XTHEADMEMIDX-NEXT: th.lurb a0, a0, a1, 0
548 ; RV64XTHEADMEMIDX-NEXT: ret
549 %1 = zext i32 %b to i64
550 %2 = getelementptr i8, ptr %a, i64 %1
551 %3 = load i8, ptr %2, align 1
555 define i64 @lurb(ptr %a, i32 %b) {
556 ; RV32XTHEADMEMIDX-LABEL: lurb:
557 ; RV32XTHEADMEMIDX: # %bb.0:
558 ; RV32XTHEADMEMIDX-NEXT: th.lrb a1, a0, a1, 0
559 ; RV32XTHEADMEMIDX-NEXT: srai a2, a1, 31
560 ; RV32XTHEADMEMIDX-NEXT: add a0, a1, a1
561 ; RV32XTHEADMEMIDX-NEXT: sltu a1, a0, a1
562 ; RV32XTHEADMEMIDX-NEXT: add a2, a2, a2
563 ; RV32XTHEADMEMIDX-NEXT: add a1, a2, a1
564 ; RV32XTHEADMEMIDX-NEXT: ret
566 ; RV64XTHEADMEMIDX-LABEL: lurb:
567 ; RV64XTHEADMEMIDX: # %bb.0:
568 ; RV64XTHEADMEMIDX-NEXT: th.lurb a0, a0, a1, 0
569 ; RV64XTHEADMEMIDX-NEXT: add a0, a0, a0
570 ; RV64XTHEADMEMIDX-NEXT: ret
571 %1 = zext i32 %b to i64
572 %2 = getelementptr i8, ptr %a, i64 %1
573 %3 = load i8, ptr %2, align 1
574 %4 = sext i8 %3 to i64
579 define i64 @lrbu(ptr %a, i64 %b) {
580 ; RV32XTHEADMEMIDX-LABEL: lrbu:
581 ; RV32XTHEADMEMIDX: # %bb.0:
582 ; RV32XTHEADMEMIDX-NEXT: th.lrbu a1, a0, a1, 0
583 ; RV32XTHEADMEMIDX-NEXT: add a0, a1, a1
584 ; RV32XTHEADMEMIDX-NEXT: sltu a1, a0, a1
585 ; RV32XTHEADMEMIDX-NEXT: ret
587 ; RV64XTHEADMEMIDX-LABEL: lrbu:
588 ; RV64XTHEADMEMIDX: # %bb.0:
589 ; RV64XTHEADMEMIDX-NEXT: th.lrbu a0, a0, a1, 0
590 ; RV64XTHEADMEMIDX-NEXT: add a0, a0, a0
591 ; RV64XTHEADMEMIDX-NEXT: ret
592 %1 = getelementptr i8, ptr %a, i64 %b
593 %2 = load i8, ptr %1, align 1
594 %3 = zext i8 %2 to i64
599 define i64 @lurbu(ptr %a, i32 %b) {
600 ; RV32XTHEADMEMIDX-LABEL: lurbu:
601 ; RV32XTHEADMEMIDX: # %bb.0:
602 ; RV32XTHEADMEMIDX-NEXT: th.lrbu a1, a0, a1, 0
603 ; RV32XTHEADMEMIDX-NEXT: add a0, a1, a1
604 ; RV32XTHEADMEMIDX-NEXT: sltu a1, a0, a1
605 ; RV32XTHEADMEMIDX-NEXT: ret
607 ; RV64XTHEADMEMIDX-LABEL: lurbu:
608 ; RV64XTHEADMEMIDX: # %bb.0:
609 ; RV64XTHEADMEMIDX-NEXT: th.lurbu a0, a0, a1, 0
610 ; RV64XTHEADMEMIDX-NEXT: add a0, a0, a0
611 ; RV64XTHEADMEMIDX-NEXT: ret
612 %1 = zext i32 %b to i64
613 %2 = getelementptr i8, ptr %a, i64 %1
614 %3 = load i8, ptr %2, align 1
615 %4 = zext i8 %3 to i64
620 define i16 @lrh_anyext(ptr %a, i64 %b) {
621 ; RV32XTHEADMEMIDX-LABEL: lrh_anyext:
622 ; RV32XTHEADMEMIDX: # %bb.0:
623 ; RV32XTHEADMEMIDX-NEXT: th.lrh a0, a0, a1, 1
624 ; RV32XTHEADMEMIDX-NEXT: ret
626 ; RV64XTHEADMEMIDX-LABEL: lrh_anyext:
627 ; RV64XTHEADMEMIDX: # %bb.0:
628 ; RV64XTHEADMEMIDX-NEXT: th.lrh a0, a0, a1, 1
629 ; RV64XTHEADMEMIDX-NEXT: ret
630 %1 = getelementptr i16, ptr %a, i64 %b
631 %2 = load i16, ptr %1, align 2
635 define i64 @lrh(ptr %a, i64 %b) {
636 ; RV32XTHEADMEMIDX-LABEL: lrh:
637 ; RV32XTHEADMEMIDX: # %bb.0:
638 ; RV32XTHEADMEMIDX-NEXT: th.lrh a1, a0, a1, 1
639 ; RV32XTHEADMEMIDX-NEXT: srai a2, a1, 31
640 ; RV32XTHEADMEMIDX-NEXT: add a0, a1, a1
641 ; RV32XTHEADMEMIDX-NEXT: sltu a1, a0, a1
642 ; RV32XTHEADMEMIDX-NEXT: add a2, a2, a2
643 ; RV32XTHEADMEMIDX-NEXT: add a1, a2, a1
644 ; RV32XTHEADMEMIDX-NEXT: ret
646 ; RV64XTHEADMEMIDX-LABEL: lrh:
647 ; RV64XTHEADMEMIDX: # %bb.0:
648 ; RV64XTHEADMEMIDX-NEXT: th.lrh a0, a0, a1, 1
649 ; RV64XTHEADMEMIDX-NEXT: add a0, a0, a0
650 ; RV64XTHEADMEMIDX-NEXT: ret
651 %1 = getelementptr i16, ptr %a, i64 %b
652 %2 = load i16, ptr %1, align 2
653 %3 = sext i16 %2 to i64
658 define i16 @lurh_anyext(ptr %a, i32 %b) {
659 ; RV32XTHEADMEMIDX-LABEL: lurh_anyext:
660 ; RV32XTHEADMEMIDX: # %bb.0:
661 ; RV32XTHEADMEMIDX-NEXT: th.lrh a0, a0, a1, 1
662 ; RV32XTHEADMEMIDX-NEXT: ret
664 ; RV64XTHEADMEMIDX-LABEL: lurh_anyext:
665 ; RV64XTHEADMEMIDX: # %bb.0:
666 ; RV64XTHEADMEMIDX-NEXT: th.lurh a0, a0, a1, 1
667 ; RV64XTHEADMEMIDX-NEXT: ret
668 %1 = zext i32 %b to i64
669 %2 = getelementptr i16, ptr %a, i64 %1
670 %3 = load i16, ptr %2, align 2
674 define i64 @lurh(ptr %a, i32 %b) {
675 ; RV32XTHEADMEMIDX-LABEL: lurh:
676 ; RV32XTHEADMEMIDX: # %bb.0:
677 ; RV32XTHEADMEMIDX-NEXT: th.lrh a1, a0, a1, 1
678 ; RV32XTHEADMEMIDX-NEXT: srai a2, a1, 31
679 ; RV32XTHEADMEMIDX-NEXT: add a0, a1, a1
680 ; RV32XTHEADMEMIDX-NEXT: sltu a1, a0, a1
681 ; RV32XTHEADMEMIDX-NEXT: add a2, a2, a2
682 ; RV32XTHEADMEMIDX-NEXT: add a1, a2, a1
683 ; RV32XTHEADMEMIDX-NEXT: ret
685 ; RV64XTHEADMEMIDX-LABEL: lurh:
686 ; RV64XTHEADMEMIDX: # %bb.0:
687 ; RV64XTHEADMEMIDX-NEXT: th.lurh a0, a0, a1, 1
688 ; RV64XTHEADMEMIDX-NEXT: add a0, a0, a0
689 ; RV64XTHEADMEMIDX-NEXT: ret
690 %1 = zext i32 %b to i64
691 %2 = getelementptr i16, ptr %a, i64 %1
692 %3 = load i16, ptr %2, align 2
693 %4 = sext i16 %3 to i64
698 define i64 @lrhu(ptr %a, i64 %b) {
699 ; RV32XTHEADMEMIDX-LABEL: lrhu:
700 ; RV32XTHEADMEMIDX: # %bb.0:
701 ; RV32XTHEADMEMIDX-NEXT: th.lrhu a1, a0, a1, 1
702 ; RV32XTHEADMEMIDX-NEXT: add a0, a1, a1
703 ; RV32XTHEADMEMIDX-NEXT: sltu a1, a0, a1
704 ; RV32XTHEADMEMIDX-NEXT: ret
706 ; RV64XTHEADMEMIDX-LABEL: lrhu:
707 ; RV64XTHEADMEMIDX: # %bb.0:
708 ; RV64XTHEADMEMIDX-NEXT: th.lrhu a0, a0, a1, 1
709 ; RV64XTHEADMEMIDX-NEXT: add a0, a0, a0
710 ; RV64XTHEADMEMIDX-NEXT: ret
711 %1 = getelementptr i16, ptr %a, i64 %b
712 %2 = load i16, ptr %1, align 2
713 %3 = zext i16 %2 to i64
718 define i64 @lurhu(ptr %a, i32 %b) {
719 ; RV32XTHEADMEMIDX-LABEL: lurhu:
720 ; RV32XTHEADMEMIDX: # %bb.0:
721 ; RV32XTHEADMEMIDX-NEXT: th.lrhu a1, a0, a1, 1
722 ; RV32XTHEADMEMIDX-NEXT: add a0, a1, a1
723 ; RV32XTHEADMEMIDX-NEXT: sltu a1, a0, a1
724 ; RV32XTHEADMEMIDX-NEXT: ret
726 ; RV64XTHEADMEMIDX-LABEL: lurhu:
727 ; RV64XTHEADMEMIDX: # %bb.0:
728 ; RV64XTHEADMEMIDX-NEXT: th.lurhu a0, a0, a1, 1
729 ; RV64XTHEADMEMIDX-NEXT: add a0, a0, a0
730 ; RV64XTHEADMEMIDX-NEXT: ret
731 %1 = zext i32 %b to i64
732 %2 = getelementptr i16, ptr %a, i64 %1
733 %3 = load i16, ptr %2, align 2
734 %4 = zext i16 %3 to i64
739 define i32 @lrw_anyext(ptr %a, i64 %b) {
740 ; RV32XTHEADMEMIDX-LABEL: lrw_anyext:
741 ; RV32XTHEADMEMIDX: # %bb.0:
742 ; RV32XTHEADMEMIDX-NEXT: th.lrw a0, a0, a1, 2
743 ; RV32XTHEADMEMIDX-NEXT: ret
745 ; RV64XTHEADMEMIDX-LABEL: lrw_anyext:
746 ; RV64XTHEADMEMIDX: # %bb.0:
747 ; RV64XTHEADMEMIDX-NEXT: th.lrw a0, a0, a1, 2
748 ; RV64XTHEADMEMIDX-NEXT: ret
749 %1 = getelementptr i32, ptr %a, i64 %b
750 %2 = load i32, ptr %1, align 4
754 define i64 @lrw(ptr %a, i64 %b) {
755 ; RV32XTHEADMEMIDX-LABEL: lrw:
756 ; RV32XTHEADMEMIDX: # %bb.0:
757 ; RV32XTHEADMEMIDX-NEXT: th.lrw a1, a0, a1, 2
758 ; RV32XTHEADMEMIDX-NEXT: srai a2, a1, 31
759 ; RV32XTHEADMEMIDX-NEXT: add a0, a1, a1
760 ; RV32XTHEADMEMIDX-NEXT: sltu a1, a0, a1
761 ; RV32XTHEADMEMIDX-NEXT: add a2, a2, a2
762 ; RV32XTHEADMEMIDX-NEXT: add a1, a2, a1
763 ; RV32XTHEADMEMIDX-NEXT: ret
765 ; RV64XTHEADMEMIDX-LABEL: lrw:
766 ; RV64XTHEADMEMIDX: # %bb.0:
767 ; RV64XTHEADMEMIDX-NEXT: th.lrw a0, a0, a1, 2
768 ; RV64XTHEADMEMIDX-NEXT: add a0, a0, a0
769 ; RV64XTHEADMEMIDX-NEXT: ret
770 %1 = getelementptr i32, ptr %a, i64 %b
771 %2 = load i32, ptr %1, align 4
772 %3 = sext i32 %2 to i64
777 define i32 @lurw_anyext(ptr %a, i32 %b) {
778 ; RV32XTHEADMEMIDX-LABEL: lurw_anyext:
779 ; RV32XTHEADMEMIDX: # %bb.0:
780 ; RV32XTHEADMEMIDX-NEXT: th.lrw a0, a0, a1, 2
781 ; RV32XTHEADMEMIDX-NEXT: ret
783 ; RV64XTHEADMEMIDX-LABEL: lurw_anyext:
784 ; RV64XTHEADMEMIDX: # %bb.0:
785 ; RV64XTHEADMEMIDX-NEXT: th.lurw a0, a0, a1, 2
786 ; RV64XTHEADMEMIDX-NEXT: ret
787 %1 = zext i32 %b to i64
788 %2 = getelementptr i32, ptr %a, i64 %1
789 %3 = load i32, ptr %2, align 4
793 define i64 @lurw(ptr %a, i32 %b) {
794 ; RV32XTHEADMEMIDX-LABEL: lurw:
795 ; RV32XTHEADMEMIDX: # %bb.0:
796 ; RV32XTHEADMEMIDX-NEXT: th.lrw a1, a0, a1, 2
797 ; RV32XTHEADMEMIDX-NEXT: srai a2, a1, 31
798 ; RV32XTHEADMEMIDX-NEXT: add a0, a1, a1
799 ; RV32XTHEADMEMIDX-NEXT: sltu a1, a0, a1
800 ; RV32XTHEADMEMIDX-NEXT: add a2, a2, a2
801 ; RV32XTHEADMEMIDX-NEXT: add a1, a2, a1
802 ; RV32XTHEADMEMIDX-NEXT: ret
804 ; RV64XTHEADMEMIDX-LABEL: lurw:
805 ; RV64XTHEADMEMIDX: # %bb.0:
806 ; RV64XTHEADMEMIDX-NEXT: th.lurw a0, a0, a1, 2
807 ; RV64XTHEADMEMIDX-NEXT: add a0, a0, a0
808 ; RV64XTHEADMEMIDX-NEXT: ret
809 %1 = zext i32 %b to i64
810 %2 = getelementptr i32, ptr %a, i64 %1
811 %3 = load i32, ptr %2, align 4
812 %4 = sext i32 %3 to i64
817 define i64 @lrwu(ptr %a, i64 %b) {
818 ; RV32XTHEADMEMIDX-LABEL: lrwu:
819 ; RV32XTHEADMEMIDX: # %bb.0:
820 ; RV32XTHEADMEMIDX-NEXT: th.lrw a1, a0, a1, 2
821 ; RV32XTHEADMEMIDX-NEXT: add a0, a1, a1
822 ; RV32XTHEADMEMIDX-NEXT: sltu a1, a0, a1
823 ; RV32XTHEADMEMIDX-NEXT: ret
825 ; RV64XTHEADMEMIDX-LABEL: lrwu:
826 ; RV64XTHEADMEMIDX: # %bb.0:
827 ; RV64XTHEADMEMIDX-NEXT: th.lrwu a0, a0, a1, 2
828 ; RV64XTHEADMEMIDX-NEXT: add a0, a0, a0
829 ; RV64XTHEADMEMIDX-NEXT: ret
830 %1 = getelementptr i32, ptr %a, i64 %b
831 %2 = load i32, ptr %1, align 4
832 %3 = zext i32 %2 to i64
837 define i64 @lurwu(ptr %a, i32 %b) {
838 ; RV32XTHEADMEMIDX-LABEL: lurwu:
839 ; RV32XTHEADMEMIDX: # %bb.0:
840 ; RV32XTHEADMEMIDX-NEXT: th.lrw a1, a0, a1, 2
841 ; RV32XTHEADMEMIDX-NEXT: add a0, a1, a1
842 ; RV32XTHEADMEMIDX-NEXT: sltu a1, a0, a1
843 ; RV32XTHEADMEMIDX-NEXT: ret
845 ; RV64XTHEADMEMIDX-LABEL: lurwu:
846 ; RV64XTHEADMEMIDX: # %bb.0:
847 ; RV64XTHEADMEMIDX-NEXT: th.lurwu a0, a0, a1, 2
848 ; RV64XTHEADMEMIDX-NEXT: add a0, a0, a0
849 ; RV64XTHEADMEMIDX-NEXT: ret
850 %1 = zext i32 %b to i64
851 %2 = getelementptr i32, ptr %a, i64 %1
852 %3 = load i32, ptr %2, align 4
853 %4 = zext i32 %3 to i64
858 define i64 @lrd(ptr %a, i64 %b) {
859 ; RV32XTHEADMEMIDX-LABEL: lrd:
860 ; RV32XTHEADMEMIDX: # %bb.0:
861 ; RV32XTHEADMEMIDX-NEXT: slli a2, a1, 3
862 ; RV32XTHEADMEMIDX-NEXT: th.lrw a1, a0, a1, 3
863 ; RV32XTHEADMEMIDX-NEXT: add a0, a0, a2
864 ; RV32XTHEADMEMIDX-NEXT: lw a2, 4(a0)
865 ; RV32XTHEADMEMIDX-NEXT: add a0, a1, a1
866 ; RV32XTHEADMEMIDX-NEXT: sltu a1, a0, a1
867 ; RV32XTHEADMEMIDX-NEXT: add a2, a2, a2
868 ; RV32XTHEADMEMIDX-NEXT: add a1, a2, a1
869 ; RV32XTHEADMEMIDX-NEXT: ret
871 ; RV64XTHEADMEMIDX-LABEL: lrd:
872 ; RV64XTHEADMEMIDX: # %bb.0:
873 ; RV64XTHEADMEMIDX-NEXT: th.lrd a0, a0, a1, 3
874 ; RV64XTHEADMEMIDX-NEXT: add a0, a0, a0
875 ; RV64XTHEADMEMIDX-NEXT: ret
876 %1 = getelementptr i64, ptr %a, i64 %b
877 %2 = load i64, ptr %1, align 8
882 define i64 @lrd_2(ptr %a, i64 %b) {
883 ; RV32XTHEADMEMIDX-LABEL: lrd_2:
884 ; RV32XTHEADMEMIDX: # %bb.0:
885 ; RV32XTHEADMEMIDX-NEXT: addi a2, a0, 96
886 ; RV32XTHEADMEMIDX-NEXT: th.lrw a2, a2, a1, 3
887 ; RV32XTHEADMEMIDX-NEXT: addi a0, a0, 100
888 ; RV32XTHEADMEMIDX-NEXT: th.lrw a1, a0, a1, 3
889 ; RV32XTHEADMEMIDX-NEXT: add a0, a2, a2
890 ; RV32XTHEADMEMIDX-NEXT: sltu a2, a0, a2
891 ; RV32XTHEADMEMIDX-NEXT: add a1, a1, a1
892 ; RV32XTHEADMEMIDX-NEXT: add a1, a1, a2
893 ; RV32XTHEADMEMIDX-NEXT: ret
895 ; RV64XTHEADMEMIDX-LABEL: lrd_2:
896 ; RV64XTHEADMEMIDX: # %bb.0:
897 ; RV64XTHEADMEMIDX-NEXT: addi a0, a0, 96
898 ; RV64XTHEADMEMIDX-NEXT: th.lrd a0, a0, a1, 3
899 ; RV64XTHEADMEMIDX-NEXT: add a0, a0, a0
900 ; RV64XTHEADMEMIDX-NEXT: ret
902 %2 = getelementptr i64, ptr %a, i64 %1
903 %3 = load i64, ptr %2, align 8
908 define i64 @lurd(ptr %a, i32 %b) {
909 ; RV32XTHEADMEMIDX-LABEL: lurd:
910 ; RV32XTHEADMEMIDX: # %bb.0:
911 ; RV32XTHEADMEMIDX-NEXT: slli a2, a1, 3
912 ; RV32XTHEADMEMIDX-NEXT: th.lrw a1, a0, a1, 3
913 ; RV32XTHEADMEMIDX-NEXT: add a0, a0, a2
914 ; RV32XTHEADMEMIDX-NEXT: lw a2, 4(a0)
915 ; RV32XTHEADMEMIDX-NEXT: add a0, a1, a1
916 ; RV32XTHEADMEMIDX-NEXT: sltu a1, a0, a1
917 ; RV32XTHEADMEMIDX-NEXT: add a2, a2, a2
918 ; RV32XTHEADMEMIDX-NEXT: add a1, a2, a1
919 ; RV32XTHEADMEMIDX-NEXT: ret
921 ; RV64XTHEADMEMIDX-LABEL: lurd:
922 ; RV64XTHEADMEMIDX: # %bb.0:
923 ; RV64XTHEADMEMIDX-NEXT: th.lurd a0, a0, a1, 3
924 ; RV64XTHEADMEMIDX-NEXT: add a0, a0, a0
925 ; RV64XTHEADMEMIDX-NEXT: ret
926 %1 = zext i32 %b to i64
927 %2 = getelementptr i64, ptr %a, i64 %1
928 %3 = load i64, ptr %2, align 8
933 define void @srb(ptr %a, i64 %b, i8 %c) {
934 ; RV32XTHEADMEMIDX-LABEL: srb:
935 ; RV32XTHEADMEMIDX: # %bb.0:
936 ; RV32XTHEADMEMIDX-NEXT: add a3, a3, a3
937 ; RV32XTHEADMEMIDX-NEXT: th.srb a3, a0, a1, 0
938 ; RV32XTHEADMEMIDX-NEXT: ret
940 ; RV64XTHEADMEMIDX-LABEL: srb:
941 ; RV64XTHEADMEMIDX: # %bb.0:
942 ; RV64XTHEADMEMIDX-NEXT: add a2, a2, a2
943 ; RV64XTHEADMEMIDX-NEXT: th.srb a2, a0, a1, 0
944 ; RV64XTHEADMEMIDX-NEXT: ret
946 %2 = getelementptr i8, ptr %a, i64 %b
947 store i8 %1, ptr %2, align 1
951 define void @surb(ptr %a, i32 %b, i8 %c) {
952 ; RV32XTHEADMEMIDX-LABEL: surb:
953 ; RV32XTHEADMEMIDX: # %bb.0:
954 ; RV32XTHEADMEMIDX-NEXT: add a2, a2, a2
955 ; RV32XTHEADMEMIDX-NEXT: th.srb a2, a0, a1, 0
956 ; RV32XTHEADMEMIDX-NEXT: ret
958 ; RV64XTHEADMEMIDX-LABEL: surb:
959 ; RV64XTHEADMEMIDX: # %bb.0:
960 ; RV64XTHEADMEMIDX-NEXT: add a2, a2, a2
961 ; RV64XTHEADMEMIDX-NEXT: th.surb a2, a0, a1, 0
962 ; RV64XTHEADMEMIDX-NEXT: ret
963 %1 = zext i32 %b to i64
965 %3 = getelementptr i8, ptr %a, i64 %1
966 store i8 %2, ptr %3, align 1
970 define void @srh(ptr %a, i64 %b, i16 %c) {
971 ; RV32XTHEADMEMIDX-LABEL: srh:
972 ; RV32XTHEADMEMIDX: # %bb.0:
973 ; RV32XTHEADMEMIDX-NEXT: add a3, a3, a3
974 ; RV32XTHEADMEMIDX-NEXT: th.srh a3, a0, a1, 1
975 ; RV32XTHEADMEMIDX-NEXT: ret
977 ; RV64XTHEADMEMIDX-LABEL: srh:
978 ; RV64XTHEADMEMIDX: # %bb.0:
979 ; RV64XTHEADMEMIDX-NEXT: add a2, a2, a2
980 ; RV64XTHEADMEMIDX-NEXT: th.srh a2, a0, a1, 1
981 ; RV64XTHEADMEMIDX-NEXT: ret
983 %2 = getelementptr i16, ptr %a, i64 %b
984 store i16 %1, ptr %2, align 2
988 define void @surh(ptr %a, i32 %b, i16 %c) {
989 ; RV32XTHEADMEMIDX-LABEL: surh:
990 ; RV32XTHEADMEMIDX: # %bb.0:
991 ; RV32XTHEADMEMIDX-NEXT: add a2, a2, a2
992 ; RV32XTHEADMEMIDX-NEXT: th.srh a2, a0, a1, 1
993 ; RV32XTHEADMEMIDX-NEXT: ret
995 ; RV64XTHEADMEMIDX-LABEL: surh:
996 ; RV64XTHEADMEMIDX: # %bb.0:
997 ; RV64XTHEADMEMIDX-NEXT: add a2, a2, a2
998 ; RV64XTHEADMEMIDX-NEXT: th.surh a2, a0, a1, 1
999 ; RV64XTHEADMEMIDX-NEXT: ret
1000 %1 = zext i32 %b to i64
1002 %3 = getelementptr i16, ptr %a, i64 %1
1003 store i16 %2, ptr %3, align 2
1007 define void @srw(ptr %a, i64 %b, i32 %c) {
1008 ; RV32XTHEADMEMIDX-LABEL: srw:
1009 ; RV32XTHEADMEMIDX: # %bb.0:
1010 ; RV32XTHEADMEMIDX-NEXT: add a3, a3, a3
1011 ; RV32XTHEADMEMIDX-NEXT: th.srw a3, a0, a1, 2
1012 ; RV32XTHEADMEMIDX-NEXT: ret
1014 ; RV64XTHEADMEMIDX-LABEL: srw:
1015 ; RV64XTHEADMEMIDX: # %bb.0:
1016 ; RV64XTHEADMEMIDX-NEXT: add a2, a2, a2
1017 ; RV64XTHEADMEMIDX-NEXT: th.srw a2, a0, a1, 2
1018 ; RV64XTHEADMEMIDX-NEXT: ret
1020 %2 = getelementptr i32, ptr %a, i64 %b
1021 store i32 %1, ptr %2, align 4
1025 define void @surw(ptr %a, i32 %b, i32 %c) {
1026 ; RV32XTHEADMEMIDX-LABEL: surw:
1027 ; RV32XTHEADMEMIDX: # %bb.0:
1028 ; RV32XTHEADMEMIDX-NEXT: add a2, a2, a2
1029 ; RV32XTHEADMEMIDX-NEXT: th.srw a2, a0, a1, 2
1030 ; RV32XTHEADMEMIDX-NEXT: ret
1032 ; RV64XTHEADMEMIDX-LABEL: surw:
1033 ; RV64XTHEADMEMIDX: # %bb.0:
1034 ; RV64XTHEADMEMIDX-NEXT: add a2, a2, a2
1035 ; RV64XTHEADMEMIDX-NEXT: th.surw a2, a0, a1, 2
1036 ; RV64XTHEADMEMIDX-NEXT: ret
1037 %1 = zext i32 %b to i64
1039 %3 = getelementptr i32, ptr %a, i64 %1
1040 store i32 %2, ptr %3, align 4
1044 define void @srd(ptr %a, i64 %b, i64 %c) {
1045 ; RV32XTHEADMEMIDX-LABEL: srd:
1046 ; RV32XTHEADMEMIDX: # %bb.0:
1047 ; RV32XTHEADMEMIDX-NEXT: add a2, a3, a3
1048 ; RV32XTHEADMEMIDX-NEXT: sltu a3, a2, a3
1049 ; RV32XTHEADMEMIDX-NEXT: add a4, a4, a4
1050 ; RV32XTHEADMEMIDX-NEXT: add a3, a4, a3
1051 ; RV32XTHEADMEMIDX-NEXT: slli a4, a1, 3
1052 ; RV32XTHEADMEMIDX-NEXT: add a4, a0, a4
1053 ; RV32XTHEADMEMIDX-NEXT: th.srw a2, a0, a1, 3
1054 ; RV32XTHEADMEMIDX-NEXT: sw a3, 4(a4)
1055 ; RV32XTHEADMEMIDX-NEXT: ret
1057 ; RV64XTHEADMEMIDX-LABEL: srd:
1058 ; RV64XTHEADMEMIDX: # %bb.0:
1059 ; RV64XTHEADMEMIDX-NEXT: add a2, a2, a2
1060 ; RV64XTHEADMEMIDX-NEXT: th.srd a2, a0, a1, 3
1061 ; RV64XTHEADMEMIDX-NEXT: ret
1063 %2 = getelementptr i64, ptr %a, i64 %b
1064 store i64 %1, ptr %2, align 8
1068 define void @surd(ptr %a, i32 %b, i64 %c) {
1069 ; RV32XTHEADMEMIDX-LABEL: surd:
1070 ; RV32XTHEADMEMIDX: # %bb.0:
1071 ; RV32XTHEADMEMIDX-NEXT: add a4, a2, a2
1072 ; RV32XTHEADMEMIDX-NEXT: sltu a2, a4, a2
1073 ; RV32XTHEADMEMIDX-NEXT: add a3, a3, a3
1074 ; RV32XTHEADMEMIDX-NEXT: add a2, a3, a2
1075 ; RV32XTHEADMEMIDX-NEXT: slli a3, a1, 3
1076 ; RV32XTHEADMEMIDX-NEXT: add a3, a0, a3
1077 ; RV32XTHEADMEMIDX-NEXT: th.srw a4, a0, a1, 3
1078 ; RV32XTHEADMEMIDX-NEXT: sw a2, 4(a3)
1079 ; RV32XTHEADMEMIDX-NEXT: ret
1081 ; RV64XTHEADMEMIDX-LABEL: surd:
1082 ; RV64XTHEADMEMIDX: # %bb.0:
1083 ; RV64XTHEADMEMIDX-NEXT: add a2, a2, a2
1084 ; RV64XTHEADMEMIDX-NEXT: th.surd a2, a0, a1, 3
1085 ; RV64XTHEADMEMIDX-NEXT: ret
1086 %1 = zext i32 %b to i64
1088 %3 = getelementptr i64, ptr %a, i64 %1
1089 store i64 %2, ptr %3, align 8
1093 define ptr @test_simm5(ptr %base, i32 %a, i32 %b) {
1094 ; RV32XTHEADMEMIDX-LABEL: test_simm5:
1095 ; RV32XTHEADMEMIDX: # %bb.0:
1096 ; RV32XTHEADMEMIDX-NEXT: add a1, a1, a2
1097 ; RV32XTHEADMEMIDX-NEXT: th.swia a1, (a0), -12, 2
1098 ; RV32XTHEADMEMIDX-NEXT: ret
1100 ; RV64XTHEADMEMIDX-LABEL: test_simm5:
1101 ; RV64XTHEADMEMIDX: # %bb.0:
1102 ; RV64XTHEADMEMIDX-NEXT: add a1, a1, a2
1103 ; RV64XTHEADMEMIDX-NEXT: th.swia a1, (a0), -12, 2
1104 ; RV64XTHEADMEMIDX-NEXT: ret
1105 %addr.1 = getelementptr i32, ptr %base, i32 -12
1106 %res = add i32 %a, %b
1107 store i32 %res, ptr %base
1111 define i64 @lrd_large_shift(ptr %a, i64 %b) {
1112 ; RV32XTHEADMEMIDX-LABEL: lrd_large_shift:
1113 ; RV32XTHEADMEMIDX: # %bb.0:
1114 ; RV32XTHEADMEMIDX-NEXT: slli a1, a1, 5
1115 ; RV32XTHEADMEMIDX-NEXT: add a1, a1, a0
1116 ; RV32XTHEADMEMIDX-NEXT: lw a0, 384(a1)
1117 ; RV32XTHEADMEMIDX-NEXT: lw a1, 388(a1)
1118 ; RV32XTHEADMEMIDX-NEXT: ret
1120 ; RV64XTHEADMEMIDX-LABEL: lrd_large_shift:
1121 ; RV64XTHEADMEMIDX: # %bb.0:
1122 ; RV64XTHEADMEMIDX-NEXT: slli a1, a1, 5
1123 ; RV64XTHEADMEMIDX-NEXT: add a0, a1, a0
1124 ; RV64XTHEADMEMIDX-NEXT: ld a0, 384(a0)
1125 ; RV64XTHEADMEMIDX-NEXT: ret
1128 %3 = getelementptr i64, ptr %a, i64 %2
1129 %4 = load i64, ptr %3, align 8
1133 define i64 @lrd_large_offset(ptr %a, i64 %b) {
1134 ; RV32XTHEADMEMIDX-LABEL: lrd_large_offset:
1135 ; RV32XTHEADMEMIDX: # %bb.0:
1136 ; RV32XTHEADMEMIDX-NEXT: slli a1, a1, 3
1137 ; RV32XTHEADMEMIDX-NEXT: add a0, a1, a0
1138 ; RV32XTHEADMEMIDX-NEXT: lui a1, 23
1139 ; RV32XTHEADMEMIDX-NEXT: addi a1, a1, 1792
1140 ; RV32XTHEADMEMIDX-NEXT: add a1, a0, a1
1141 ; RV32XTHEADMEMIDX-NEXT: lw a0, 0(a1)
1142 ; RV32XTHEADMEMIDX-NEXT: lw a1, 4(a1)
1143 ; RV32XTHEADMEMIDX-NEXT: ret
1145 ; RV64XTHEADMEMIDX-LABEL: lrd_large_offset:
1146 ; RV64XTHEADMEMIDX: # %bb.0:
1147 ; RV64XTHEADMEMIDX-NEXT: slli a1, a1, 3
1148 ; RV64XTHEADMEMIDX-NEXT: add a0, a1, a0
1149 ; RV64XTHEADMEMIDX-NEXT: lui a1, 23
1150 ; RV64XTHEADMEMIDX-NEXT: add a0, a0, a1
1151 ; RV64XTHEADMEMIDX-NEXT: ld a0, 1792(a0)
1152 ; RV64XTHEADMEMIDX-NEXT: ret
1153 %1 = add i64 %b, 12000
1154 %2 = getelementptr i64, ptr %a, i64 %1
1155 %3 = load i64, ptr %2, align 8