xref: /llvm-project/llvm/test/CodeGen/AMDGPU/postra-sink-update-dependency.mir (revision e33e087a175567e88b361fd198536314a0a1fff2)
1*e33e087aSRuiling, Song# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 5
2*e33e087aSRuiling, Song# RUN: llc -mtriple=amdgcn -mcpu=gfx1100 -run-pass=postra-machine-sink -verify-machineinstrs -o - %s | FileCheck %s
3*e33e087aSRuiling, Song#
4*e33e087aSRuiling, Song# In the example, the ` $sgpr4 = COPY $sgpr2` was incorrectly sunk into bb.3. This happened because we did not update
5*e33e087aSRuiling, Song# register uses when we found that `$sgpr2 = COPY $sgpr3` should not be sunk because of conflict with the successor's
6*e33e087aSRuiling, Song# prologue instructions.
7*e33e087aSRuiling, Song---
8*e33e087aSRuiling, Songname:            update_dependency_correctly
9*e33e087aSRuiling, SongtracksRegLiveness: true
10*e33e087aSRuiling, Songbody:             |
11*e33e087aSRuiling, Song  ; CHECK-LABEL: name: update_dependency_correctly
12*e33e087aSRuiling, Song  ; CHECK: bb.0:
13*e33e087aSRuiling, Song  ; CHECK-NEXT:   successors: %bb.2(0x40000000), %bb.1(0x40000000)
14*e33e087aSRuiling, Song  ; CHECK-NEXT:   liveins: $sgpr0, $sgpr3, $sgpr2
15*e33e087aSRuiling, Song  ; CHECK-NEXT: {{  $}}
16*e33e087aSRuiling, Song  ; CHECK-NEXT:   $vgpr1 = IMPLICIT_DEF
17*e33e087aSRuiling, Song  ; CHECK-NEXT:   renamable $sgpr4 = COPY $sgpr2
18*e33e087aSRuiling, Song  ; CHECK-NEXT:   renamable $sgpr2 = COPY $sgpr3
19*e33e087aSRuiling, Song  ; CHECK-NEXT:   $vgpr1 = SI_SPILL_S32_TO_VGPR $sgpr0, 0, $vgpr1
20*e33e087aSRuiling, Song  ; CHECK-NEXT:   $sgpr1 = S_AND_SAVEEXEC_B32 $sgpr0, implicit-def $exec, implicit-def $scc, implicit $exec
21*e33e087aSRuiling, Song  ; CHECK-NEXT:   S_CBRANCH_EXECZ %bb.1, implicit $exec
22*e33e087aSRuiling, Song  ; CHECK-NEXT:   S_BRANCH %bb.2
23*e33e087aSRuiling, Song  ; CHECK-NEXT: {{  $}}
24*e33e087aSRuiling, Song  ; CHECK-NEXT: bb.1:
25*e33e087aSRuiling, Song  ; CHECK-NEXT:   S_ENDPGM 0
26*e33e087aSRuiling, Song  ; CHECK-NEXT: {{  $}}
27*e33e087aSRuiling, Song  ; CHECK-NEXT: bb.2:
28*e33e087aSRuiling, Song  ; CHECK-NEXT:   successors: %bb.1(0x80000000)
29*e33e087aSRuiling, Song  ; CHECK-NEXT:   liveins: $sgpr0, $sgpr2, $sgpr4, $vgpr1
30*e33e087aSRuiling, Song  ; CHECK-NEXT: {{  $}}
31*e33e087aSRuiling, Song  ; CHECK-NEXT:   $sgpr3 = SI_RESTORE_S32_FROM_VGPR $vgpr1, 0
32*e33e087aSRuiling, Song  ; CHECK-NEXT:   renamable $sgpr0_sgpr1 = S_GETPC_B64_pseudo
33*e33e087aSRuiling, Song  ; CHECK-NEXT:   renamable $sgpr5 = COPY $sgpr1
34*e33e087aSRuiling, Song  ; CHECK-NEXT:   renamable $sgpr0_sgpr1 = S_LOAD_DWORDX2_IMM renamable $sgpr4_sgpr5, 32, 0
35*e33e087aSRuiling, Song  ; CHECK-NEXT:   S_BRANCH %bb.1
36*e33e087aSRuiling, Song  bb.0:
37*e33e087aSRuiling, Song    successors: %bb.3(0x40000000), %bb.2(0x40000000)
38*e33e087aSRuiling, Song    liveins: $sgpr0, $sgpr3, $sgpr2
39*e33e087aSRuiling, Song
40*e33e087aSRuiling, Song    $vgpr1 = IMPLICIT_DEF
41*e33e087aSRuiling, Song
42*e33e087aSRuiling, Song    renamable $sgpr4 = COPY $sgpr2
43*e33e087aSRuiling, Song    renamable $sgpr2 = COPY $sgpr3
44*e33e087aSRuiling, Song
45*e33e087aSRuiling, Song    $vgpr1 = SI_SPILL_S32_TO_VGPR $sgpr0, 0, $vgpr1
46*e33e087aSRuiling, Song
47*e33e087aSRuiling, Song    $sgpr1 = S_AND_SAVEEXEC_B32 $sgpr0, implicit-def $exec, implicit-def $scc, implicit $exec
48*e33e087aSRuiling, Song    S_CBRANCH_EXECZ %bb.2, implicit $exec
49*e33e087aSRuiling, Song    S_BRANCH %bb.3
50*e33e087aSRuiling, Song
51*e33e087aSRuiling, Song  bb.2:
52*e33e087aSRuiling, Song    S_ENDPGM 0
53*e33e087aSRuiling, Song
54*e33e087aSRuiling, Song  bb.3:
55*e33e087aSRuiling, Song    successors: %bb.2(0x40000000)
56*e33e087aSRuiling, Song    liveins: $sgpr0, $sgpr2, $sgpr4, $vgpr1
57*e33e087aSRuiling, Song
58*e33e087aSRuiling, Song    $sgpr3 = SI_RESTORE_S32_FROM_VGPR $vgpr1, 0
59*e33e087aSRuiling, Song
60*e33e087aSRuiling, Song    renamable $sgpr0_sgpr1 = S_GETPC_B64_pseudo
61*e33e087aSRuiling, Song    renamable $sgpr5 = COPY $sgpr1
62*e33e087aSRuiling, Song    renamable $sgpr0_sgpr1 = S_LOAD_DWORDX2_IMM renamable $sgpr4_sgpr5, 32, 0
63*e33e087aSRuiling, Song
64*e33e087aSRuiling, Song    S_BRANCH %bb.2
65*e33e087aSRuiling, Song
66*e33e087aSRuiling, Song...
67