1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -march=amdgcn -mcpu=gfx1010 -verify-machineinstrs -run-pass=machine-sink -o - %s | FileCheck -check-prefixes=GFX10 %s
4 # Test that MachineSink pass respects block prologues when sinking instructions.
5 # Specifically an instruction must not be sunk before exec mask manipulation.
10 tracksRegLiveness: true
14 ; GFX10-LABEL: name: _amdgpu_hs_main
16 ; GFX10-NEXT: successors: %bb.1(0x40000000), %bb.2(0x40000000)
18 ; GFX10-NEXT: [[DEF:%[0-9]+]]:vgpr_32 = IMPLICIT_DEF
19 ; GFX10-NEXT: [[S_MOV_B32_:%[0-9]+]]:sreg_32 = S_MOV_B32 8
20 ; GFX10-NEXT: [[V_BFE_U32_e64_:%[0-9]+]]:vgpr_32 = V_BFE_U32_e64 [[DEF]], 8, 5, implicit $exec
21 ; GFX10-NEXT: [[S_MOV_B32_1:%[0-9]+]]:sreg_32 = S_MOV_B32 5
22 ; GFX10-NEXT: [[V_CMP_NE_U32_e64_:%[0-9]+]]:sreg_32 = V_CMP_NE_U32_e64 [[V_BFE_U32_e64_]], killed [[S_MOV_B32_1]], implicit $exec
23 ; GFX10-NEXT: [[S_XOR_B32_:%[0-9]+]]:sreg_32 = S_XOR_B32 [[V_CMP_NE_U32_e64_]], -1, implicit-def $scc
24 ; GFX10-NEXT: [[S_AND_B32_:%[0-9]+]]:sreg_32 = S_AND_B32 [[S_XOR_B32_]], $exec_lo, implicit-def $scc
25 ; GFX10-NEXT: [[S_XOR_B32_1:%[0-9]+]]:sreg_32 = S_XOR_B32 $exec_lo, [[S_AND_B32_]], implicit-def $scc
26 ; GFX10-NEXT: $exec_lo = S_MOV_B32_term [[S_AND_B32_]]
27 ; GFX10-NEXT: S_CBRANCH_EXECZ %bb.2, implicit $exec
28 ; GFX10-NEXT: S_BRANCH %bb.1
31 ; GFX10-NEXT: successors: %bb.2(0x80000000)
33 ; GFX10-NEXT: [[DEF1:%[0-9]+]]:sgpr_32 = IMPLICIT_DEF
34 ; GFX10-NEXT: S_BRANCH %bb.2
37 ; GFX10-NEXT: successors: %bb.3(0x40000000), %bb.4(0x40000000)
39 ; GFX10-NEXT: $exec_lo = S_OR_B32 $exec_lo, [[S_XOR_B32_1]], implicit-def $scc
40 ; GFX10-NEXT: [[V_LSHRREV_B32_e64_:%[0-9]+]]:vgpr_32 = V_LSHRREV_B32_e64 [[S_MOV_B32_]], [[DEF]], implicit $exec
41 ; GFX10-NEXT: [[S_MOV_B32_2:%[0-9]+]]:sreg_32 = S_MOV_B32 31
42 ; GFX10-NEXT: [[V_CMP_NE_U32_e64_1:%[0-9]+]]:sreg_32 = V_CMP_NE_U32_e64 [[V_BFE_U32_e64_]], killed [[S_MOV_B32_2]], implicit $exec
43 ; GFX10-NEXT: [[S_XOR_B32_2:%[0-9]+]]:sreg_32 = S_XOR_B32 [[V_CMP_NE_U32_e64_1]], -1, implicit-def $scc
44 ; GFX10-NEXT: [[S_AND_B32_1:%[0-9]+]]:sreg_32 = S_AND_B32 [[S_XOR_B32_2]], $exec_lo, implicit-def $scc
45 ; GFX10-NEXT: [[S_XOR_B32_3:%[0-9]+]]:sreg_32 = S_XOR_B32 $exec_lo, [[S_AND_B32_1]], implicit-def $scc
46 ; GFX10-NEXT: $exec_lo = S_MOV_B32_term [[S_AND_B32_1]]
47 ; GFX10-NEXT: S_CBRANCH_EXECZ %bb.4, implicit $exec
48 ; GFX10-NEXT: S_BRANCH %bb.3
51 ; GFX10-NEXT: successors: %bb.4(0x80000000)
53 ; GFX10-NEXT: S_BRANCH %bb.4
56 ; GFX10-NEXT: successors: %bb.5(0x80000000)
58 ; GFX10-NEXT: $exec_lo = S_OR_B32 $exec_lo, [[S_XOR_B32_3]], implicit-def $scc
59 ; GFX10-NEXT: [[DEF2:%[0-9]+]]:sreg_32 = IMPLICIT_DEF
60 ; GFX10-NEXT: [[S_MOV_B32_3:%[0-9]+]]:sreg_32 = S_MOV_B32 16
61 ; GFX10-NEXT: [[S_MOV_B32_4:%[0-9]+]]:sreg_32 = S_MOV_B32 4
62 ; GFX10-NEXT: [[V_LSHL_ADD_U32_e64_:%[0-9]+]]:vgpr_32 = nuw nsw V_LSHL_ADD_U32_e64 [[V_LSHRREV_B32_e64_]], [[S_MOV_B32_4]], killed [[S_MOV_B32_3]], implicit $exec
63 ; GFX10-NEXT: S_BRANCH %bb.5
66 ; GFX10-NEXT: $exec_lo = S_OR_B32 $exec_lo, [[DEF2]], implicit-def $scc
67 ; GFX10-NEXT: S_ENDPGM 0
69 successors: %bb.4(0x40000000), %bb.5(0x40000000)
71 %0:sgpr_32 = IMPLICIT_DEF
72 %14:sreg_32 = IMPLICIT_DEF
73 %15:vgpr_32 = IMPLICIT_DEF
74 %16:sreg_32 = S_MOV_B32 8
75 %17:vgpr_32 = V_LSHRREV_B32_e64 %16, %15, implicit $exec
76 %18:vgpr_32 = V_BFE_U32_e64 %15, 8, 5, implicit $exec
77 %19:sreg_32 = S_MOV_B32 5
78 %20:sreg_32 = V_CMP_NE_U32_e64 %18, killed %19, implicit $exec
79 %21:sreg_32 = S_XOR_B32 %20, -1, implicit-def $scc
80 %22:sreg_32 = S_AND_B32 %21, $exec_lo, implicit-def $scc
81 %23:sreg_32 = S_XOR_B32 $exec_lo, %22, implicit-def $scc
82 $exec_lo = S_MOV_B32_term %22
83 S_CBRANCH_EXECZ %bb.5, implicit $exec
87 successors: %bb.5(0x80000000)
92 successors: %bb.6(0x40000000), %bb.7(0x40000000)
94 $exec_lo = S_OR_B32 $exec_lo, %23, implicit-def $scc
95 %24:sreg_32 = S_MOV_B32 31
96 %25:sreg_32 = V_CMP_NE_U32_e64 %18, killed %24, implicit $exec
97 %26:sreg_32 = S_XOR_B32 %25, -1, implicit-def $scc
98 %27:sreg_32 = S_AND_B32 %26, $exec_lo, implicit-def $scc
99 %28:sreg_32 = S_XOR_B32 $exec_lo, %27, implicit-def $scc
100 $exec_lo = S_MOV_B32_term %27
101 S_CBRANCH_EXECZ %bb.7, implicit $exec
105 successors: %bb.7(0x80000000)
110 successors: %bb.8(0x80000000)
112 $exec_lo = S_OR_B32 $exec_lo, %28, implicit-def $scc
113 %29:sreg_32 = S_MOV_B32 16
114 %30:sreg_32 = S_MOV_B32 4
115 %31:vgpr_32 = nuw nsw V_LSHL_ADD_U32_e64 %17, %30, killed %29, implicit $exec
119 $exec_lo = S_OR_B32 $exec_lo, %14, implicit-def $scc