1# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2# RUN: llc -march=amdgcn -mcpu=gfx900 -run-pass=si-lower-sgpr-spills,prologepilog,machine-cp -verify-machineinstrs %s -o - | FileCheck -check-prefix=GCN %s
3
4# Make sure the initial first $sgpr1 = COPY $sgpr2 copy is not deleted
5# by the copy propagation after lowering the spill.
6
7---
8name: spill_sgpr128_use_subreg
9tracksRegLiveness: true
10machineFunctionInfo:
11  hasSpilledSGPRs: true
12  scratchRSrcReg: $sgpr100_sgpr101_sgpr102_sgpr103
13  stackPtrOffsetReg: $sgpr32
14
15stack:
16  - { id: 0, stack-id: sgpr-spill, type: spill-slot, size: 16, alignment: 4 }
17
18body:             |
19  bb.0:
20    liveins: $sgpr0, $sgpr1, $sgpr2, $sgpr3, $sgpr4, $sgpr5, $sgpr6, $sgpr7, $vgpr0, $vgpr1, $vgpr2, $vgpr3
21
22    ; GCN-LABEL: name: spill_sgpr128_use_subreg
23    ; GCN: liveins: $sgpr0, $sgpr1, $sgpr2, $sgpr3, $sgpr4, $sgpr5, $sgpr6, $sgpr7, $vgpr0, $vgpr1, $vgpr2, $vgpr3
24    ; GCN: renamable $sgpr1 = COPY $sgpr2
25    ; GCN: $vgpr0 = V_WRITELANE_B32 $sgpr0, 0, undef $vgpr0, implicit-def $sgpr0_sgpr1_sgpr2_sgpr3, implicit $sgpr0_sgpr1_sgpr2_sgpr3
26    ; GCN: $vgpr0 = V_WRITELANE_B32 $sgpr1, 1, $vgpr0, implicit $sgpr0_sgpr1_sgpr2_sgpr3
27    ; GCN: $vgpr0 = V_WRITELANE_B32 $sgpr2, 2, $vgpr0, implicit $sgpr0_sgpr1_sgpr2_sgpr3
28    ; GCN: $vgpr0 = V_WRITELANE_B32 $sgpr3, 3, $vgpr0, implicit $sgpr0_sgpr1_sgpr2_sgpr3
29    ; GCN: renamable $sgpr8 = COPY killed renamable $sgpr1
30    ; GCN: S_ENDPGM 0, implicit $sgpr8
31    renamable $sgpr1 = COPY $sgpr2
32    SI_SPILL_S128_SAVE renamable $sgpr0_sgpr1_sgpr2_sgpr3, %stack.0, implicit $exec, implicit $sgpr32 :: (store 16 into %stack.0, align 4, addrspace 5)
33    renamable $sgpr8 = COPY killed renamable $sgpr1
34    S_ENDPGM 0, implicit $sgpr8
35...
36
37---
38name: spill_sgpr128_use_kill
39tracksRegLiveness: true
40machineFunctionInfo:
41  hasSpilledSGPRs: true
42  scratchRSrcReg: $sgpr100_sgpr101_sgpr102_sgpr103
43  stackPtrOffsetReg: $sgpr32
44
45stack:
46  - { id: 0, stack-id: sgpr-spill, type: spill-slot, size: 16, alignment: 4 }
47
48body:             |
49  bb.0:
50    liveins: $sgpr0, $sgpr1, $sgpr2, $sgpr3, $sgpr4, $sgpr5, $sgpr6, $sgpr7, $vgpr0, $vgpr1, $vgpr2, $vgpr3
51
52    ; GCN-LABEL: name: spill_sgpr128_use_kill
53    ; GCN: liveins: $sgpr0, $sgpr1, $sgpr2, $sgpr3, $sgpr4, $sgpr5, $sgpr6, $sgpr7, $vgpr0, $vgpr1, $vgpr2, $vgpr3
54    ; GCN: renamable $sgpr1 = COPY $sgpr2
55    ; GCN: $vgpr0 = V_WRITELANE_B32 $sgpr0, 0, undef $vgpr0, implicit-def $sgpr0_sgpr1_sgpr2_sgpr3, implicit $sgpr0_sgpr1_sgpr2_sgpr3
56    ; GCN: $vgpr0 = V_WRITELANE_B32 $sgpr1, 1, $vgpr0, implicit $sgpr0_sgpr1_sgpr2_sgpr3
57    ; GCN: $vgpr0 = V_WRITELANE_B32 $sgpr2, 2, $vgpr0, implicit $sgpr0_sgpr1_sgpr2_sgpr3
58    ; GCN: $vgpr0 = V_WRITELANE_B32 killed $sgpr3, 3, $vgpr0, implicit killed $sgpr0_sgpr1_sgpr2_sgpr3
59    ; GCN: S_ENDPGM 0
60    renamable $sgpr1 = COPY $sgpr2
61    SI_SPILL_S128_SAVE renamable killed $sgpr0_sgpr1_sgpr2_sgpr3, %stack.0, implicit $exec, implicit $sgpr32 :: (store 16 into %stack.0, align 4, addrspace 5)
62    S_ENDPGM 0
63...
64
65---
66name: spill_vgpr128_use_subreg
67tracksRegLiveness: true
68machineFunctionInfo:
69  scratchRSrcReg: $sgpr100_sgpr101_sgpr102_sgpr103
70  stackPtrOffsetReg: $sgpr32
71
72stack:
73  - { id: 0, type: spill-slot, size: 16, alignment: 4 }
74
75body:             |
76  bb.0:
77    liveins: $vgpr0, $vgpr1, $vgpr2, $vgpr3, $vgpr4, $vgpr5, $vgpr6, $vgpr7
78
79    ; GCN-LABEL: name: spill_vgpr128_use_subreg
80    ; GCN: liveins: $vgpr0, $vgpr1, $vgpr2, $vgpr3, $vgpr4, $vgpr5, $vgpr6, $vgpr7
81    ; GCN: renamable $vgpr1 = COPY $vgpr2
82    ; GCN: BUFFER_STORE_DWORD_OFFSET $vgpr0, $sgpr100_sgpr101_sgpr102_sgpr103, $sgpr32, 0, 0, 0, 0, 0, 0, implicit $exec, implicit-def $vgpr0_vgpr1_vgpr2_vgpr3, implicit $vgpr0_vgpr1_vgpr2_vgpr3 :: (store 4 into %stack.0, addrspace 5)
83    ; GCN: BUFFER_STORE_DWORD_OFFSET $vgpr1, $sgpr100_sgpr101_sgpr102_sgpr103, $sgpr32, 4, 0, 0, 0, 0, 0, implicit $exec, implicit $vgpr0_vgpr1_vgpr2_vgpr3 :: (store 4 into %stack.0 + 4, addrspace 5)
84    ; GCN: BUFFER_STORE_DWORD_OFFSET $vgpr2, $sgpr100_sgpr101_sgpr102_sgpr103, $sgpr32, 8, 0, 0, 0, 0, 0, implicit $exec, implicit $vgpr0_vgpr1_vgpr2_vgpr3 :: (store 4 into %stack.0 + 8, addrspace 5)
85    ; GCN: BUFFER_STORE_DWORD_OFFSET $vgpr3, $sgpr100_sgpr101_sgpr102_sgpr103, $sgpr32, 12, 0, 0, 0, 0, 0, implicit $exec, implicit $vgpr0_vgpr1_vgpr2_vgpr3 :: (store 4 into %stack.0 + 12, addrspace 5)
86    ; GCN: renamable $vgpr8 = COPY killed renamable $vgpr1
87    ; GCN: S_ENDPGM 0, implicit $vgpr8
88    renamable $vgpr1 = COPY $vgpr2
89    SI_SPILL_V128_SAVE renamable $vgpr0_vgpr1_vgpr2_vgpr3, %stack.0, $sgpr32, 0, implicit $exec :: (store 16 into %stack.0, align 4, addrspace 5)
90    renamable $vgpr8 = COPY killed renamable $vgpr1
91    S_ENDPGM 0, implicit $vgpr8
92...
93
94---
95name: spill_vgpr128_use_kill
96tracksRegLiveness: true
97machineFunctionInfo:
98  scratchRSrcReg: $sgpr100_sgpr101_sgpr102_sgpr103
99  stackPtrOffsetReg: $sgpr32
100
101stack:
102  - { id: 0, type: spill-slot, size: 16, alignment: 4 }
103
104body:             |
105  bb.0:
106    liveins: $vgpr0, $vgpr1, $vgpr2, $vgpr3, $vgpr4, $vgpr5, $vgpr6, $vgpr7
107
108    ; GCN-LABEL: name: spill_vgpr128_use_kill
109    ; GCN: liveins: $vgpr0, $vgpr1, $vgpr2, $vgpr3, $vgpr4, $vgpr5, $vgpr6, $vgpr7
110    ; GCN: renamable $vgpr1 = COPY $vgpr2
111    ; GCN: BUFFER_STORE_DWORD_OFFSET killed $vgpr0, $sgpr100_sgpr101_sgpr102_sgpr103, $sgpr32, 0, 0, 0, 0, 0, 0, implicit $exec, implicit-def $vgpr0_vgpr1_vgpr2_vgpr3, implicit $vgpr0_vgpr1_vgpr2_vgpr3 :: (store 4 into %stack.0, addrspace 5)
112    ; GCN: BUFFER_STORE_DWORD_OFFSET killed $vgpr1, $sgpr100_sgpr101_sgpr102_sgpr103, $sgpr32, 4, 0, 0, 0, 0, 0, implicit $exec, implicit $vgpr0_vgpr1_vgpr2_vgpr3 :: (store 4 into %stack.0 + 4, addrspace 5)
113    ; GCN: BUFFER_STORE_DWORD_OFFSET killed $vgpr2, $sgpr100_sgpr101_sgpr102_sgpr103, $sgpr32, 8, 0, 0, 0, 0, 0, implicit $exec, implicit $vgpr0_vgpr1_vgpr2_vgpr3 :: (store 4 into %stack.0 + 8, addrspace 5)
114    ; GCN: BUFFER_STORE_DWORD_OFFSET killed $vgpr3, $sgpr100_sgpr101_sgpr102_sgpr103, $sgpr32, 12, 0, 0, 0, 0, 0, implicit $exec, implicit killed $vgpr0_vgpr1_vgpr2_vgpr3 :: (store 4 into %stack.0 + 12, addrspace 5)
115    ; GCN: S_ENDPGM 0
116    renamable $vgpr1 = COPY $vgpr2
117    SI_SPILL_V128_SAVE renamable killed $vgpr0_vgpr1_vgpr2_vgpr3, %stack.0, $sgpr32, 0, implicit $exec :: (store 16 into %stack.0, align 4, addrspace 5)
118    S_ENDPGM 0
119...
120