1# RUN: llc -mtriple=amdgcn--amdpal -mcpu=gfx803 -run-pass=simple-register-coalescing -o - %s | FileCheck -check-prefix=GCN %s
2
3# With one version of the D48102 fix, this test failed with
4# Assertion failed: (Id != S.end() && T != S.end() && T->valno == Id->valno), function pruneSubRegValues, file ../lib/CodeGen/RegisterCoalescer.cpp, line 2870.
5
6# GCN: {{^body}}
7
8--- |
9  target datalayout = "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5"
10  target triple = "amdgcn--amdpal"
11
12  ; Function Attrs: nounwind
13  define amdgpu_cs void @_amdgpu_cs_main(<3 x i32> %arg) #0 {
14    ret void
15  }
16
17  attributes #0 = { nounwind "target-cpu"="gfx803" }
18...
19
20---
21name:            _amdgpu_cs_main
22tracksRegLiveness: true
23liveins:
24  - { reg: '$vgpr0', virtual-reg: '%0' }
25body: |
26  bb.0:
27    successors: %bb.1(0x40000000), %bb.21(0x40000000)
28    liveins: $vgpr0, $vgpr1, $vgpr2
29    %0:vgpr_32 = COPY killed $vgpr0
30    S_CBRANCH_SCC1 %bb.21, implicit undef $scc
31
32  bb.1:
33    successors: %bb.2(0x40000000), %bb.17(0x40000000)
34    S_CBRANCH_SCC1 %bb.17, implicit undef $scc
35
36  bb.2:
37    successors: %bb.4(0x40000000), %bb.3(0x40000000)
38    %1:sreg_32_xm0 = S_MOV_B32 0
39    %2:vgpr_32 = V_MOV_B32_e32 0, implicit $exec
40    undef %3.sub0:vreg_128 = COPY killed %0
41    %3.sub2:vreg_128 = COPY killed %2
42    undef %4.sub0:sgpr_256 = COPY %1
43    %4.sub1:sgpr_256 = COPY %1
44    %4.sub2:sgpr_256 = COPY %1
45    %4.sub3:sgpr_256 = COPY %1
46    %4.sub4:sgpr_256 = COPY %1
47    %4.sub5:sgpr_256 = COPY %1
48    %4.sub6:sgpr_256 = COPY %1
49    %4.sub7:sgpr_256 = COPY killed %1
50    %5:vgpr_32 = IMAGE_LOAD_V1_V4 killed %3, killed %4, 1, -1, 0, 0, 0, 0, 0, 0, 0, implicit $exec :: (dereferenceable load 16 from constant-pool, addrspace 4)
51    %6:vgpr_32 = nofpexcept V_MAD_F32 0, killed %5, 0, 0, 0, 0, 0, 0, implicit $mode, implicit $exec
52    %7:vgpr_32 = nofpexcept V_RCP_F32_e32 killed %6, implicit $mode, implicit $exec
53    %8:vgpr_32 = nofpexcept V_MUL_F32_e32 0, killed %7, implicit $mode, implicit $exec
54    %9:vgpr_32 = nofpexcept V_MAD_F32 0, killed %8, 0, 0, 0, 0, 0, 0, implicit $mode, implicit $exec
55    dead %10:vgpr_32 = nofpexcept V_MAC_F32_e32 undef %11:vgpr_32, undef %12:vgpr_32, undef %10, implicit $mode, implicit $exec
56    undef %13.sub0:vreg_128 = COPY %9
57    %14:vgpr_32 = V_MOV_B32_e32 -1, implicit $exec
58    S_CBRANCH_SCC0 %bb.4, implicit undef $scc
59
60  bb.3:
61    successors: %bb.6(0x80000000)
62    %15:vreg_128 = IMPLICIT_DEF
63    %16:vgpr_32 = COPY killed %14
64    S_BRANCH %bb.6
65
66  bb.4:
67    successors: %bb.5(0x40000000), %bb.7(0x40000000)
68    %17:vgpr_32 = nofpexcept V_MAD_F32 0, killed %9, 0, 0, 0, 0, 0, 0, implicit $mode, implicit $exec
69    %18:vgpr_32 = nofpexcept V_MIN_F32_e32 1065353216, killed %17, implicit $mode, implicit $exec
70    %19:sreg_64_xexec = nofpexcept V_CMP_NEQ_F32_e64 0, 1065353216, 0, killed %18, 0, implicit $mode, implicit $exec
71    %20:vgpr_32 = V_MOV_B32_e32 2143289344, implicit $exec
72    %21:vgpr_32 = V_CNDMASK_B32_e64 0, 0, 0, killed %20, killed %19, implicit $exec
73    %22:sreg_64 = nofpexcept V_CMP_LT_F32_e64 0, 0, 0, killed %21, 0, implicit $mode, implicit $exec
74    %23:sreg_64 = COPY $exec, implicit-def $exec
75    %24:sreg_64 = S_AND_B64 %23, %22, implicit-def dead $scc
76    $exec = S_MOV_B64_term killed %24
77    SI_MASK_BRANCH %bb.7, implicit $exec
78    S_BRANCH %bb.5
79
80  bb.5:
81    successors: %bb.7(0x80000000)
82    S_BRANCH %bb.7
83
84  bb.6:
85    successors: %bb.8(0x40000000), %bb.10(0x40000000)
86    %25:vgpr_32 = COPY killed %16
87    %26:vreg_128 = COPY killed %15
88    %27:sreg_64 = V_CMP_NE_U32_e64 0, killed %25, implicit $exec
89    %28:sreg_64 = S_AND_B64 $exec, killed %27, implicit-def dead $scc
90    $vcc = COPY killed %28
91    %29:vreg_128 = COPY killed %26
92    S_CBRANCH_VCCNZ %bb.8, implicit killed $vcc
93    S_BRANCH %bb.10
94
95  bb.7:
96    successors: %bb.6(0x80000000)
97    $exec = S_OR_B64 $exec, killed %23, implicit-def $scc
98    %30:vgpr_32 = V_MOV_B32_e32 0, implicit $exec
99    %15:vreg_128 = COPY %13
100    %16:vgpr_32 = COPY killed %30
101    S_BRANCH %bb.6
102
103  bb.8:
104    successors: %bb.9(0x40000000), %bb.11(0x40000000)
105    %31:vreg_128 = COPY killed %13
106    S_CBRANCH_SCC1 %bb.11, implicit undef $scc
107    S_BRANCH %bb.9
108
109  bb.9:
110    successors: %bb.11(0x80000000)
111    %32:sreg_32_xm0 = S_MOV_B32 0
112    undef %33.sub0:sgpr_128 = COPY %32
113    %33.sub1:sgpr_128 = COPY %32
114    %33.sub2:sgpr_128 = COPY %32
115    %33.sub3:sgpr_128 = COPY killed %32
116    %34:sgpr_128 = COPY killed %33
117    %35:vreg_128 = COPY killed %34
118    %31:vreg_128 = COPY killed %35
119    S_BRANCH %bb.11
120
121  bb.10:
122    successors: %bb.14(0x80000000)
123    %36:vreg_128 = COPY killed %29
124    S_BRANCH %bb.14
125
126  bb.11:
127    successors: %bb.13(0x40000000), %bb.12(0x40000000)
128    %37:vreg_128 = COPY killed %31
129    S_CBRANCH_SCC0 %bb.13, implicit undef $scc
130
131  bb.12:
132    successors: %bb.10(0x80000000)
133    %29:vreg_128 = COPY killed %37
134    S_BRANCH %bb.10
135
136  bb.13:
137    successors: %bb.10(0x80000000)
138    %29:vreg_128 = COPY killed %37
139    S_BRANCH %bb.10
140
141  bb.14:
142    successors: %bb.15(0x40000000), %bb.16(0x40000000)
143    %38:vgpr_32 = nofpexcept V_MAD_F32 0, killed %36.sub0, 0, target-flags(amdgpu-gotprel) 0, 0, 0, 0, 0, implicit $mode, implicit $exec
144    %39:vgpr_32 = nofpexcept V_MAD_F32 0, killed %38, 0, 0, 0, 0, 0, 0, implicit $mode, implicit $exec
145    %40:vgpr_32 = nofpexcept V_MAD_F32 0, killed %39, 0, -1090519040, 0, 1056964608, 0, 0, implicit $mode, implicit $exec
146    %41:vgpr_32 = nofpexcept V_MAD_F32 0, killed %40, 0, 0, 0, -1090519040, 0, 0, implicit $mode, implicit $exec
147    %42:vgpr_32 = nofpexcept V_CVT_I32_F32_e32 killed %41, implicit $mode, implicit $exec
148    %43:sreg_32_xm0_xexec = S_BUFFER_LOAD_DWORD_IMM undef %44:sgpr_128, 12, 0, 0 :: (dereferenceable invariant load 4)
149    %45:vgpr_32 = V_MUL_LO_I32 killed %42, killed %43, implicit $exec
150    %46:vgpr_32 = V_LSHLREV_B32_e32 2, killed %45, implicit $exec
151    %47:vgpr_32 = BUFFER_LOAD_FORMAT_X_IDXEN killed %46, undef %48:sgpr_128, 0, 0, 0, 0, 0, 0, 0, implicit $exec :: (dereferenceable load 4 from constant-pool, align 1, addrspace 4)
152    %49:sreg_64 = V_CMP_NE_U32_e64 0, killed %47, implicit $exec
153    %50:sreg_64 = COPY $exec, implicit-def $exec
154    %51:sreg_64 = S_AND_B64 %50, %49, implicit-def dead $scc
155    $exec = S_MOV_B64_term killed %51
156    SI_MASK_BRANCH %bb.16, implicit $exec
157    S_BRANCH %bb.15
158
159  bb.15:
160    successors: %bb.16(0x80000000)
161
162  bb.16:
163    successors: %bb.17(0x80000000)
164    $exec = S_OR_B64 $exec, killed %50, implicit-def $scc
165    S_BRANCH %bb.17
166
167  bb.17:
168    successors: %bb.21(0x40000000), %bb.18(0x40000000)
169    S_CBRANCH_SCC1 %bb.21, implicit undef $scc
170
171  bb.18:
172    successors: %bb.19(0x40000000), %bb.20(0x40000000)
173    S_CBRANCH_SCC1 %bb.19, implicit undef $scc
174    S_BRANCH %bb.20
175
176  bb.19:
177    successors: %bb.20(0x80000000)
178
179  bb.20:
180    successors: %bb.21(0x80000000)
181
182  bb.21:
183    S_ENDPGM 0
184...
185