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 i8* @lbia(i8* %base, i8* %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, i8* %base, i8 0
22 %ld = load i8, i8* %addr
23 %addr.1 = getelementptr i8, i8* %base, i8 -1
25 store i8 %res, i8* %addr.2
29 define i8* @lbib(i8* %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, i8* %base, i8 1
44 %ld = load i8, i8* %addr
45 %addr.1 = getelementptr i8, i8* %base, i8 2
47 store i8 %res, i8* %addr.1
51 define i8* @lbuia(i8* %base, i64* %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, i8* %base, i8 0
69 %ld = load i8, i8* %addr
70 %zext = zext i8 %ld to i64
71 %addr.1 = getelementptr i8, i8* %base, i8 -1
72 %res = add i64 %zext, %a
73 store i64 %res, i64* %addr.2
77 define i8* @lbuib(i8* %base, i64 %a, i64* %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, i8* %base, i8 1
95 %ld = load i8, i8* %addr
96 %zext = zext i8 %ld to i64
97 %res = add i64 %zext, %a
98 store i64 %res, i64* %addr.1
102 define i16* @lhia(i16* %base, i16* %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, i16* %base, i16 0
117 %ld = load i16, i16* %addr
118 %addr.1 = getelementptr i16, i16* %base, i16 -16
119 %res = add i16 %ld, %a
120 store i16 %res, i16* %addr.2
124 define i16* @lhib(i16* %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, i16* %base, i16 1
139 %ld = load i16, i16* %addr
140 %addr.1 = getelementptr i16, i16* %base, i16 2
141 %res = add i16 %ld, %a
142 store i16 %res, i16* %addr.1
146 define i16* @lhuia(i16* %base, i64* %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, i16* %base, i16 0
164 %ld = load i16, i16* %addr
165 %zext = zext i16 %ld to i64
166 %addr.1 = getelementptr i16, i16* %base, i16 -16
167 %res = add i64 %zext, %a
168 store i64 %res, i64* %addr.2
172 define i16* @lhuib(i16* %base, i64 %a, i64* %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, i16* %base, i16 1
190 %ld = load i16, i16* %addr
191 %zext = zext i16 %ld to i64
192 %res = add i64 %zext, %a
193 store i64 %res, i64* %addr.1
197 define i32* @lwia(i32* %base, i32* %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, i32* %base, i32 0
212 %ld = load i32, i32* %addr
213 %addr.1 = getelementptr i32, i32* %base, i32 -16
214 %res = add i32 %ld, %a
215 store i32 %res, i32* %addr.2
219 define i32* @lwib(i32* %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, i32* %base, i32 1
234 %ld = load i32, i32* %addr
235 %addr.1 = getelementptr i32, i32* %base, i32 2
236 %res = add i32 %ld, %a
237 store i32 %res, i32* %addr.1
241 define i32* @lwuia(i32* %base, i64* %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, i32* %base, i32 0
259 %ld = load i32, i32* %addr
260 %zext = zext i32 %ld to i64
261 %addr.1 = getelementptr i32, i32* %base, i32 -16
262 %res = add i64 %zext, %a
263 store i64 %res, i64* %addr.2
267 define i32* @lwuib(i32* %base, i64 %a, i64* %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, i32* %base, i32 1
285 %ld = load i32, i32* %addr
286 %zext = zext i32 %ld to i64
287 %res = add i64 %zext, %a
288 store i64 %res, i64* %addr.1
292 define i64* @ldia(i64* %base, i64* %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, i64* %base, i64 0
313 %ld = load i64, i64* %addr
314 %addr.1 = getelementptr i64, i64* %base, i64 -16
315 %res = add i64 %ld, %a
316 store i64 %res, i64* %addr.2
320 define i64* @ldib(i64* %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, i64* %base, i64 1
340 %ld = load i64, i64* %addr
341 %addr.1 = getelementptr i64, i64* %base, i64 2
342 %res = add i64 %ld, %a
343 store i64 %res, i64* %addr.1
347 define i8* @sbia(i8* %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, i8* %base, i8 1
361 store i8 %res, i8* %base
365 define i8* @sbib(i8* %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, i8* %base, i8 1
379 store i8 %res, i8* %addr.1
383 define i16* @shia(i16* %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, i16* %base, i16 -9
396 %res = add i16 %a, %b
397 store i16 %res, i16* %base
401 define i16* @shib(i16* %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, i16* %base, i16 1
414 %res = add i16 %a, %b
415 store i16 %res, i16* %addr.1
419 define i32* @swia(i32* %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, i32* %base, i32 8
432 %res = add i32 %a, %b
433 store i32 %res, i32* %base
437 define i32* @swib(i32* %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, i32* %base, i32 -26
450 %res = add i32 %a, %b
451 store i32 %res, i32* %addr.1
455 define i64* @sdia(i64* %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, i64* %base, i64 8
474 %res = add i64 %a, %b
475 store i64 %res, i64* %base
479 define i64* @sdib(i64* %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, i64* %base, i64 1
496 %res = add i64 %a, %b
497 store i64 %res, i64* %addr.1
501 define i64 @lrb(i8* %a, i64 %b) {
502 ; RV32XTHEADMEMIDX-LABEL: lrb:
503 ; RV32XTHEADMEMIDX: # %bb.0:
504 ; RV32XTHEADMEMIDX-NEXT: th.lrb a1, a0, a1, 0
505 ; RV32XTHEADMEMIDX-NEXT: srai a2, a1, 31
506 ; RV32XTHEADMEMIDX-NEXT: add a0, a1, a1
507 ; RV32XTHEADMEMIDX-NEXT: sltu a1, a0, a1
508 ; RV32XTHEADMEMIDX-NEXT: add a2, a2, a2
509 ; RV32XTHEADMEMIDX-NEXT: add a1, a2, a1
510 ; RV32XTHEADMEMIDX-NEXT: ret
512 ; RV64XTHEADMEMIDX-LABEL: lrb:
513 ; RV64XTHEADMEMIDX: # %bb.0:
514 ; RV64XTHEADMEMIDX-NEXT: th.lrb a0, a0, a1, 0
515 ; RV64XTHEADMEMIDX-NEXT: add a0, a0, a0
516 ; RV64XTHEADMEMIDX-NEXT: ret
517 %1 = getelementptr i8, i8* %a, i64 %b
518 %2 = load i8, i8* %1, align 1
519 %3 = sext i8 %2 to i64
524 define i64 @lurb(i8* %a, i32 %b) {
525 ; RV32XTHEADMEMIDX-LABEL: lurb:
526 ; RV32XTHEADMEMIDX: # %bb.0:
527 ; RV32XTHEADMEMIDX-NEXT: th.lrb a1, a0, a1, 0
528 ; RV32XTHEADMEMIDX-NEXT: srai a2, a1, 31
529 ; RV32XTHEADMEMIDX-NEXT: add a0, a1, a1
530 ; RV32XTHEADMEMIDX-NEXT: sltu a1, a0, a1
531 ; RV32XTHEADMEMIDX-NEXT: add a2, a2, a2
532 ; RV32XTHEADMEMIDX-NEXT: add a1, a2, a1
533 ; RV32XTHEADMEMIDX-NEXT: ret
535 ; RV64XTHEADMEMIDX-LABEL: lurb:
536 ; RV64XTHEADMEMIDX: # %bb.0:
537 ; RV64XTHEADMEMIDX-NEXT: th.lurb a0, a0, a1, 0
538 ; RV64XTHEADMEMIDX-NEXT: add a0, a0, a0
539 ; RV64XTHEADMEMIDX-NEXT: ret
540 %1 = zext i32 %b to i64
541 %2 = getelementptr i8, i8* %a, i64 %1
542 %3 = load i8, i8* %2, align 1
543 %4 = sext i8 %3 to i64
548 define i64 @lrbu(i8* %a, i64 %b) {
549 ; RV32XTHEADMEMIDX-LABEL: lrbu:
550 ; RV32XTHEADMEMIDX: # %bb.0:
551 ; RV32XTHEADMEMIDX-NEXT: th.lrbu a1, a0, a1, 0
552 ; RV32XTHEADMEMIDX-NEXT: add a0, a1, a1
553 ; RV32XTHEADMEMIDX-NEXT: sltu a1, a0, a1
554 ; RV32XTHEADMEMIDX-NEXT: ret
556 ; RV64XTHEADMEMIDX-LABEL: lrbu:
557 ; RV64XTHEADMEMIDX: # %bb.0:
558 ; RV64XTHEADMEMIDX-NEXT: th.lrbu a0, a0, a1, 0
559 ; RV64XTHEADMEMIDX-NEXT: add a0, a0, a0
560 ; RV64XTHEADMEMIDX-NEXT: ret
561 %1 = getelementptr i8, i8* %a, i64 %b
562 %2 = load i8, i8* %1, align 1
563 %3 = zext i8 %2 to i64
568 define i64 @lurbu(i8* %a, i32 %b) {
569 ; RV32XTHEADMEMIDX-LABEL: lurbu:
570 ; RV32XTHEADMEMIDX: # %bb.0:
571 ; RV32XTHEADMEMIDX-NEXT: th.lrbu a1, a0, a1, 0
572 ; RV32XTHEADMEMIDX-NEXT: add a0, a1, a1
573 ; RV32XTHEADMEMIDX-NEXT: sltu a1, a0, a1
574 ; RV32XTHEADMEMIDX-NEXT: ret
576 ; RV64XTHEADMEMIDX-LABEL: lurbu:
577 ; RV64XTHEADMEMIDX: # %bb.0:
578 ; RV64XTHEADMEMIDX-NEXT: th.lurbu a0, a0, a1, 0
579 ; RV64XTHEADMEMIDX-NEXT: add a0, a0, a0
580 ; RV64XTHEADMEMIDX-NEXT: ret
581 %1 = zext i32 %b to i64
582 %2 = getelementptr i8, i8* %a, i64 %1
583 %3 = load i8, i8* %2, align 1
584 %4 = zext i8 %3 to i64
589 define i64 @lrh(i16* %a, i64 %b) {
590 ; RV32XTHEADMEMIDX-LABEL: lrh:
591 ; RV32XTHEADMEMIDX: # %bb.0:
592 ; RV32XTHEADMEMIDX-NEXT: th.lrh a1, a0, a1, 1
593 ; RV32XTHEADMEMIDX-NEXT: srai a2, a1, 31
594 ; RV32XTHEADMEMIDX-NEXT: add a0, a1, a1
595 ; RV32XTHEADMEMIDX-NEXT: sltu a1, a0, a1
596 ; RV32XTHEADMEMIDX-NEXT: add a2, a2, a2
597 ; RV32XTHEADMEMIDX-NEXT: add a1, a2, a1
598 ; RV32XTHEADMEMIDX-NEXT: ret
600 ; RV64XTHEADMEMIDX-LABEL: lrh:
601 ; RV64XTHEADMEMIDX: # %bb.0:
602 ; RV64XTHEADMEMIDX-NEXT: th.lrh a0, a0, a1, 1
603 ; RV64XTHEADMEMIDX-NEXT: add a0, a0, a0
604 ; RV64XTHEADMEMIDX-NEXT: ret
605 %1 = getelementptr i16, i16* %a, i64 %b
606 %2 = load i16, i16* %1, align 4
607 %3 = sext i16 %2 to i64
612 define i64 @lurh(i16* %a, i32 %b) {
613 ; RV32XTHEADMEMIDX-LABEL: lurh:
614 ; RV32XTHEADMEMIDX: # %bb.0:
615 ; RV32XTHEADMEMIDX-NEXT: th.lrh a1, a0, a1, 1
616 ; RV32XTHEADMEMIDX-NEXT: srai a2, a1, 31
617 ; RV32XTHEADMEMIDX-NEXT: add a0, a1, a1
618 ; RV32XTHEADMEMIDX-NEXT: sltu a1, a0, a1
619 ; RV32XTHEADMEMIDX-NEXT: add a2, a2, a2
620 ; RV32XTHEADMEMIDX-NEXT: add a1, a2, a1
621 ; RV32XTHEADMEMIDX-NEXT: ret
623 ; RV64XTHEADMEMIDX-LABEL: lurh:
624 ; RV64XTHEADMEMIDX: # %bb.0:
625 ; RV64XTHEADMEMIDX-NEXT: th.lurh a0, a0, a1, 1
626 ; RV64XTHEADMEMIDX-NEXT: add a0, a0, a0
627 ; RV64XTHEADMEMIDX-NEXT: ret
628 %1 = zext i32 %b to i64
629 %2 = getelementptr i16, i16* %a, i64 %1
630 %3 = load i16, i16* %2, align 4
631 %4 = sext i16 %3 to i64
636 define i64 @lrhu(i16* %a, i64 %b) {
637 ; RV32XTHEADMEMIDX-LABEL: lrhu:
638 ; RV32XTHEADMEMIDX: # %bb.0:
639 ; RV32XTHEADMEMIDX-NEXT: th.lrhu a1, a0, a1, 1
640 ; RV32XTHEADMEMIDX-NEXT: add a0, a1, a1
641 ; RV32XTHEADMEMIDX-NEXT: sltu a1, a0, a1
642 ; RV32XTHEADMEMIDX-NEXT: ret
644 ; RV64XTHEADMEMIDX-LABEL: lrhu:
645 ; RV64XTHEADMEMIDX: # %bb.0:
646 ; RV64XTHEADMEMIDX-NEXT: th.lrhu a0, a0, a1, 1
647 ; RV64XTHEADMEMIDX-NEXT: add a0, a0, a0
648 ; RV64XTHEADMEMIDX-NEXT: ret
649 %1 = getelementptr i16, i16* %a, i64 %b
650 %2 = load i16, i16* %1, align 4
651 %3 = zext i16 %2 to i64
656 define i64 @lurhu(i16* %a, i32 %b) {
657 ; RV32XTHEADMEMIDX-LABEL: lurhu:
658 ; RV32XTHEADMEMIDX: # %bb.0:
659 ; RV32XTHEADMEMIDX-NEXT: th.lrhu a1, a0, a1, 1
660 ; RV32XTHEADMEMIDX-NEXT: add a0, a1, a1
661 ; RV32XTHEADMEMIDX-NEXT: sltu a1, a0, a1
662 ; RV32XTHEADMEMIDX-NEXT: ret
664 ; RV64XTHEADMEMIDX-LABEL: lurhu:
665 ; RV64XTHEADMEMIDX: # %bb.0:
666 ; RV64XTHEADMEMIDX-NEXT: th.lurhu a0, a0, a1, 1
667 ; RV64XTHEADMEMIDX-NEXT: add a0, a0, a0
668 ; RV64XTHEADMEMIDX-NEXT: ret
669 %1 = zext i32 %b to i64
670 %2 = getelementptr i16, i16* %a, i64 %1
671 %3 = load i16, i16* %2, align 4
672 %4 = zext i16 %3 to i64
677 define i64 @lrw(i32* %a, i64 %b) {
678 ; RV32XTHEADMEMIDX-LABEL: lrw:
679 ; RV32XTHEADMEMIDX: # %bb.0:
680 ; RV32XTHEADMEMIDX-NEXT: th.lrw a1, a0, a1, 2
681 ; RV32XTHEADMEMIDX-NEXT: srai a2, a1, 31
682 ; RV32XTHEADMEMIDX-NEXT: add a0, a1, a1
683 ; RV32XTHEADMEMIDX-NEXT: sltu a1, a0, a1
684 ; RV32XTHEADMEMIDX-NEXT: add a2, a2, a2
685 ; RV32XTHEADMEMIDX-NEXT: add a1, a2, a1
686 ; RV32XTHEADMEMIDX-NEXT: ret
688 ; RV64XTHEADMEMIDX-LABEL: lrw:
689 ; RV64XTHEADMEMIDX: # %bb.0:
690 ; RV64XTHEADMEMIDX-NEXT: th.lrw a0, a0, a1, 2
691 ; RV64XTHEADMEMIDX-NEXT: add a0, a0, a0
692 ; RV64XTHEADMEMIDX-NEXT: ret
693 %1 = getelementptr i32, i32* %a, i64 %b
694 %2 = load i32, i32* %1, align 4
695 %3 = sext i32 %2 to i64
700 define i64 @lurw(i32* %a, i32 %b) {
701 ; RV32XTHEADMEMIDX-LABEL: lurw:
702 ; RV32XTHEADMEMIDX: # %bb.0:
703 ; RV32XTHEADMEMIDX-NEXT: th.lrw a1, a0, a1, 2
704 ; RV32XTHEADMEMIDX-NEXT: srai a2, a1, 31
705 ; RV32XTHEADMEMIDX-NEXT: add a0, a1, a1
706 ; RV32XTHEADMEMIDX-NEXT: sltu a1, a0, a1
707 ; RV32XTHEADMEMIDX-NEXT: add a2, a2, a2
708 ; RV32XTHEADMEMIDX-NEXT: add a1, a2, a1
709 ; RV32XTHEADMEMIDX-NEXT: ret
711 ; RV64XTHEADMEMIDX-LABEL: lurw:
712 ; RV64XTHEADMEMIDX: # %bb.0:
713 ; RV64XTHEADMEMIDX-NEXT: th.lurw a0, a0, a1, 2
714 ; RV64XTHEADMEMIDX-NEXT: add a0, a0, a0
715 ; RV64XTHEADMEMIDX-NEXT: ret
716 %1 = zext i32 %b to i64
717 %2 = getelementptr i32, i32* %a, i64 %1
718 %3 = load i32, i32* %2, align 4
719 %4 = sext i32 %3 to i64
724 define i64 @lrwu(i32* %a, i64 %b) {
725 ; RV32XTHEADMEMIDX-LABEL: lrwu:
726 ; RV32XTHEADMEMIDX: # %bb.0:
727 ; RV32XTHEADMEMIDX-NEXT: th.lrw a1, a0, a1, 2
728 ; RV32XTHEADMEMIDX-NEXT: add a0, a1, a1
729 ; RV32XTHEADMEMIDX-NEXT: sltu a1, a0, a1
730 ; RV32XTHEADMEMIDX-NEXT: ret
732 ; RV64XTHEADMEMIDX-LABEL: lrwu:
733 ; RV64XTHEADMEMIDX: # %bb.0:
734 ; RV64XTHEADMEMIDX-NEXT: th.lrwu a0, a0, a1, 2
735 ; RV64XTHEADMEMIDX-NEXT: add a0, a0, a0
736 ; RV64XTHEADMEMIDX-NEXT: ret
737 %1 = getelementptr i32, i32* %a, i64 %b
738 %2 = load i32, i32* %1, align 4
739 %3 = zext i32 %2 to i64
744 define i64 @lurwu(i32* %a, i32 %b) {
745 ; RV32XTHEADMEMIDX-LABEL: lurwu:
746 ; RV32XTHEADMEMIDX: # %bb.0:
747 ; RV32XTHEADMEMIDX-NEXT: th.lrw a1, a0, a1, 2
748 ; RV32XTHEADMEMIDX-NEXT: add a0, a1, a1
749 ; RV32XTHEADMEMIDX-NEXT: sltu a1, a0, a1
750 ; RV32XTHEADMEMIDX-NEXT: ret
752 ; RV64XTHEADMEMIDX-LABEL: lurwu:
753 ; RV64XTHEADMEMIDX: # %bb.0:
754 ; RV64XTHEADMEMIDX-NEXT: th.lurwu a0, a0, a1, 2
755 ; RV64XTHEADMEMIDX-NEXT: add a0, a0, a0
756 ; RV64XTHEADMEMIDX-NEXT: ret
757 %1 = zext i32 %b to i64
758 %2 = getelementptr i32, i32* %a, i64 %1
759 %3 = load i32, i32* %2, align 4
760 %4 = zext i32 %3 to i64
765 define i64 @lrd(i64* %a, i64 %b) {
766 ; RV32XTHEADMEMIDX-LABEL: lrd:
767 ; RV32XTHEADMEMIDX: # %bb.0:
768 ; RV32XTHEADMEMIDX-NEXT: slli a2, a1, 3
769 ; RV32XTHEADMEMIDX-NEXT: th.lrw a1, a0, a1, 3
770 ; RV32XTHEADMEMIDX-NEXT: add a0, a0, a2
771 ; RV32XTHEADMEMIDX-NEXT: lw a2, 4(a0)
772 ; RV32XTHEADMEMIDX-NEXT: add a0, a1, a1
773 ; RV32XTHEADMEMIDX-NEXT: sltu a1, a0, a1
774 ; RV32XTHEADMEMIDX-NEXT: add a2, a2, a2
775 ; RV32XTHEADMEMIDX-NEXT: add a1, a2, a1
776 ; RV32XTHEADMEMIDX-NEXT: ret
778 ; RV64XTHEADMEMIDX-LABEL: lrd:
779 ; RV64XTHEADMEMIDX: # %bb.0:
780 ; RV64XTHEADMEMIDX-NEXT: th.lrd a0, a0, a1, 3
781 ; RV64XTHEADMEMIDX-NEXT: add a0, a0, a0
782 ; RV64XTHEADMEMIDX-NEXT: ret
783 %1 = getelementptr i64, i64* %a, i64 %b
784 %2 = load i64, i64* %1, align 8
789 define i64 @lrd_2(i64* %a, i64 %b) {
790 ; RV32XTHEADMEMIDX-LABEL: lrd_2:
791 ; RV32XTHEADMEMIDX: # %bb.0:
792 ; RV32XTHEADMEMIDX-NEXT: addi a2, a0, 96
793 ; RV32XTHEADMEMIDX-NEXT: th.lrw a2, a2, a1, 3
794 ; RV32XTHEADMEMIDX-NEXT: addi a0, a0, 100
795 ; RV32XTHEADMEMIDX-NEXT: th.lrw a1, a0, a1, 3
796 ; RV32XTHEADMEMIDX-NEXT: add a0, a2, a2
797 ; RV32XTHEADMEMIDX-NEXT: sltu a2, a0, a2
798 ; RV32XTHEADMEMIDX-NEXT: add a1, a1, a1
799 ; RV32XTHEADMEMIDX-NEXT: add a1, a1, a2
800 ; RV32XTHEADMEMIDX-NEXT: ret
802 ; RV64XTHEADMEMIDX-LABEL: lrd_2:
803 ; RV64XTHEADMEMIDX: # %bb.0:
804 ; RV64XTHEADMEMIDX-NEXT: addi a0, a0, 96
805 ; RV64XTHEADMEMIDX-NEXT: th.lrd a0, a0, a1, 3
806 ; RV64XTHEADMEMIDX-NEXT: add a0, a0, a0
807 ; RV64XTHEADMEMIDX-NEXT: ret
809 %2 = getelementptr i64, i64* %a, i64 %1
810 %3 = load i64, i64* %2, align 8
815 define i64 @lurd(i64* %a, i32 %b) {
816 ; RV32XTHEADMEMIDX-LABEL: lurd:
817 ; RV32XTHEADMEMIDX: # %bb.0:
818 ; RV32XTHEADMEMIDX-NEXT: slli a2, a1, 3
819 ; RV32XTHEADMEMIDX-NEXT: th.lrw a1, a0, a1, 3
820 ; RV32XTHEADMEMIDX-NEXT: add a0, a0, a2
821 ; RV32XTHEADMEMIDX-NEXT: lw a2, 4(a0)
822 ; RV32XTHEADMEMIDX-NEXT: add a0, a1, a1
823 ; RV32XTHEADMEMIDX-NEXT: sltu a1, a0, a1
824 ; RV32XTHEADMEMIDX-NEXT: add a2, a2, a2
825 ; RV32XTHEADMEMIDX-NEXT: add a1, a2, a1
826 ; RV32XTHEADMEMIDX-NEXT: ret
828 ; RV64XTHEADMEMIDX-LABEL: lurd:
829 ; RV64XTHEADMEMIDX: # %bb.0:
830 ; RV64XTHEADMEMIDX-NEXT: th.lurd a0, a0, a1, 3
831 ; RV64XTHEADMEMIDX-NEXT: add a0, a0, a0
832 ; RV64XTHEADMEMIDX-NEXT: ret
833 %1 = zext i32 %b to i64
834 %2 = getelementptr i64, i64* %a, i64 %1
835 %3 = load i64, i64* %2, align 8
840 define void @srb(i8* %a, i64 %b, i8 %c) {
841 ; RV32XTHEADMEMIDX-LABEL: srb:
842 ; RV32XTHEADMEMIDX: # %bb.0:
843 ; RV32XTHEADMEMIDX-NEXT: add a3, a3, a3
844 ; RV32XTHEADMEMIDX-NEXT: th.srb a3, a0, a1, 0
845 ; RV32XTHEADMEMIDX-NEXT: ret
847 ; RV64XTHEADMEMIDX-LABEL: srb:
848 ; RV64XTHEADMEMIDX: # %bb.0:
849 ; RV64XTHEADMEMIDX-NEXT: add a2, a2, a2
850 ; RV64XTHEADMEMIDX-NEXT: th.srb a2, a0, a1, 0
851 ; RV64XTHEADMEMIDX-NEXT: ret
853 %2 = getelementptr i8, i8* %a, i64 %b
854 store i8 %1, i8* %2, align 8
858 define void @surb(i8* %a, i32 %b, i8 %c) {
859 ; RV32XTHEADMEMIDX-LABEL: surb:
860 ; RV32XTHEADMEMIDX: # %bb.0:
861 ; RV32XTHEADMEMIDX-NEXT: add a2, a2, a2
862 ; RV32XTHEADMEMIDX-NEXT: th.srb a2, a0, a1, 0
863 ; RV32XTHEADMEMIDX-NEXT: ret
865 ; RV64XTHEADMEMIDX-LABEL: surb:
866 ; RV64XTHEADMEMIDX: # %bb.0:
867 ; RV64XTHEADMEMIDX-NEXT: add a2, a2, a2
868 ; RV64XTHEADMEMIDX-NEXT: th.surb a2, a0, a1, 0
869 ; RV64XTHEADMEMIDX-NEXT: ret
870 %1 = zext i32 %b to i64
872 %3 = getelementptr i8, i8* %a, i64 %1
873 store i8 %2, i8* %3, align 8
877 define void @srh(i16* %a, i64 %b, i16 %c) {
878 ; RV32XTHEADMEMIDX-LABEL: srh:
879 ; RV32XTHEADMEMIDX: # %bb.0:
880 ; RV32XTHEADMEMIDX-NEXT: add a3, a3, a3
881 ; RV32XTHEADMEMIDX-NEXT: th.srh a3, a0, a1, 1
882 ; RV32XTHEADMEMIDX-NEXT: ret
884 ; RV64XTHEADMEMIDX-LABEL: srh:
885 ; RV64XTHEADMEMIDX: # %bb.0:
886 ; RV64XTHEADMEMIDX-NEXT: add a2, a2, a2
887 ; RV64XTHEADMEMIDX-NEXT: th.srh a2, a0, a1, 1
888 ; RV64XTHEADMEMIDX-NEXT: ret
890 %2 = getelementptr i16, i16* %a, i64 %b
891 store i16 %1, i16* %2, align 8
895 define void @surh(i16* %a, i32 %b, i16 %c) {
896 ; RV32XTHEADMEMIDX-LABEL: surh:
897 ; RV32XTHEADMEMIDX: # %bb.0:
898 ; RV32XTHEADMEMIDX-NEXT: add a2, a2, a2
899 ; RV32XTHEADMEMIDX-NEXT: th.srh a2, a0, a1, 1
900 ; RV32XTHEADMEMIDX-NEXT: ret
902 ; RV64XTHEADMEMIDX-LABEL: surh:
903 ; RV64XTHEADMEMIDX: # %bb.0:
904 ; RV64XTHEADMEMIDX-NEXT: add a2, a2, a2
905 ; RV64XTHEADMEMIDX-NEXT: th.surh a2, a0, a1, 1
906 ; RV64XTHEADMEMIDX-NEXT: ret
907 %1 = zext i32 %b to i64
909 %3 = getelementptr i16, i16* %a, i64 %1
910 store i16 %2, i16* %3, align 8
914 define void @srw(i32* %a, i64 %b, i32 %c) {
915 ; RV32XTHEADMEMIDX-LABEL: srw:
916 ; RV32XTHEADMEMIDX: # %bb.0:
917 ; RV32XTHEADMEMIDX-NEXT: add a3, a3, a3
918 ; RV32XTHEADMEMIDX-NEXT: th.srw a3, a0, a1, 2
919 ; RV32XTHEADMEMIDX-NEXT: ret
921 ; RV64XTHEADMEMIDX-LABEL: srw:
922 ; RV64XTHEADMEMIDX: # %bb.0:
923 ; RV64XTHEADMEMIDX-NEXT: add a2, a2, a2
924 ; RV64XTHEADMEMIDX-NEXT: th.srw a2, a0, a1, 2
925 ; RV64XTHEADMEMIDX-NEXT: ret
927 %2 = getelementptr i32, i32* %a, i64 %b
928 store i32 %1, i32* %2, align 8
932 define void @surw(i32* %a, i32 %b, i32 %c) {
933 ; RV32XTHEADMEMIDX-LABEL: surw:
934 ; RV32XTHEADMEMIDX: # %bb.0:
935 ; RV32XTHEADMEMIDX-NEXT: add a2, a2, a2
936 ; RV32XTHEADMEMIDX-NEXT: th.srw a2, a0, a1, 2
937 ; RV32XTHEADMEMIDX-NEXT: ret
939 ; RV64XTHEADMEMIDX-LABEL: surw:
940 ; RV64XTHEADMEMIDX: # %bb.0:
941 ; RV64XTHEADMEMIDX-NEXT: add a2, a2, a2
942 ; RV64XTHEADMEMIDX-NEXT: th.surw a2, a0, a1, 2
943 ; RV64XTHEADMEMIDX-NEXT: ret
944 %1 = zext i32 %b to i64
946 %3 = getelementptr i32, i32* %a, i64 %1
947 store i32 %2, i32* %3, align 8
951 define void @srd(i64* %a, i64 %b, i64 %c) {
952 ; RV32XTHEADMEMIDX-LABEL: srd:
953 ; RV32XTHEADMEMIDX: # %bb.0:
954 ; RV32XTHEADMEMIDX-NEXT: add a2, a3, a3
955 ; RV32XTHEADMEMIDX-NEXT: sltu a3, a2, a3
956 ; RV32XTHEADMEMIDX-NEXT: add a4, a4, a4
957 ; RV32XTHEADMEMIDX-NEXT: add a3, a4, a3
958 ; RV32XTHEADMEMIDX-NEXT: slli a4, a1, 3
959 ; RV32XTHEADMEMIDX-NEXT: add a4, a0, a4
960 ; RV32XTHEADMEMIDX-NEXT: th.srw a2, a0, a1, 3
961 ; RV32XTHEADMEMIDX-NEXT: sw a3, 4(a4)
962 ; RV32XTHEADMEMIDX-NEXT: ret
964 ; RV64XTHEADMEMIDX-LABEL: srd:
965 ; RV64XTHEADMEMIDX: # %bb.0:
966 ; RV64XTHEADMEMIDX-NEXT: add a2, a2, a2
967 ; RV64XTHEADMEMIDX-NEXT: th.srd a2, a0, a1, 3
968 ; RV64XTHEADMEMIDX-NEXT: ret
970 %2 = getelementptr i64, i64* %a, i64 %b
971 store i64 %1, i64* %2, align 8
975 define void @surd(i64* %a, i32 %b, i64 %c) {
976 ; RV32XTHEADMEMIDX-LABEL: surd:
977 ; RV32XTHEADMEMIDX: # %bb.0:
978 ; RV32XTHEADMEMIDX-NEXT: add a4, a2, a2
979 ; RV32XTHEADMEMIDX-NEXT: sltu a2, a4, a2
980 ; RV32XTHEADMEMIDX-NEXT: add a3, a3, a3
981 ; RV32XTHEADMEMIDX-NEXT: add a2, a3, a2
982 ; RV32XTHEADMEMIDX-NEXT: slli a3, a1, 3
983 ; RV32XTHEADMEMIDX-NEXT: add a3, a0, a3
984 ; RV32XTHEADMEMIDX-NEXT: th.srw a4, a0, a1, 3
985 ; RV32XTHEADMEMIDX-NEXT: sw a2, 4(a3)
986 ; RV32XTHEADMEMIDX-NEXT: ret
988 ; RV64XTHEADMEMIDX-LABEL: surd:
989 ; RV64XTHEADMEMIDX: # %bb.0:
990 ; RV64XTHEADMEMIDX-NEXT: add a2, a2, a2
991 ; RV64XTHEADMEMIDX-NEXT: th.surd a2, a0, a1, 3
992 ; RV64XTHEADMEMIDX-NEXT: ret
993 %1 = zext i32 %b to i64
995 %3 = getelementptr i64, i64* %a, i64 %1
996 store i64 %2, i64* %3, align 8
1000 define i32* @test_simm5(i32* %base, i32 %a, i32 %b) {
1001 ; RV32XTHEADMEMIDX-LABEL: test_simm5:
1002 ; RV32XTHEADMEMIDX: # %bb.0:
1003 ; RV32XTHEADMEMIDX-NEXT: add a1, a1, a2
1004 ; RV32XTHEADMEMIDX-NEXT: th.swia a1, (a0), -12, 2
1005 ; RV32XTHEADMEMIDX-NEXT: ret
1007 ; RV64XTHEADMEMIDX-LABEL: test_simm5:
1008 ; RV64XTHEADMEMIDX: # %bb.0:
1009 ; RV64XTHEADMEMIDX-NEXT: add a1, a1, a2
1010 ; RV64XTHEADMEMIDX-NEXT: th.swia a1, (a0), -12, 2
1011 ; RV64XTHEADMEMIDX-NEXT: ret
1012 %addr.1 = getelementptr i32, i32* %base, i32 -12
1013 %res = add i32 %a, %b
1014 store i32 %res, i32* %base
1018 define i64 @lrd_large_shift(i64* %a, i64 %b) {
1019 ; RV32XTHEADMEMIDX-LABEL: lrd_large_shift:
1020 ; RV32XTHEADMEMIDX: # %bb.0:
1021 ; RV32XTHEADMEMIDX-NEXT: slli a1, a1, 5
1022 ; RV32XTHEADMEMIDX-NEXT: add a1, a1, a0
1023 ; RV32XTHEADMEMIDX-NEXT: lw a0, 384(a1)
1024 ; RV32XTHEADMEMIDX-NEXT: lw a1, 388(a1)
1025 ; RV32XTHEADMEMIDX-NEXT: ret
1027 ; RV64XTHEADMEMIDX-LABEL: lrd_large_shift:
1028 ; RV64XTHEADMEMIDX: # %bb.0:
1029 ; RV64XTHEADMEMIDX-NEXT: slli a1, a1, 5
1030 ; RV64XTHEADMEMIDX-NEXT: add a0, a1, a0
1031 ; RV64XTHEADMEMIDX-NEXT: ld a0, 384(a0)
1032 ; RV64XTHEADMEMIDX-NEXT: ret
1035 %3 = getelementptr i64, i64* %a, i64 %2
1036 %4 = load i64, i64* %3, align 8
1040 define i64 @lrd_large_offset(i64* %a, i64 %b) {
1041 ; RV32XTHEADMEMIDX-LABEL: lrd_large_offset:
1042 ; RV32XTHEADMEMIDX: # %bb.0:
1043 ; RV32XTHEADMEMIDX-NEXT: slli a1, a1, 3
1044 ; RV32XTHEADMEMIDX-NEXT: add a0, a1, a0
1045 ; RV32XTHEADMEMIDX-NEXT: lui a1, 23
1046 ; RV32XTHEADMEMIDX-NEXT: addi a1, a1, 1792
1047 ; RV32XTHEADMEMIDX-NEXT: add a1, a0, a1
1048 ; RV32XTHEADMEMIDX-NEXT: lw a0, 0(a1)
1049 ; RV32XTHEADMEMIDX-NEXT: lw a1, 4(a1)
1050 ; RV32XTHEADMEMIDX-NEXT: ret
1052 ; RV64XTHEADMEMIDX-LABEL: lrd_large_offset:
1053 ; RV64XTHEADMEMIDX: # %bb.0:
1054 ; RV64XTHEADMEMIDX-NEXT: slli a1, a1, 3
1055 ; RV64XTHEADMEMIDX-NEXT: add a0, a1, a0
1056 ; RV64XTHEADMEMIDX-NEXT: lui a1, 23
1057 ; RV64XTHEADMEMIDX-NEXT: add a0, a0, a1
1058 ; RV64XTHEADMEMIDX-NEXT: ld a0, 1792(a0)
1059 ; RV64XTHEADMEMIDX-NEXT: ret
1060 %1 = add i64 %b, 12000
1061 %2 = getelementptr i64, i64* %a, i64 %1
1062 %3 = load i64, i64* %2, align 8