1# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2# RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 -verify-machineinstrs -stress-regalloc=2 -start-before=greedy -stop-after=virtregmap -o - %s | FileCheck %s
3
4# Test that a spill of a copy of m0 is not folded to be a spill of m0 directly.
5
6---
7
8name:            merge_sgpr_spill_into_copy_from_m0
9tracksRegLiveness: true
10body:             |
11  bb.0:
12
13    ; CHECK-LABEL: name: merge_sgpr_spill_into_copy_from_m0
14    ; CHECK: liveins: $vgpr0
15    ; CHECK: S_WAITCNT 0
16    ; CHECK: S_NOP 0, implicit-def $m0
17    ; CHECK: $sgpr0 = S_MOV_B32 $m0
18    ; CHECK: $vgpr0 = V_WRITELANE_B32 killed $sgpr0, 0, undef $vgpr0
19    ; CHECK: $sgpr0 = V_READLANE_B32 $vgpr0, 0
20    ; CHECK: S_NOP 0, implicit-def dead renamable $sgpr1, implicit-def dead renamable $sgpr0, implicit killed renamable $sgpr0
21    ; CHECK: $sgpr0 = V_READLANE_B32 killed $vgpr0, 0
22    ; CHECK: $m0 = S_MOV_B32 killed $sgpr0
23    ; CHECK: S_NOP 0
24    ; CHECK: S_SENDMSG 0, implicit $m0, implicit $exec
25    S_NOP 0, implicit-def $m0
26    %0:sreg_32 = COPY $m0
27    S_NOP 0, implicit-def %1:sreg_32, implicit-def %2:sreg_32, implicit %0
28    $m0 = COPY %0
29    S_SENDMSG 0, implicit $m0, implicit $exec
30
31...
32
33# Test that a reload into a copy of m0 is not folded to be a reload of m0 directly.
34
35---
36
37name:            reload_sgpr_spill_into_copy_to_m0
38tracksRegLiveness: true
39body:             |
40  bb.0:
41
42    ; CHECK-LABEL: name: reload_sgpr_spill_into_copy_to_m0
43    ; CHECK: liveins: $vgpr0
44    ; CHECK: S_WAITCNT 0
45    ; CHECK: S_NOP 0, implicit-def renamable $sgpr0, implicit-def dead renamable $sgpr1, implicit-def $m0
46    ; CHECK: $vgpr0 = V_WRITELANE_B32 killed $sgpr0, 0, undef $vgpr0
47    ; CHECK: $sgpr0 = V_READLANE_B32 $vgpr0, 0
48    ; CHECK: S_NOP 0, implicit killed renamable $sgpr0, implicit-def dead renamable $sgpr1, implicit-def dead renamable $sgpr0
49    ; CHECK: $sgpr0 = V_READLANE_B32 killed $vgpr0, 0
50    ; CHECK: $m0 = S_MOV_B32 killed $sgpr0
51    ; CHECK: S_NOP 0
52    ; CHECK: S_SENDMSG 0, implicit $m0, implicit $exec
53    S_NOP 0, implicit-def %0:sreg_32, implicit-def %1:sreg_32, implicit-def $m0
54    S_NOP 0, implicit %0, implicit-def %3:sreg_32, implicit-def %4:sreg_32
55    $m0 = COPY %0
56    S_SENDMSG 0, implicit $m0, implicit $exec
57
58...
59