1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 2
2 # RUN: llc -o - %s -mtriple=amdgcn-- -mcpu=fiji -verify-machineinstrs -run-pass=greedy,virtregrewriter | FileCheck %s
4 define amdgpu_kernel void @func0() #0 { ret void }
5 define amdgpu_kernel void @func1() #0 { ret void }
6 define amdgpu_kernel void @splitHoist() #0 { ret void }
8 attributes #0 = { "amdgpu-num-sgpr"="12" }
11 # Make sure we only get a single spill+reload even if liverange splitting
12 # created a sequence of multiple copy instructions.
16 ; CHECK-LABEL: name: func0
17 ; CHECK: S_NOP 0, implicit-def renamable $sgpr0
18 ; CHECK-NEXT: S_NOP 0, implicit-def renamable $sgpr3
19 ; CHECK-NEXT: SI_SPILL_S128_SAVE renamable $sgpr0_sgpr1_sgpr2_sgpr3, %stack.0, implicit $exec, implicit $sp_reg :: (store (s128) into %stack.0, align 4, addrspace 5)
20 ; CHECK-NEXT: S_NOP 0, implicit-def dead $sgpr0, implicit-def dead $sgpr1, implicit-def dead $sgpr2, implicit-def dead $sgpr3, implicit-def dead $sgpr4, implicit-def dead $sgpr5, implicit-def dead $sgpr6, implicit-def dead $sgpr7, implicit-def dead $sgpr8, implicit-def dead $sgpr9, implicit-def dead $sgpr10, implicit-def dead $sgpr11
21 ; CHECK-NEXT: renamable $sgpr0_sgpr1_sgpr2_sgpr3 = SI_SPILL_S128_RESTORE %stack.0, implicit $exec, implicit $sp_reg :: (load (s128) from %stack.0, align 4, addrspace 5)
22 ; CHECK-NEXT: S_NOP 0, implicit renamable $sgpr0
23 ; CHECK-NEXT: S_NOP 0, implicit renamable $sgpr3
24 ; CHECK-NEXT: S_NOP 0, implicit renamable $sgpr0
25 ; CHECK-NEXT: S_NOP 0, implicit killed renamable $sgpr3
26 S_NOP 0, implicit-def undef %0.sub0 : sgpr_128
27 S_NOP 0, implicit-def %0.sub3 : sgpr_128
30 S_NOP 0, implicit-def dead $sgpr0, implicit-def dead $sgpr1, implicit-def dead $sgpr2, implicit-def dead $sgpr3, implicit-def dead $sgpr4, implicit-def dead $sgpr5, implicit-def dead $sgpr6, implicit-def dead $sgpr7, implicit-def dead $sgpr8, implicit-def dead $sgpr9, implicit-def dead $sgpr10, implicit-def dead $sgpr11
32 S_NOP 0, implicit %0.sub0
33 S_NOP 0, implicit %0.sub3
34 S_NOP 0, implicit %0.sub0
35 S_NOP 0, implicit %0.sub3
38 # LiveRange splitting should split this into 2 intervals with the second getting
39 # allocated to sgpr0_sgpr1 and the first to something else so we see two copies
40 # in between for the two subregisters that are alive.
42 tracksRegLiveness: true
45 liveins: $sgpr0, $sgpr1, $sgpr2
46 ; CHECK-LABEL: name: func1
47 ; CHECK: liveins: $sgpr0, $sgpr1, $sgpr2
49 ; CHECK-NEXT: renamable $sgpr4 = COPY $sgpr0
50 ; CHECK-NEXT: renamable $sgpr6 = COPY $sgpr2
51 ; CHECK-NEXT: S_NOP 0, implicit-def dead $sgpr0, implicit-def dead $sgpr1
52 ; CHECK-NEXT: S_NOP 0, implicit renamable $sgpr4
53 ; CHECK-NEXT: S_NOP 0, implicit renamable $sgpr6
54 ; CHECK-NEXT: renamable $sgpr0 = COPY killed renamable $sgpr4
55 ; CHECK-NEXT: renamable $sgpr2 = COPY renamable $sgpr6
56 ; CHECK-NEXT: S_NOP 0, implicit-def dead $sgpr4, implicit-def dead $sgpr5, implicit-def dead $sgpr6, implicit-def dead $sgpr7, implicit-def dead $sgpr8, implicit-def dead $sgpr9, implicit-def dead $sgpr10, implicit-def dead $sgpr11, implicit-def dead $sgpr12, implicit-def dead $sgpr13, implicit-def dead $sgpr14, implicit-def dead $sgpr15, implicit-def dead $vcc_lo, implicit-def dead $vcc_hi
57 ; CHECK-NEXT: S_NOP 0, implicit renamable $sgpr0
58 ; CHECK-NEXT: S_NOP 0, implicit killed renamable $sgpr2
59 undef %0.sub0 : sgpr_128 = COPY $sgpr0
62 S_NOP 0, implicit-def dead $sgpr0, implicit-def dead $sgpr1
64 S_NOP 0, implicit %0.sub0
65 S_NOP 0, implicit %0.sub2
67 ; Clobber everything but sgpr0-sgpr3
68 S_NOP 0, implicit-def dead $sgpr4, implicit-def dead $sgpr5, implicit-def dead $sgpr6, implicit-def dead $sgpr7, implicit-def dead $sgpr8, implicit-def dead $sgpr9, implicit-def dead $sgpr10, implicit-def dead $sgpr11, implicit-def dead $sgpr12, implicit-def dead $sgpr13, implicit-def dead $sgpr14, implicit-def dead $sgpr15, implicit-def dead $vcc_lo, implicit-def dead $vcc_hi
70 S_NOP 0, implicit %0.sub0
71 S_NOP 0, implicit %0.sub2
74 # Check that copy hoisting out of loops works. This mainly should not crash the
75 # compiler when it hoists a subreg copy sequence.
77 tracksRegLiveness: true
79 ; CHECK-LABEL: name: splitHoist
81 ; CHECK-NEXT: successors: %bb.1(0x40000000), %bb.2(0x40000000)
83 ; CHECK-NEXT: S_NOP 0, implicit-def renamable $sgpr0
84 ; CHECK-NEXT: S_NOP 0, implicit-def renamable $sgpr3
85 ; CHECK-NEXT: SI_SPILL_S128_SAVE renamable $sgpr0_sgpr1_sgpr2_sgpr3, %stack.0, implicit $exec, implicit $sp_reg :: (store (s128) into %stack.0, align 4, addrspace 5)
86 ; CHECK-NEXT: S_CBRANCH_VCCNZ %bb.1, implicit undef $vcc
87 ; CHECK-NEXT: S_BRANCH %bb.2
90 ; CHECK-NEXT: successors: %bb.1(0x40000000), %bb.3(0x40000000)
91 ; CHECK-NEXT: liveins: $sgpr0_sgpr1_sgpr2_sgpr3:0x00000000000000C3
93 ; CHECK-NEXT: S_NOP 0, implicit renamable $sgpr0
94 ; CHECK-NEXT: S_NOP 0, implicit-def dead $sgpr0, implicit-def dead $sgpr1, implicit-def dead $sgpr2, implicit-def dead $sgpr3, implicit-def dead $sgpr4, implicit-def dead $sgpr5, implicit-def dead $sgpr6, implicit-def dead $sgpr7, implicit-def dead $sgpr8, implicit-def dead $sgpr9, implicit-def dead $sgpr10, implicit-def dead $sgpr11
95 ; CHECK-NEXT: renamable $sgpr0_sgpr1_sgpr2_sgpr3 = SI_SPILL_S128_RESTORE %stack.0, implicit $exec, implicit $sp_reg :: (load (s128) from %stack.0, align 4, addrspace 5)
96 ; CHECK-NEXT: S_CBRANCH_VCCNZ %bb.1, implicit undef $vcc
97 ; CHECK-NEXT: S_BRANCH %bb.3
100 ; CHECK-NEXT: successors: %bb.3(0x80000000)
101 ; CHECK-NEXT: liveins: $sgpr0_sgpr1_sgpr2_sgpr3:0x00000000000000C3
103 ; CHECK-NEXT: S_NOP 0, implicit-def dead $sgpr0, implicit-def dead $sgpr1, implicit-def dead $sgpr2, implicit-def dead $sgpr3, implicit-def dead $sgpr4, implicit-def dead $sgpr5, implicit-def dead $sgpr6, implicit-def dead $sgpr7, implicit-def dead $sgpr8, implicit-def dead $sgpr9, implicit-def dead $sgpr10, implicit-def dead $sgpr11
104 ; CHECK-NEXT: renamable $sgpr0_sgpr1_sgpr2_sgpr3 = SI_SPILL_S128_RESTORE %stack.0, implicit $exec, implicit $sp_reg :: (load (s128) from %stack.0, align 4, addrspace 5)
105 ; CHECK-NEXT: S_BRANCH %bb.3
108 ; CHECK-NEXT: liveins: $sgpr0_sgpr1_sgpr2_sgpr3:0x00000000000000C3
110 ; CHECK-NEXT: S_NOP 0, implicit renamable $sgpr0
111 ; CHECK-NEXT: S_NOP 0, implicit renamable $sgpr3
112 ; CHECK-NEXT: S_NOP 0, implicit renamable $sgpr0
113 ; CHECK-NEXT: S_NOP 0, implicit killed renamable $sgpr3
115 successors: %bb.1, %bb.2
116 S_NOP 0, implicit-def undef %0.sub0 : sgpr_128
117 S_NOP 0, implicit-def %0.sub3 : sgpr_128
119 S_CBRANCH_VCCNZ %bb.1, implicit undef $vcc
123 successors: %bb.1, %bb.3
124 S_NOP 0, implicit %0.sub0
127 S_NOP 0, implicit-def dead $sgpr0, implicit-def dead $sgpr1, implicit-def dead $sgpr2, implicit-def dead $sgpr3, implicit-def dead $sgpr4, implicit-def dead $sgpr5, implicit-def dead $sgpr6, implicit-def dead $sgpr7, implicit-def dead $sgpr8, implicit-def dead $sgpr9, implicit-def dead $sgpr10, implicit-def dead $sgpr11
129 S_CBRANCH_VCCNZ %bb.1, implicit undef $vcc
135 S_NOP 0, implicit-def dead $sgpr0, implicit-def dead $sgpr1, implicit-def dead $sgpr2, implicit-def dead $sgpr3, implicit-def dead $sgpr4, implicit-def dead $sgpr5, implicit-def dead $sgpr6, implicit-def dead $sgpr7, implicit-def dead $sgpr8, implicit-def dead $sgpr9, implicit-def dead $sgpr10, implicit-def dead $sgpr11
139 S_NOP 0, implicit %0.sub0
140 S_NOP 0, implicit %0.sub3
141 S_NOP 0, implicit %0.sub0
142 S_NOP 0, implicit %0.sub3