xref: /llvm-project/llvm/test/CodeGen/AMDGPU/greedy-liverange-priority.mir (revision 9e9907f1cfa424366fba58d9520f9305b537cec9)
1# RUN: llc -mtriple=amdgcn -mcpu=gfx1030 -greedy-regclass-priority-trumps-globalness=0 -start-before greedy -o - %s | FileCheck %s -check-prefixes=GCN,OLD
2# RUN: llc -mtriple=amdgcn -mcpu=gfx1030 -greedy-regclass-priority-trumps-globalness=1 -start-before greedy -o - %s | FileCheck %s -check-prefixes=GCN,NEW
3
4# At the time of writing -greedy-regclass-priority-trumps-globalness makes a
5# significant improvement in the total number of vgprs needed to compile this
6# test, from 11 down to 7.
7
8# GCN-LABEL: test1:
9# OLD: NumVgprs: 11{{$}}
10# NEW: NumVgprs: 7{{$}}
11---
12name: test1
13tracksRegLiveness: true
14body: |
15  bb.0:
16    successors: %bb.1, %bb.2
17    liveins: $vgpr0, $vgpr6
18
19    %6:vgpr_32 = COPY $vgpr6
20    undef %30.sub0:vreg_128 = COPY $vgpr0
21    undef %27.sub0:vreg_128 = V_MED3_F32_e64 0, 0, 0, 0, 0, 0, 0, 0, implicit $mode, implicit $exec
22    undef %16.sub0:sgpr_256 = S_MOV_B32 0
23    undef %26.sub1:vreg_64 = V_LSHRREV_B32_e32 1, %6, implicit $exec
24    %27.sub1:vreg_128 = COPY %27.sub0
25    %27.sub2:vreg_128 = COPY %27.sub0
26    %27.sub3:vreg_128 = COPY %27.sub0
27    %26.sub0:vreg_64 = V_MOV_B32_e32 1, implicit $exec
28    %16.sub1:sgpr_256 = COPY %16.sub0
29    %16.sub2:sgpr_256 = COPY %16.sub0
30    %16.sub3:sgpr_256 = COPY %16.sub0
31    %16.sub4:sgpr_256 = COPY %16.sub0
32    %16.sub5:sgpr_256 = COPY %16.sub0
33    %16.sub6:sgpr_256 = COPY %16.sub0
34    %16.sub7:sgpr_256 = COPY %16.sub0
35    IMAGE_STORE_V4_V2_gfx10 %27, %26, %16, 0, 1, -1, 0, 0, 0, 0, 0, 0, implicit $exec :: (dereferenceable store (s32), addrspace 7)
36    S_CBRANCH_SCC1 %bb.2, implicit undef $scc
37    S_BRANCH %bb.1
38
39  bb.1:
40    %30.sub1:vreg_128 = V_MOV_B32_e32 0, implicit $exec
41    %30.sub2:vreg_128 = COPY %30.sub1
42    %30.sub3:vreg_128 = COPY %30.sub1
43    %26.sub1:vreg_64 = COPY %30.sub1
44    IMAGE_STORE_V4_V2_gfx10 %30, %26, %16, 0, 1, -1, 0, 0, 0, 0, 0, 0, implicit $exec :: (dereferenceable store (s32), addrspace 7)
45
46  bb.2:
47    S_ENDPGM 0
48...
49
50# GCN-LABEL: test2:
51# OLD: NumVgprs: 7{{$}}
52# NEW: NumVgprs: 11{{$}}
53---
54name: test2
55tracksRegLiveness: true
56body: |
57  bb.0:
58    liveins: $vgpr0, $vgpr2
59
60    %8:vgpr_32 = COPY $vgpr2
61    %6:vgpr_32 = COPY $vgpr0
62
63  bb.1:
64    successors: %bb.2, %bb.3
65
66    undef %25.sub0:sgpr_256 = S_MOV_B32 0
67    %10:vgpr_32 = V_MOV_B32_e32 0, implicit $exec
68    %25.sub1:sgpr_256 = COPY %25.sub0
69    %25.sub2:sgpr_256 = COPY %25.sub0
70    %25.sub3:sgpr_256 = COPY %25.sub0
71    %19:vgpr_32 = BUFFER_LOAD_FORMAT_X_IDXEN %10, %25.sub0_sub1_sub2_sub3, 0, 0, 0, 0, implicit $exec :: (dereferenceable load (s32))
72    %36:vreg_64 = DS_READ2_B32_gfx9 %10, 0, 2, 0, implicit $exec :: (load (s32)), (load (s32))
73    %30:vgpr_32 = V_LSHLREV_B32_e32 2, %36.sub0, implicit $exec
74    %3:vgpr_32 = V_ADD_U32_e32 %30, %6, implicit $exec
75    %4:vgpr_32 = V_ADD_U32_e32 %36.sub1, %8, implicit $exec
76    %15:vgpr_32 = V_OR_B32_e32 %4, %3, implicit $exec
77    %21:sreg_32 = V_READFIRSTLANE_B32 %19, implicit $exec
78    %17:sreg_32 = V_CMP_EQ_U32_e64 0, %15, implicit $exec
79    S_CMP_LG_U32 %21, 0, implicit-def $scc
80    %31:sreg_32_xm0_xexec = S_CSELECT_B32 -1, 0, implicit killed $scc
81    %23:sreg_32 = S_AND_B32 %31, %17, implicit-def dead $scc
82    %5:sreg_32 = COPY $exec_lo, implicit-def $exec_lo
83    %37:sreg_32 = S_AND_B32 %5, %23, implicit-def dead $scc
84    $exec_lo = S_MOV_B32_term %37
85    S_CBRANCH_EXECZ %bb.3, implicit $exec
86    S_BRANCH %bb.2
87
88  bb.2:
89    undef %28.sub0:vreg_128 = V_MOV_B32_e32 0, implicit $exec
90    %25.sub1:sgpr_256 = COPY %25.sub0
91    %25.sub2:sgpr_256 = COPY %25.sub0
92    %25.sub3:sgpr_256 = COPY %25.sub0
93    %25.sub4:sgpr_256 = COPY %25.sub0
94    %28.sub1:vreg_128 = COPY %28.sub0
95    %28.sub2:vreg_128 = COPY %28.sub0
96    %28.sub3:vreg_128 = COPY %28.sub0
97    %25.sub5:sgpr_256 = COPY %25.sub0
98    %25.sub6:sgpr_256 = COPY %25.sub0
99    %25.sub7:sgpr_256 = COPY %25.sub0
100    IMAGE_STORE_V4_V3_nsa_gfx10 %28, %3, %30, %4, %25, 0, 2, -1, 0, 0, 0, 0, 0, 0, implicit $exec :: (dereferenceable store (s32))
101
102  bb.3:
103    S_ENDPGM 0
104...
105