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
4 # Test that a spill of a copy of exec is not folded to be a spill of exec directly.
8 name: merge_sgpr_spill_into_copy_from_exec_lo
9 tracksRegLiveness: true
14 ; CHECK-LABEL: name: merge_sgpr_spill_into_copy_from_exec_lo
15 ; CHECK: renamable $vgpr0 = IMPLICIT_DEF
16 ; CHECK-NEXT: S_NOP 0, implicit-def $exec_lo
17 ; CHECK-NEXT: $sgpr0 = S_MOV_B32 $exec_lo
18 ; CHECK-NEXT: renamable $vgpr0 = V_WRITELANE_B32 killed $sgpr0, 0, killed $vgpr0
19 ; CHECK-NEXT: $sgpr0 = V_READLANE_B32 $vgpr0, 0
20 ; CHECK-NEXT: S_NOP 0, implicit-def dead renamable $sgpr1, implicit-def dead renamable $sgpr0, implicit killed renamable $sgpr0
21 ; CHECK-NEXT: $sgpr0 = V_READLANE_B32 killed $vgpr0, 0
22 ; CHECK-NEXT: $exec_lo = S_MOV_B32 killed $sgpr0
23 ; CHECK-NEXT: S_SENDMSG 0, implicit $m0, implicit $exec
24 S_NOP 0, implicit-def $exec_lo
25 %0:sreg_32 = COPY $exec_lo
26 S_NOP 0, implicit-def %1:sreg_32, implicit-def %2:sreg_32, implicit %0
28 S_SENDMSG 0, implicit $m0, implicit $exec
33 name: merge_sgpr_spill_into_copy_from_exec_hi
34 tracksRegLiveness: true
39 ; CHECK-LABEL: name: merge_sgpr_spill_into_copy_from_exec_hi
40 ; CHECK: renamable $vgpr0 = IMPLICIT_DEF
41 ; CHECK-NEXT: S_NOP 0, implicit-def $exec_hi
42 ; CHECK-NEXT: $sgpr0 = S_MOV_B32 $exec_hi
43 ; CHECK-NEXT: renamable $vgpr0 = V_WRITELANE_B32 killed $sgpr0, 0, killed $vgpr0
44 ; CHECK-NEXT: $sgpr0 = V_READLANE_B32 $vgpr0, 0
45 ; CHECK-NEXT: S_NOP 0, implicit-def dead renamable $sgpr1, implicit-def dead renamable $sgpr0, implicit killed renamable $sgpr0
46 ; CHECK-NEXT: $sgpr0 = V_READLANE_B32 killed $vgpr0, 0
47 ; CHECK-NEXT: $exec_hi = S_MOV_B32 killed $sgpr0
48 ; CHECK-NEXT: S_SENDMSG 0, implicit $m0, implicit $exec
49 S_NOP 0, implicit-def $exec_hi
50 %0:sreg_32 = COPY $exec_hi
51 S_NOP 0, implicit-def %1:sreg_32, implicit-def %2:sreg_32, implicit %0
53 S_SENDMSG 0, implicit $m0, implicit $exec
58 name: merge_sgpr_spill_into_copy_from_exec
59 tracksRegLiveness: true
64 ; CHECK-LABEL: name: merge_sgpr_spill_into_copy_from_exec
65 ; CHECK: renamable $vgpr0 = IMPLICIT_DEF
66 ; CHECK-NEXT: S_NOP 0, implicit-def $exec
67 ; CHECK-NEXT: $sgpr0_sgpr1 = S_MOV_B64 $exec
68 ; CHECK-NEXT: renamable $vgpr0 = V_WRITELANE_B32 killed $sgpr0, 0, killed $vgpr0, implicit-def $sgpr0_sgpr1, implicit $sgpr0_sgpr1
69 ; CHECK-NEXT: renamable $vgpr0 = V_WRITELANE_B32 killed $sgpr1, 1, killed $vgpr0, implicit $sgpr0_sgpr1
70 ; CHECK-NEXT: $sgpr0 = V_READLANE_B32 $vgpr0, 0, implicit-def $sgpr0_sgpr1
71 ; CHECK-NEXT: $sgpr1 = V_READLANE_B32 $vgpr0, 1
72 ; CHECK-NEXT: S_NOP 0, implicit-def dead renamable $sgpr2_sgpr3, implicit-def dead renamable $sgpr0_sgpr1, implicit killed renamable $sgpr0_sgpr1
73 ; CHECK-NEXT: $sgpr0 = V_READLANE_B32 $vgpr0, 0, implicit-def $sgpr0_sgpr1
74 ; CHECK-NEXT: $sgpr1 = V_READLANE_B32 killed $vgpr0, 1
75 ; CHECK-NEXT: $exec = S_MOV_B64 killed $sgpr0_sgpr1
76 ; CHECK-NEXT: S_SENDMSG 0, implicit $m0, implicit $exec
77 S_NOP 0, implicit-def $exec
78 %0:sreg_64 = COPY $exec
79 S_NOP 0, implicit-def %1:sreg_64, implicit-def %2:sreg_64, implicit %0
81 S_SENDMSG 0, implicit $m0, implicit $exec
85 # Test that a reload into a copy of exec is not folded to be a reload of exec directly.
89 name: reload_sgpr_spill_into_copy_to_exec_lo
90 tracksRegLiveness: true
95 ; CHECK-LABEL: name: reload_sgpr_spill_into_copy_to_exec_lo
96 ; CHECK: renamable $vgpr0 = IMPLICIT_DEF
97 ; CHECK-NEXT: S_NOP 0, implicit-def renamable $sgpr0, implicit-def dead renamable $sgpr1, implicit-def $exec_lo
98 ; CHECK-NEXT: renamable $vgpr0 = V_WRITELANE_B32 killed $sgpr0, 0, killed $vgpr0
99 ; CHECK-NEXT: $sgpr0 = V_READLANE_B32 $vgpr0, 0
100 ; CHECK-NEXT: S_NOP 0, implicit killed renamable $sgpr0, implicit-def dead renamable $sgpr1, implicit-def dead renamable $sgpr0
101 ; CHECK-NEXT: $sgpr0 = V_READLANE_B32 killed $vgpr0, 0
102 ; CHECK-NEXT: $exec_lo = S_MOV_B32 killed $sgpr0
103 ; CHECK-NEXT: S_SENDMSG 0, implicit $m0, implicit $exec
104 S_NOP 0, implicit-def %0:sreg_32, implicit-def %1:sreg_32, implicit-def $exec_lo
105 S_NOP 0, implicit %0, implicit-def %3:sreg_32, implicit-def %4:sreg_32
107 S_SENDMSG 0, implicit $m0, implicit $exec
112 name: reload_sgpr_spill_into_copy_to_exec_hi
113 tracksRegLiveness: true
115 isEntryFunction: true
118 ; CHECK-LABEL: name: reload_sgpr_spill_into_copy_to_exec_hi
119 ; CHECK: renamable $vgpr0 = IMPLICIT_DEF
120 ; CHECK-NEXT: S_NOP 0, implicit-def renamable $sgpr0, implicit-def dead renamable $sgpr1, implicit-def $exec_hi
121 ; CHECK-NEXT: renamable $vgpr0 = V_WRITELANE_B32 killed $sgpr0, 0, killed $vgpr0
122 ; CHECK-NEXT: $sgpr0 = V_READLANE_B32 $vgpr0, 0
123 ; CHECK-NEXT: S_NOP 0, implicit killed renamable $sgpr0, implicit-def dead renamable $sgpr1, implicit-def dead renamable $sgpr0
124 ; CHECK-NEXT: $sgpr0 = V_READLANE_B32 killed $vgpr0, 0
125 ; CHECK-NEXT: $exec_hi = S_MOV_B32 killed $sgpr0
126 ; CHECK-NEXT: S_SENDMSG 0, implicit $m0, implicit $exec
127 S_NOP 0, implicit-def %0:sreg_32, implicit-def %1:sreg_32, implicit-def $exec_hi
128 S_NOP 0, implicit %0, implicit-def %3:sreg_32, implicit-def %4:sreg_32
130 S_SENDMSG 0, implicit $m0, implicit $exec
135 name: reload_sgpr_spill_into_copy_to_exec
136 tracksRegLiveness: true
138 isEntryFunction: true
141 ; CHECK-LABEL: name: reload_sgpr_spill_into_copy_to_exec
142 ; CHECK: renamable $vgpr0 = IMPLICIT_DEF
143 ; CHECK-NEXT: S_NOP 0, implicit-def renamable $sgpr0_sgpr1, implicit-def dead renamable $sgpr2_sgpr3, implicit-def $exec
144 ; CHECK-NEXT: renamable $vgpr0 = V_WRITELANE_B32 killed $sgpr0, 0, killed $vgpr0, implicit-def $sgpr0_sgpr1, implicit $sgpr0_sgpr1
145 ; CHECK-NEXT: renamable $vgpr0 = V_WRITELANE_B32 killed $sgpr1, 1, killed $vgpr0, implicit $sgpr0_sgpr1
146 ; CHECK-NEXT: $sgpr0 = V_READLANE_B32 $vgpr0, 0, implicit-def $sgpr0_sgpr1
147 ; CHECK-NEXT: $sgpr1 = V_READLANE_B32 $vgpr0, 1
148 ; CHECK-NEXT: S_NOP 0, implicit killed renamable $sgpr0_sgpr1, implicit-def dead renamable $sgpr2_sgpr3, implicit-def dead renamable $sgpr0_sgpr1
149 ; CHECK-NEXT: $sgpr0 = V_READLANE_B32 $vgpr0, 0, implicit-def $sgpr0_sgpr1
150 ; CHECK-NEXT: $sgpr1 = V_READLANE_B32 killed $vgpr0, 1
151 ; CHECK-NEXT: $exec = S_MOV_B64 killed $sgpr0_sgpr1
152 ; CHECK-NEXT: S_SENDMSG 0, implicit $m0, implicit $exec
153 S_NOP 0, implicit-def %0:sreg_64, implicit-def %1:sreg_64, implicit-def $exec
154 S_NOP 0, implicit %0, implicit-def %3:sreg_64, implicit-def %4:sreg_64
156 S_SENDMSG 0, implicit $m0, implicit $exec