1 # RUN: not llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx908 -start-before=greedy,0 -stop-after=virtregrewriter,1 -verify-machineinstrs -o - 2> %t.err %s | FileCheck %s
2 # RUN: FileCheck -check-prefix=ERR %s < %t.err
4 # ERR: error: register allocation failed: maximum depth for recoloring reached. Use -fexhaustive-register-search to skip cutoffs
5 # ERR-NEXT: error: ran out of registers during register allocation
7 # This testcase used to fail with an "overlapping insert" assertion
8 # when trying to roll back an unsucessful recoloring of %25. One of
9 # the interfering vregs is successfully recolored, and the other is
10 # not. We need to roll back the successfully recolored interfering
11 # vreg in order to avoid conflicting with the original assignment of
12 # the original register when rolling back the second.
15 # %25 initially assigned to $sgpr60_sgpr61_sgpr62_sgpr63_sgpr64_sgpr65_sgpr66_sgpr67
16 # interfering candidates %15 %17
17 # assigned %15 to $sgpr8_sgpr9_sgpr10_sgpr11_sgpr12_sgpr13_sgpr14_sgpr15
19 # %18 -> normal recolored $sgpr28_sgpr29_sgpr30_sgpr31
20 # %20 -> normal recolored $sgpr60_sgpr61_sgpr62_sgpr63
21 # %17 candidates %37 %39
22 # tentative assign %17 $sgpr84_sgpr85_sgpr86_sgpr87_sgpr88_sgpr89_sgpr90_sgpr91
23 # %37 to $sgpr72_sgpr73_sgpr74_sgpr75 succeeded
24 # %39 last chance recoloring, fails max depth
25 # Fail to assign: %17 to $sgpr84_sgpr85_sgpr86_sgpr87_sgpr88_sgpr89_sgpr90_sgpr91 at depth 4
26 # %37 reassign to $sgpr84_sgpr85_sgpr86_sgpr87 unassign from $sgpr72_sgpr73_sgpr74_sgpr75
27 # %39 reassign to $sgpr88_sgpr89_sgpr90_sgpr91
28 # %17 candidates %39 %41
29 # Try to assign: %17 to $sgpr88_sgpr89_sgpr90_sgpr91_sgpr92_sgpr93_sgpr94_sgpr95
30 # %39 Try assign to $sgpr72_sgpr73_sgpr74_sgpr75 succeeded
31 # %41 last chance recoloring, fail max depth
32 # %39 reassign to $sgpr88_sgpr89_sgpr90_sgpr91 unassign from $sgpr72_sgpr73_sgpr74_sgpr75
33 # %41 reassign to $sgpr92_sgpr93_sgpr94_sgpr95
34 # %17 candidates %41 %16
35 # Try assign %41 to $sgpr72_sgpr73_sgpr74_sgpr75 succeeded
36 # %16 last chance recolor, fail max depth
39 # Have to roll back the succesful recoloring of %15 when %17's
40 # recoloring failed. Previously we would leave the recoloring of %18
41 # and %20 in place. The recoloring of %20 to
42 # $sgpr60_sgpr61_sgpr62_sgpr63 conflicts with the parent restore of
43 # %25 to $sgpr60_sgpr61_sgpr62_sgpr63_sgpr64_sgpr65_sgpr66_sgpr67
45 # CHECK-LABEL: name: issue48473
46 # CHECK: S_NOP 0, implicit killed renamable $sgpr0_sgpr1_sgpr2_sgpr3, implicit killed renamable $sgpr12_sgpr13_sgpr14_sgpr15, implicit killed renamable $sgpr16_sgpr17_sgpr18_sgpr19_sgpr20_sgpr21_sgpr22_sgpr23, implicit killed renamable $sgpr24_sgpr25_sgpr26_sgpr27_sgpr28_sgpr29_sgpr30_sgpr31, implicit killed renamable $sgpr84_sgpr85_sgpr86_sgpr87, implicit killed renamable $sgpr36_sgpr37_sgpr38_sgpr39_sgpr40_sgpr41_sgpr42_sgpr43, implicit killed renamable $sgpr4_sgpr5_sgpr6_sgpr7, implicit killed renamable $sgpr44_sgpr45_sgpr46_sgpr47_sgpr48_sgpr49_sgpr50_sgpr51, implicit killed renamable $sgpr88_sgpr89_sgpr90_sgpr91, implicit killed renamable $sgpr76_sgpr77_sgpr78_sgpr79_sgpr80_sgpr81_sgpr82_sgpr83, implicit killed renamable $sgpr0_sgpr1_sgpr2_sgpr3, implicit killed renamable $sgpr52_sgpr53_sgpr54_sgpr55_sgpr56_sgpr57_sgpr58_sgpr59, implicit killed renamable $sgpr92_sgpr93_sgpr94_sgpr95, implicit killed renamable $sgpr68_sgpr69_sgpr70_sgpr71_sgpr72_sgpr73_sgpr74_sgpr75, implicit renamable $sgpr68_sgpr69_sgpr70_sgpr71_sgpr72_sgpr73_sgpr74_sgpr75, implicit killed renamable $sgpr96_sgpr97_sgpr98_sgpr99, implicit killed renamable $sgpr8_sgpr9_sgpr10_sgpr11, implicit killed renamable $sgpr60_sgpr61_sgpr62_sgpr63_sgpr64_sgpr65_sgpr66_sgpr67
50 tracksRegLiveness: true
53 scratchRSrcReg: '$sgpr100_sgpr101_sgpr102_sgpr103'
54 stackPtrOffsetReg: '$sgpr32'
56 privateSegmentBuffer: { reg: '$sgpr0_sgpr1_sgpr2_sgpr3' }
57 privateSegmentWaveByteOffset: { reg: '$sgpr4' }
61 liveins: $sgpr0_sgpr1_sgpr2_sgpr3, $sgpr4_sgpr5_sgpr6_sgpr7
63 %0:sgpr_128 = COPY $sgpr0_sgpr1_sgpr2_sgpr3
64 %1:sgpr_128 = COPY $sgpr4_sgpr5_sgpr6_sgpr7
65 %2:sgpr_256 = S_LOAD_DWORDX8_IMM undef %3:sgpr_64, 1000, 0 :: (load 32, addrspace 6)
66 %4:sgpr_256 = S_LOAD_DWORDX8_IMM undef %3:sgpr_64, 1088, 0 :: (load 32, addrspace 6)
67 %5:sgpr_256 = S_LOAD_DWORDX8_IMM undef %3:sgpr_64, 1152, 0 :: (load 32, addrspace 6)
68 %6:sgpr_256 = S_LOAD_DWORDX8_IMM undef %3:sgpr_64, 1216, 0 :: (load 32, addrspace 6)
69 %7:sgpr_256 = S_LOAD_DWORDX8_IMM undef %3:sgpr_64, 1280, 0 :: (load 32, addrspace 6)
70 %8:sgpr_256 = S_LOAD_DWORDX8_IMM undef %3:sgpr_64, 1408, 0 :: (load 32, addrspace 6)
71 %9:sgpr_128 = S_LOAD_DWORDX4_IMM undef %3:sgpr_64, 0, 0 :: (load 16, addrspace 6)
72 %10:sgpr_128 = S_LOAD_DWORDX4_IMM undef %3:sgpr_64, 0, 0 :: (load 16, addrspace 6)
73 %11:sgpr_128 = S_LOAD_DWORDX4_IMM undef %3:sgpr_64, 0, 0 :: (load 16, addrspace 6)
74 %12:sgpr_128 = S_LOAD_DWORDX4_IMM undef %3:sgpr_64, 0, 0 :: (load 16, addrspace 6)
75 %13:sgpr_128 = S_LOAD_DWORDX4_IMM undef %3:sgpr_64, 0, 0 :: (load 16, addrspace 6)
76 %14:sgpr_128 = IMPLICIT_DEF
77 S_NOP 0, implicit-def %15:sgpr_256, implicit-def %16:sgpr_128, implicit-def %17:sgpr_256
78 S_NOP 0, implicit %0, implicit %1, implicit %2, implicit %4, implicit %9, implicit %5, implicit %10, implicit %6, implicit %11, implicit %8, implicit %13, implicit %7, implicit %12, implicit %17, implicit %17, implicit %16, implicit %14, implicit %15