1# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2# RUN: llc -march=amdgcn -mcpu=fiji -verify-machineinstrs -run-pass=si-optimize-exec-masking -o - %s | FileCheck %s
3
4# Make sure we can still optimize writes to exec when there are
5# additional terminators after the exec write. This can happen with
6# phi users of control flow intrinsics.
7
8---
9name: instructions_after_copy_to_exec
10tracksRegLiveness: true
11body:             |
12  ; CHECK-LABEL: name: instructions_after_copy_to_exec
13  ; CHECK: bb.0:
14  ; CHECK:   successors: %bb.2(0x40000000), %bb.1(0x40000000)
15  ; CHECK:   liveins: $vgpr0
16  ; CHECK:   renamable $vgpr1 = V_MOV_B32_e32 0, implicit $exec
17  ; CHECK:   renamable $vcc = V_CMP_EQ_U32_e64 0, killed $vgpr0, implicit $exec
18  ; CHECK:   $sgpr0_sgpr1 = S_AND_SAVEEXEC_B64 $vcc, implicit-def $exec, implicit-def $scc, implicit $exec
19  ; CHECK:   renamable $sgpr0_sgpr1 = S_XOR_B64 $exec, killed renamable $sgpr0_sgpr1, implicit-def dead $scc
20  ; CHECK:   renamable $sgpr0_sgpr1 = COPY killed renamable $sgpr0_sgpr1, implicit $exec
21  ; CHECK:   S_CBRANCH_EXECZ %bb.2, implicit $exec
22  ; CHECK: bb.1:
23  ; CHECK:   successors: %bb.2(0x80000000)
24  ; CHECK:   liveins: $sgpr0_sgpr1
25  ; CHECK:   S_NOP 0, implicit $sgpr0_sgpr1
26  ; CHECK: bb.2:
27  ; CHECK:   liveins: $sgpr0_sgpr1
28  ; CHECK:   S_NOP 0, implicit $sgpr0_sgpr1
29  bb.0:
30    liveins: $vgpr0
31
32    renamable $vgpr1 = V_MOV_B32_e32 0, implicit $exec
33    renamable $vcc = V_CMP_EQ_U32_e64 0, killed $vgpr0, implicit $exec
34    renamable $sgpr0_sgpr1 = COPY $exec, implicit-def $exec
35    renamable $sgpr2_sgpr3 = S_AND_B64 renamable $sgpr0_sgpr1, renamable $vcc, implicit-def dead $scc
36    renamable $sgpr0_sgpr1 = S_XOR_B64 renamable $sgpr2_sgpr3, killed renamable $sgpr0_sgpr1, implicit-def dead $scc
37    $exec = S_MOV_B64_term killed renamable $sgpr2_sgpr3
38    renamable $sgpr0_sgpr1 = S_MOV_B64_term killed renamable $sgpr0_sgpr1, implicit $exec
39    S_CBRANCH_EXECZ %bb.2, implicit $exec
40
41  bb.1:
42    liveins: $sgpr0_sgpr1
43
44    S_NOP 0, implicit $sgpr0_sgpr1
45
46  bb.2:
47    liveins: $sgpr0_sgpr1
48
49    S_NOP 0, implicit $sgpr0_sgpr1
50
51...
52