1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -mtriple=riscv64 -run-pass=legalizer %s -o - \
4 # RUN: llc -mtriple=riscv64 -mattr=+unaligned-scalar-mem -run-pass=legalizer %s -o - \
5 # RUN: | FileCheck %s --check-prefix=UNALIGNED
10 tracksRegLiveness: true
24 ; CHECK-LABEL: name: store_i8
25 ; CHECK: liveins: $x10, $x11
27 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x10
28 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(p0) = COPY $x11
29 ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s16) = G_TRUNC [[COPY]](s64)
30 ; CHECK-NEXT: G_STORE [[TRUNC]](s16), [[COPY1]](p0) :: (store (s8))
31 ; CHECK-NEXT: PseudoRET
33 ; UNALIGNED-LABEL: name: store_i8
34 ; UNALIGNED: liveins: $x10, $x11
35 ; UNALIGNED-NEXT: {{ $}}
36 ; UNALIGNED-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x10
37 ; UNALIGNED-NEXT: [[COPY1:%[0-9]+]]:_(p0) = COPY $x11
38 ; UNALIGNED-NEXT: [[TRUNC:%[0-9]+]]:_(s16) = G_TRUNC [[COPY]](s64)
39 ; UNALIGNED-NEXT: G_STORE [[TRUNC]](s16), [[COPY1]](p0) :: (store (s8))
40 ; UNALIGNED-NEXT: PseudoRET
42 %0:_(s8) = G_TRUNC %2(s64)
44 G_STORE %0(s8), %1(p0) :: (store (s8))
51 tracksRegLiveness: true
65 ; CHECK-LABEL: name: store_i16
66 ; CHECK: liveins: $x10, $x11
68 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x10
69 ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s16) = G_TRUNC [[COPY]](s64)
70 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(p0) = COPY $x11
71 ; CHECK-NEXT: G_STORE [[TRUNC]](s16), [[COPY1]](p0) :: (store (s16))
72 ; CHECK-NEXT: PseudoRET
74 ; UNALIGNED-LABEL: name: store_i16
75 ; UNALIGNED: liveins: $x10, $x11
76 ; UNALIGNED-NEXT: {{ $}}
77 ; UNALIGNED-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x10
78 ; UNALIGNED-NEXT: [[TRUNC:%[0-9]+]]:_(s16) = G_TRUNC [[COPY]](s64)
79 ; UNALIGNED-NEXT: [[COPY1:%[0-9]+]]:_(p0) = COPY $x11
80 ; UNALIGNED-NEXT: G_STORE [[TRUNC]](s16), [[COPY1]](p0) :: (store (s16))
81 ; UNALIGNED-NEXT: PseudoRET
83 %0:_(s16) = G_TRUNC %2(s64)
85 G_STORE %0(s16), %1(p0) :: (store (s16))
92 tracksRegLiveness: true
106 ; CHECK-LABEL: name: store_i32
107 ; CHECK: liveins: $x10, $x11
109 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x10
110 ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64)
111 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(p0) = COPY $x11
112 ; CHECK-NEXT: G_STORE [[TRUNC]](s32), [[COPY1]](p0) :: (store (s32))
113 ; CHECK-NEXT: PseudoRET
115 ; UNALIGNED-LABEL: name: store_i32
116 ; UNALIGNED: liveins: $x10, $x11
117 ; UNALIGNED-NEXT: {{ $}}
118 ; UNALIGNED-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x10
119 ; UNALIGNED-NEXT: [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64)
120 ; UNALIGNED-NEXT: [[COPY1:%[0-9]+]]:_(p0) = COPY $x11
121 ; UNALIGNED-NEXT: G_STORE [[TRUNC]](s32), [[COPY1]](p0) :: (store (s32))
122 ; UNALIGNED-NEXT: PseudoRET
123 %2:_(s64) = COPY $x10
124 %0:_(s32) = G_TRUNC %2(s64)
126 G_STORE %0(s32), %1(p0) :: (store (s32))
133 tracksRegLiveness: true
135 - { id: 0, class: _ }
136 - { id: 1, class: _ }
146 ; CHECK-LABEL: name: store_i64
147 ; CHECK: liveins: $x10, $x11
149 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x10
150 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(p0) = COPY $x11
151 ; CHECK-NEXT: G_STORE [[COPY]](s64), [[COPY1]](p0) :: (store (s64))
152 ; CHECK-NEXT: PseudoRET
154 ; UNALIGNED-LABEL: name: store_i64
155 ; UNALIGNED: liveins: $x10, $x11
156 ; UNALIGNED-NEXT: {{ $}}
157 ; UNALIGNED-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x10
158 ; UNALIGNED-NEXT: [[COPY1:%[0-9]+]]:_(p0) = COPY $x11
159 ; UNALIGNED-NEXT: G_STORE [[COPY]](s64), [[COPY1]](p0) :: (store (s64))
160 ; UNALIGNED-NEXT: PseudoRET
161 %0:_(s64) = COPY $x10
163 G_STORE %0(s64), %1(p0) :: (store (s64))
170 tracksRegLiveness: true
172 - { id: 0, class: _ }
173 - { id: 1, class: _ }
183 ; CHECK-LABEL: name: store_i128
184 ; CHECK: liveins: $x10, $x11
186 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x10
187 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(p0) = COPY $x11
188 ; CHECK-NEXT: G_STORE [[COPY]](s64), [[COPY1]](p0) :: (store (s64))
189 ; CHECK-NEXT: PseudoRET
191 ; UNALIGNED-LABEL: name: store_i128
192 ; UNALIGNED: liveins: $x10, $x11
193 ; UNALIGNED-NEXT: {{ $}}
194 ; UNALIGNED-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x10
195 ; UNALIGNED-NEXT: [[COPY1:%[0-9]+]]:_(p0) = COPY $x11
196 ; UNALIGNED-NEXT: G_STORE [[COPY]](s64), [[COPY1]](p0) :: (store (s64))
197 ; UNALIGNED-NEXT: PseudoRET
198 %0:_(s64) = COPY $x10
200 G_STORE %0(s64), %1(p0) :: (store (s64))
207 tracksRegLiveness: true
209 - { id: 0, class: _ }
210 - { id: 1, class: _ }
220 ; CHECK-LABEL: name: store_ptr
221 ; CHECK: liveins: $x10, $x11
223 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(p0) = COPY $x10
224 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(p0) = COPY $x11
225 ; CHECK-NEXT: G_STORE [[COPY]](p0), [[COPY1]](p0) :: (store (p0))
226 ; CHECK-NEXT: PseudoRET
228 ; UNALIGNED-LABEL: name: store_ptr
229 ; UNALIGNED: liveins: $x10, $x11
230 ; UNALIGNED-NEXT: {{ $}}
231 ; UNALIGNED-NEXT: [[COPY:%[0-9]+]]:_(p0) = COPY $x10
232 ; UNALIGNED-NEXT: [[COPY1:%[0-9]+]]:_(p0) = COPY $x11
233 ; UNALIGNED-NEXT: G_STORE [[COPY]](p0), [[COPY1]](p0) :: (store (p0))
234 ; UNALIGNED-NEXT: PseudoRET
237 G_STORE %0(p0), %1(p0) :: (store (p0))
242 name: store_i16_unaligned
244 tracksRegLiveness: true
246 - { id: 0, class: _ }
247 - { id: 1, class: _ }
248 - { id: 2, class: _ }
258 ; CHECK-LABEL: name: store_i16_unaligned
259 ; CHECK: liveins: $x10, $x11
261 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x10
262 ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s16) = G_TRUNC [[COPY]](s64)
263 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(p0) = COPY $x11
264 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(s16) = COPY [[TRUNC]](s16)
265 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 8
266 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 65535
267 ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s64) = G_AND [[COPY]], [[C1]]
268 ; CHECK-NEXT: [[LSHR:%[0-9]+]]:_(s64) = G_LSHR [[AND]], [[C]](s64)
269 ; CHECK-NEXT: [[TRUNC1:%[0-9]+]]:_(s16) = G_TRUNC [[LSHR]](s64)
270 ; CHECK-NEXT: [[C2:%[0-9]+]]:_(s64) = G_CONSTANT i64 1
271 ; CHECK-NEXT: [[PTR_ADD:%[0-9]+]]:_(p0) = G_PTR_ADD [[COPY1]], [[C2]](s64)
272 ; CHECK-NEXT: G_STORE [[COPY2]](s16), [[COPY1]](p0) :: (store (s8))
273 ; CHECK-NEXT: G_STORE [[TRUNC1]](s16), [[PTR_ADD]](p0) :: (store (s8) into unknown-address + 1)
274 ; CHECK-NEXT: PseudoRET
276 ; UNALIGNED-LABEL: name: store_i16_unaligned
277 ; UNALIGNED: liveins: $x10, $x11
278 ; UNALIGNED-NEXT: {{ $}}
279 ; UNALIGNED-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x10
280 ; UNALIGNED-NEXT: [[TRUNC:%[0-9]+]]:_(s16) = G_TRUNC [[COPY]](s64)
281 ; UNALIGNED-NEXT: [[COPY1:%[0-9]+]]:_(p0) = COPY $x11
282 ; UNALIGNED-NEXT: G_STORE [[TRUNC]](s16), [[COPY1]](p0) :: (store (s16), align 1)
283 ; UNALIGNED-NEXT: PseudoRET
284 %2:_(s64) = COPY $x10
285 %0:_(s16) = G_TRUNC %2(s64)
287 G_STORE %0(s16), %1(p0) :: (store (s16), align 1)
292 name: store_i32_unaligned
294 tracksRegLiveness: true
296 - { id: 0, class: _ }
297 - { id: 1, class: _ }
298 - { id: 2, class: _ }
308 ; CHECK-LABEL: name: store_i32_unaligned
309 ; CHECK: liveins: $x10, $x11
311 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x10
312 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(p0) = COPY $x11
313 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 16
314 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 4294967295
315 ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s64) = G_AND [[COPY]], [[C1]]
316 ; CHECK-NEXT: [[LSHR:%[0-9]+]]:_(s64) = G_LSHR [[AND]], [[C]](s64)
317 ; CHECK-NEXT: [[C2:%[0-9]+]]:_(s64) = G_CONSTANT i64 2
318 ; CHECK-NEXT: [[PTR_ADD:%[0-9]+]]:_(p0) = G_PTR_ADD [[COPY1]], [[C2]](s64)
319 ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s16) = G_TRUNC [[COPY]](s64)
320 ; CHECK-NEXT: [[C3:%[0-9]+]]:_(s64) = G_CONSTANT i64 8
321 ; CHECK-NEXT: [[C4:%[0-9]+]]:_(s64) = G_CONSTANT i64 65535
322 ; CHECK-NEXT: [[AND1:%[0-9]+]]:_(s64) = G_AND [[COPY]], [[C4]]
323 ; CHECK-NEXT: [[LSHR1:%[0-9]+]]:_(s64) = G_LSHR [[AND1]], [[C3]](s64)
324 ; CHECK-NEXT: [[TRUNC1:%[0-9]+]]:_(s16) = G_TRUNC [[LSHR1]](s64)
325 ; CHECK-NEXT: [[C5:%[0-9]+]]:_(s64) = G_CONSTANT i64 1
326 ; CHECK-NEXT: [[PTR_ADD1:%[0-9]+]]:_(p0) = G_PTR_ADD [[COPY1]], [[C5]](s64)
327 ; CHECK-NEXT: G_STORE [[TRUNC]](s16), [[COPY1]](p0) :: (store (s8))
328 ; CHECK-NEXT: G_STORE [[TRUNC1]](s16), [[PTR_ADD1]](p0) :: (store (s8) into unknown-address + 1)
329 ; CHECK-NEXT: [[TRUNC2:%[0-9]+]]:_(s16) = G_TRUNC [[LSHR]](s64)
330 ; CHECK-NEXT: [[C6:%[0-9]+]]:_(s64) = G_CONSTANT i64 8
331 ; CHECK-NEXT: [[AND2:%[0-9]+]]:_(s64) = G_AND [[LSHR]], [[C4]]
332 ; CHECK-NEXT: [[LSHR2:%[0-9]+]]:_(s64) = G_LSHR [[AND2]], [[C6]](s64)
333 ; CHECK-NEXT: [[TRUNC3:%[0-9]+]]:_(s16) = G_TRUNC [[LSHR2]](s64)
334 ; CHECK-NEXT: [[PTR_ADD2:%[0-9]+]]:_(p0) = G_PTR_ADD [[PTR_ADD]], [[C5]](s64)
335 ; CHECK-NEXT: G_STORE [[TRUNC2]](s16), [[PTR_ADD]](p0) :: (store (s8) into unknown-address + 2)
336 ; CHECK-NEXT: G_STORE [[TRUNC3]](s16), [[PTR_ADD2]](p0) :: (store (s8) into unknown-address + 3)
337 ; CHECK-NEXT: PseudoRET
339 ; UNALIGNED-LABEL: name: store_i32_unaligned
340 ; UNALIGNED: liveins: $x10, $x11
341 ; UNALIGNED-NEXT: {{ $}}
342 ; UNALIGNED-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x10
343 ; UNALIGNED-NEXT: [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64)
344 ; UNALIGNED-NEXT: [[COPY1:%[0-9]+]]:_(p0) = COPY $x11
345 ; UNALIGNED-NEXT: G_STORE [[TRUNC]](s32), [[COPY1]](p0) :: (store (s32), align 1)
346 ; UNALIGNED-NEXT: PseudoRET
347 %2:_(s64) = COPY $x10
348 %0:_(s32) = G_TRUNC %2(s64)
350 G_STORE %0(s32), %1(p0) :: (store (s32), align 1)
355 name: store_i32_align2
357 tracksRegLiveness: true
359 - { id: 0, class: _ }
360 - { id: 1, class: _ }
361 - { id: 2, class: _ }
371 ; CHECK-LABEL: name: store_i32_align2
372 ; CHECK: liveins: $x10, $x11
374 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x10
375 ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64)
376 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(p0) = COPY $x11
377 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(s32) = COPY [[TRUNC]](s32)
378 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 16
379 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 4294967295
380 ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s64) = G_AND [[COPY]], [[C1]]
381 ; CHECK-NEXT: [[LSHR:%[0-9]+]]:_(s64) = G_LSHR [[AND]], [[C]](s64)
382 ; CHECK-NEXT: [[TRUNC1:%[0-9]+]]:_(s32) = G_TRUNC [[LSHR]](s64)
383 ; CHECK-NEXT: [[C2:%[0-9]+]]:_(s64) = G_CONSTANT i64 2
384 ; CHECK-NEXT: [[PTR_ADD:%[0-9]+]]:_(p0) = G_PTR_ADD [[COPY1]], [[C2]](s64)
385 ; CHECK-NEXT: G_STORE [[COPY2]](s32), [[COPY1]](p0) :: (store (s16))
386 ; CHECK-NEXT: G_STORE [[TRUNC1]](s32), [[PTR_ADD]](p0) :: (store (s16) into unknown-address + 2)
387 ; CHECK-NEXT: PseudoRET
389 ; UNALIGNED-LABEL: name: store_i32_align2
390 ; UNALIGNED: liveins: $x10, $x11
391 ; UNALIGNED-NEXT: {{ $}}
392 ; UNALIGNED-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x10
393 ; UNALIGNED-NEXT: [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64)
394 ; UNALIGNED-NEXT: [[COPY1:%[0-9]+]]:_(p0) = COPY $x11
395 ; UNALIGNED-NEXT: G_STORE [[TRUNC]](s32), [[COPY1]](p0) :: (store (s32), align 2)
396 ; UNALIGNED-NEXT: PseudoRET
397 %2:_(s64) = COPY $x10
398 %0:_(s32) = G_TRUNC %2(s64)
400 G_STORE %0(s32), %1(p0) :: (store (s32), align 2)
405 name: store_i64_align2
407 tracksRegLiveness: true
409 - { id: 0, class: _ }
410 - { id: 1, class: _ }
420 ; CHECK-LABEL: name: store_i64_align2
421 ; CHECK: liveins: $x10, $x11
423 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x10
424 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(p0) = COPY $x11
425 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(s64) = COPY [[COPY]](s64)
426 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 32
427 ; CHECK-NEXT: [[LSHR:%[0-9]+]]:_(s64) = G_LSHR [[COPY2]], [[C]](s64)
428 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 4
429 ; CHECK-NEXT: [[PTR_ADD:%[0-9]+]]:_(p0) = G_PTR_ADD [[COPY1]], [[C1]](s64)
430 ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC [[COPY2]](s64)
431 ; CHECK-NEXT: [[C2:%[0-9]+]]:_(s64) = G_CONSTANT i64 16
432 ; CHECK-NEXT: [[C3:%[0-9]+]]:_(s64) = G_CONSTANT i64 4294967295
433 ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s64) = G_AND [[COPY2]], [[C3]]
434 ; CHECK-NEXT: [[LSHR1:%[0-9]+]]:_(s64) = G_LSHR [[AND]], [[C2]](s64)
435 ; CHECK-NEXT: [[TRUNC1:%[0-9]+]]:_(s32) = G_TRUNC [[LSHR1]](s64)
436 ; CHECK-NEXT: [[C4:%[0-9]+]]:_(s64) = G_CONSTANT i64 2
437 ; CHECK-NEXT: [[PTR_ADD1:%[0-9]+]]:_(p0) = G_PTR_ADD [[COPY1]], [[C4]](s64)
438 ; CHECK-NEXT: G_STORE [[TRUNC]](s32), [[COPY1]](p0) :: (store (s16))
439 ; CHECK-NEXT: G_STORE [[TRUNC1]](s32), [[PTR_ADD1]](p0) :: (store (s16) into unknown-address + 2)
440 ; CHECK-NEXT: [[TRUNC2:%[0-9]+]]:_(s32) = G_TRUNC [[LSHR]](s64)
441 ; CHECK-NEXT: [[C5:%[0-9]+]]:_(s64) = G_CONSTANT i64 16
442 ; CHECK-NEXT: [[LSHR2:%[0-9]+]]:_(s64) = G_LSHR [[LSHR]], [[C5]](s64)
443 ; CHECK-NEXT: [[TRUNC3:%[0-9]+]]:_(s32) = G_TRUNC [[LSHR2]](s64)
444 ; CHECK-NEXT: [[PTR_ADD2:%[0-9]+]]:_(p0) = G_PTR_ADD [[PTR_ADD]], [[C4]](s64)
445 ; CHECK-NEXT: G_STORE [[TRUNC2]](s32), [[PTR_ADD]](p0) :: (store (s16) into unknown-address + 4)
446 ; CHECK-NEXT: G_STORE [[TRUNC3]](s32), [[PTR_ADD2]](p0) :: (store (s16) into unknown-address + 6)
447 ; CHECK-NEXT: PseudoRET
449 ; UNALIGNED-LABEL: name: store_i64_align2
450 ; UNALIGNED: liveins: $x10, $x11
451 ; UNALIGNED-NEXT: {{ $}}
452 ; UNALIGNED-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x10
453 ; UNALIGNED-NEXT: [[COPY1:%[0-9]+]]:_(p0) = COPY $x11
454 ; UNALIGNED-NEXT: G_STORE [[COPY]](s64), [[COPY1]](p0) :: (store (s64), align 2)
455 ; UNALIGNED-NEXT: PseudoRET
456 %0:_(s64) = COPY $x10
458 G_STORE %0(s64), %1(p0) :: (store (s64), align 2)