1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx906 -verify-machineinstrs -run-pass=si-i1-copies -o - %s | FileCheck %s
4 # %bb.1 and %bb.3 loop back to each other, and thus neither dominates
6 # When the phi in %bb.3 is handled, it attempted to insert instructions
7 # in %bb.1 to handle this def, but ended up inserting mask management
8 # instructions before the def of %34. This is avoided by treating
9 # IMPLICIT_DEF specially like constants
12 name: recursive_vreg_1_phi
13 tracksRegLiveness: true
17 ; CHECK-LABEL: name: recursive_vreg_1_phi
19 ; CHECK-NEXT: successors: %bb.1(0x80000000)
20 ; CHECK-NEXT: liveins: $vgpr0, $vgpr1, $vgpr2, $sgpr4_sgpr5, $sgpr6_sgpr7, $sgpr8_sgpr9, $sgpr10_sgpr11, $sgpr14, $sgpr15, $sgpr16
22 ; CHECK-NEXT: [[DEF:%[0-9]+]]:sreg_64 = IMPLICIT_DEF
23 ; CHECK-NEXT: [[S_MOV_B32_:%[0-9]+]]:sreg_32 = S_MOV_B32 20
24 ; CHECK-NEXT: [[COPY:%[0-9]+]]:vgpr_32 = COPY [[S_MOV_B32_]]
25 ; CHECK-NEXT: [[DEF1:%[0-9]+]]:vgpr_32 = IMPLICIT_DEF
26 ; CHECK-NEXT: [[S_MOV_B32_1:%[0-9]+]]:sreg_32 = S_MOV_B32 10
27 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:vgpr_32 = COPY [[S_MOV_B32_1]]
28 ; CHECK-NEXT: [[DEF2:%[0-9]+]]:vgpr_32 = IMPLICIT_DEF
29 ; CHECK-NEXT: [[DEF3:%[0-9]+]]:vgpr_32 = IMPLICIT_DEF
30 ; CHECK-NEXT: [[V_OR_B32_e32_:%[0-9]+]]:vgpr_32 = V_OR_B32_e32 killed [[DEF3]], killed [[DEF1]], implicit $exec
31 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:vgpr_32 = COPY $vgpr0
32 ; CHECK-NEXT: [[DEF4:%[0-9]+]]:sreg_32 = IMPLICIT_DEF
33 ; CHECK-NEXT: [[V_ASHRREV_I32_e32_:%[0-9]+]]:vgpr_32 = V_ASHRREV_I32_e32 31, [[COPY2]], implicit $exec
34 ; CHECK-NEXT: [[DEF5:%[0-9]+]]:sreg_32_xm0 = IMPLICIT_DEF
35 ; CHECK-NEXT: [[REG_SEQUENCE:%[0-9]+]]:vreg_64 = REG_SEQUENCE [[COPY2]], %subreg.sub0, [[V_ASHRREV_I32_e32_]], %subreg.sub1
36 ; CHECK-NEXT: [[S_MOV_B32_2:%[0-9]+]]:sreg_32 = S_MOV_B32 2
37 ; CHECK-NEXT: [[COPY3:%[0-9]+]]:sgpr_32 = COPY killed [[S_MOV_B32_2]]
38 ; CHECK-NEXT: [[V_LSHL_B64_e64_:%[0-9]+]]:vreg_64 = V_LSHL_B64_e64 killed [[REG_SEQUENCE]], [[COPY3]], implicit $exec
39 ; CHECK-NEXT: [[FLAT_LOAD_DWORD:%[0-9]+]]:vgpr_32 = FLAT_LOAD_DWORD killed [[V_LSHL_B64_e64_]], 0, 0, implicit $exec, implicit $flat_scr :: (load (s32), addrspace 1)
40 ; CHECK-NEXT: [[S_MOV_B32_3:%[0-9]+]]:sreg_32 = S_MOV_B32 0
41 ; CHECK-NEXT: [[S_MOV_B32_4:%[0-9]+]]:sreg_32 = S_MOV_B32 68
42 ; CHECK-NEXT: [[COPY4:%[0-9]+]]:vgpr_32 = COPY killed [[S_MOV_B32_4]]
43 ; CHECK-NEXT: [[COPY5:%[0-9]+]]:vgpr_32 = COPY [[S_MOV_B32_3]]
44 ; CHECK-NEXT: [[REG_SEQUENCE1:%[0-9]+]]:vreg_64 = REG_SEQUENCE killed [[COPY4]], %subreg.sub0, [[COPY5]], %subreg.sub1
45 ; CHECK-NEXT: [[S_MOV_B32_5:%[0-9]+]]:sreg_32 = S_MOV_B32 432
46 ; CHECK-NEXT: [[V_MAD_I64_I32_e64_:%[0-9]+]]:vreg_64, [[V_MAD_I64_I32_e64_1:%[0-9]+]]:sreg_64 = V_MAD_I64_I32_e64 killed [[FLAT_LOAD_DWORD]], killed [[S_MOV_B32_5]], [[REG_SEQUENCE1]], 0, implicit $exec
47 ; CHECK-NEXT: [[S_MOV_B64_:%[0-9]+]]:sreg_64 = S_MOV_B64 0
48 ; CHECK-NEXT: [[DEF6:%[0-9]+]]:sreg_64 = IMPLICIT_DEF
51 ; CHECK-NEXT: successors: %bb.2(0x40000000), %bb.3(0x40000000)
53 ; CHECK-NEXT: [[PHI:%[0-9]+]]:sreg_64 = PHI [[DEF6]], %bb.0, %31, %bb.3
54 ; CHECK-NEXT: [[PHI1:%[0-9]+]]:sreg_64 = PHI [[S_MOV_B64_]], %bb.0, %54, %bb.3
55 ; CHECK-NEXT: [[PHI2:%[0-9]+]]:sreg_32 = PHI [[S_MOV_B32_3]], %bb.0, %29, %bb.3
56 ; CHECK-NEXT: [[S_MOV_B32_6:%[0-9]+]]:sreg_32 = S_MOV_B32 0
57 ; CHECK-NEXT: [[S_ANDN2_B64_:%[0-9]+]]:sreg_64 = S_ANDN2_B64 [[PHI]], $exec, implicit-def $scc
58 ; CHECK-NEXT: [[COPY6:%[0-9]+]]:sreg_64 = COPY [[S_ANDN2_B64_]]
59 ; CHECK-NEXT: S_CMP_EQ_U32 [[PHI2]], killed [[S_MOV_B32_6]], implicit-def $scc
60 ; CHECK-NEXT: [[S_MOV_B64_1:%[0-9]+]]:sreg_64 = S_MOV_B64 -1
61 ; CHECK-NEXT: [[DEF7:%[0-9]+]]:sreg_64 = IMPLICIT_DEF
62 ; CHECK-NEXT: S_CBRANCH_SCC1 %bb.3, implicit $scc
63 ; CHECK-NEXT: S_BRANCH %bb.2
66 ; CHECK-NEXT: successors: %bb.3(0x80000000)
68 ; CHECK-NEXT: [[FLAT_LOAD_DWORD1:%[0-9]+]]:vgpr_32 = FLAT_LOAD_DWORD [[V_MAD_I64_I32_e64_]], 0, 0, implicit $exec, implicit $flat_scr :: (load (s32), addrspace 1)
69 ; CHECK-NEXT: [[S_MOV_B32_7:%[0-9]+]]:sreg_32 = S_MOV_B32 6
70 ; CHECK-NEXT: [[COPY7:%[0-9]+]]:vgpr_32 = COPY [[S_MOV_B32_7]]
71 ; CHECK-NEXT: [[V_LSHR_B32_e32_:%[0-9]+]]:vgpr_32 = V_LSHR_B32_e32 killed [[FLAT_LOAD_DWORD1]], killed [[COPY7]], implicit $exec
72 ; CHECK-NEXT: [[DEF8:%[0-9]+]]:sreg_32 = IMPLICIT_DEF
73 ; CHECK-NEXT: [[V_AND_B32_e64_:%[0-9]+]]:vgpr_32 = V_AND_B32_e64 1, [[V_LSHR_B32_e32_]], implicit $exec
74 ; CHECK-NEXT: [[V_CMP_EQ_U32_e64_:%[0-9]+]]:sreg_64 = V_CMP_EQ_U32_e64 killed [[V_AND_B32_e64_]], 1, implicit $exec
75 ; CHECK-NEXT: [[COPY8:%[0-9]+]]:sreg_64 = COPY [[PHI1]]
76 ; CHECK-NEXT: [[S_AND_B64_:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY8]], killed [[V_CMP_EQ_U32_e64_]], implicit-def dead $scc
77 ; CHECK-NEXT: [[COPY9:%[0-9]+]]:sreg_64 = COPY [[PHI1]]
78 ; CHECK-NEXT: [[S_OR_B64_:%[0-9]+]]:sreg_64 = S_OR_B64 killed [[S_AND_B64_]], [[COPY9]], implicit-def dead $scc
79 ; CHECK-NEXT: [[S_MOV_B64_2:%[0-9]+]]:sreg_64 = S_MOV_B64 0
80 ; CHECK-NEXT: [[DEF9:%[0-9]+]]:sreg_64 = IMPLICIT_DEF
81 ; CHECK-NEXT: [[S_ANDN2_B64_1:%[0-9]+]]:sreg_64 = S_ANDN2_B64 [[COPY6]], $exec, implicit-def $scc
82 ; CHECK-NEXT: [[S_AND_B64_1:%[0-9]+]]:sreg_64 = S_AND_B64 [[S_OR_B64_]], $exec, implicit-def $scc
83 ; CHECK-NEXT: [[S_OR_B64_1:%[0-9]+]]:sreg_64 = S_OR_B64 [[S_ANDN2_B64_1]], [[S_AND_B64_1]], implicit-def $scc
86 ; CHECK-NEXT: successors: %bb.4(0x00000000), %bb.1(0x80000000)
88 ; CHECK-NEXT: [[PHI3:%[0-9]+]]:sreg_64 = PHI [[COPY6]], %bb.1, [[S_OR_B64_1]], %bb.2
89 ; CHECK-NEXT: [[PHI4:%[0-9]+]]:sreg_64 = PHI [[PHI1]], %bb.1, [[DEF9]], %bb.2
90 ; CHECK-NEXT: [[PHI5:%[0-9]+]]:sreg_64_xexec = PHI [[S_MOV_B64_1]], %bb.1, [[S_MOV_B64_2]], %bb.2
91 ; CHECK-NEXT: [[S_MOV_B32_8:%[0-9]+]]:sreg_32 = S_MOV_B32 -1
92 ; CHECK-NEXT: [[V_CNDMASK_B32_e64_:%[0-9]+]]:vgpr_32 = V_CNDMASK_B32_e64 0, 0, 0, 1, [[PHI5]], implicit $exec
93 ; CHECK-NEXT: [[S_MOV_B32_9:%[0-9]+]]:sreg_32 = S_MOV_B32 1
94 ; CHECK-NEXT: [[DEF10:%[0-9]+]]:sreg_32 = IMPLICIT_DEF
95 ; CHECK-NEXT: V_CMP_NE_U32_e32 killed [[S_MOV_B32_9]], [[V_CNDMASK_B32_e64_]], implicit-def $vcc, implicit $exec
96 ; CHECK-NEXT: $vcc = S_AND_B64 $exec, $vcc, implicit-def $scc
97 ; CHECK-NEXT: [[S_ANDN2_B64_2:%[0-9]+]]:sreg_64 = S_ANDN2_B64 [[PHI4]], $exec, implicit-def $scc
98 ; CHECK-NEXT: [[S_AND_B64_2:%[0-9]+]]:sreg_64 = S_AND_B64 [[PHI3]], $exec, implicit-def $scc
99 ; CHECK-NEXT: [[S_OR_B64_2:%[0-9]+]]:sreg_64 = S_OR_B64 [[S_ANDN2_B64_2]], [[S_AND_B64_2]], implicit-def $scc
100 ; CHECK-NEXT: S_CBRANCH_VCCNZ %bb.1, implicit $vcc
101 ; CHECK-NEXT: S_BRANCH %bb.4
105 liveins: $vgpr0, $vgpr1, $vgpr2, $sgpr4_sgpr5, $sgpr6_sgpr7, $sgpr8_sgpr9, $sgpr10_sgpr11, $sgpr14, $sgpr15, $sgpr16
107 %0:sreg_64 = IMPLICIT_DEF
108 %1:sreg_32 = S_MOV_B32 20
110 %3:vgpr_32 = IMPLICIT_DEF
111 %4:sreg_32 = S_MOV_B32 10
113 %6:vgpr_32 = IMPLICIT_DEF
114 %7:vgpr_32 = IMPLICIT_DEF
115 %8:vgpr_32 = V_OR_B32_e32 killed %7, killed %3, implicit $exec
116 %9:vgpr_32 = COPY $vgpr0
117 %10:sreg_32 = IMPLICIT_DEF
118 %11:vgpr_32 = V_ASHRREV_I32_e32 31, %9, implicit $exec
119 %12:sreg_32_xm0 = IMPLICIT_DEF
120 %13:vreg_64 = REG_SEQUENCE %9, %subreg.sub0, %11, %subreg.sub1
121 %14:sreg_32 = S_MOV_B32 2
122 %15:sgpr_32 = COPY killed %14
123 %16:vreg_64 = V_LSHL_B64_e64 killed %13, %15, implicit $exec
124 %17:vgpr_32 = FLAT_LOAD_DWORD killed %16, 0, 0, implicit $exec, implicit $flat_scr :: (load (s32), addrspace 1)
125 %18:sreg_32 = S_MOV_B32 0
126 %19:sreg_32 = S_MOV_B32 68
127 %20:vgpr_32 = COPY killed %19
128 %21:vgpr_32 = COPY %18
129 %22:vreg_64 = REG_SEQUENCE killed %20, %subreg.sub0, %21, %subreg.sub1
130 %23:sreg_32 = S_MOV_B32 432
131 %24:vreg_64, %25:sreg_64 = V_MAD_I64_I32_e64 killed %17, killed %23, %22, 0, implicit $exec
132 %26:sreg_64 = S_MOV_B64 0
133 %27:vreg_1 = COPY %26, implicit $exec
136 successors: %bb.2, %bb.3
138 %28:sreg_32 = PHI %18, %bb.0, %29, %bb.3
139 %30:vreg_1 = PHI %27, %bb.0, %31, %bb.3
140 %32:sreg_32 = S_MOV_B32 0
141 S_CMP_EQ_U32 %28, killed %32, implicit-def $scc
142 %33:sreg_64 = S_MOV_B64 -1
143 %34:sreg_64 = IMPLICIT_DEF
144 %35:vreg_1 = COPY %34
145 S_CBRANCH_SCC1 %bb.3, implicit $scc
149 %36:vgpr_32 = FLAT_LOAD_DWORD %24, 0, 0, implicit $exec, implicit $flat_scr :: (load (s32), addrspace 1)
150 %37:sreg_32 = S_MOV_B32 6
151 %38:vgpr_32 = COPY %37
152 %39:vgpr_32 = V_LSHR_B32_e32 killed %36, killed %38, implicit $exec
153 %40:sreg_32 = IMPLICIT_DEF
154 %41:vgpr_32 = V_AND_B32_e64 1, %39, implicit $exec
155 %42:sreg_64 = V_CMP_EQ_U32_e64 killed %41, 1, implicit $exec
156 %43:sreg_64 = COPY %30
157 %44:sreg_64 = S_AND_B64 %43, killed %42, implicit-def dead $scc
158 %45:sreg_64 = COPY %30
159 %46:sreg_64 = S_OR_B64 killed %44, %45, implicit-def dead $scc
160 %47:sreg_64 = S_MOV_B64 0
161 %48:vreg_1 = COPY %46
164 successors: %bb.4(0x00000000), %bb.1(0x80000000)
166 %31:vreg_1 = PHI %35, %bb.1, %48, %bb.2
167 %49:sreg_64_xexec = PHI %33, %bb.1, %47, %bb.2
168 %29:sreg_32 = S_MOV_B32 -1
169 %50:vgpr_32 = V_CNDMASK_B32_e64 0, 0, 0, 1, %49, implicit $exec
170 %51:sreg_32 = S_MOV_B32 1
171 %52:sreg_32 = IMPLICIT_DEF
172 V_CMP_NE_U32_e32 killed %51, %50, implicit-def $vcc, implicit $exec
173 $vcc = S_AND_B64 $exec, $vcc, implicit-def $scc
174 S_CBRANCH_VCCNZ %bb.1, implicit $vcc