1# RUN: llc -mtriple=amdgcn-amd-amdhsa-opencl -verify-machineinstrs -stress-regalloc=1 -start-before=simple-register-coalescing -stop-after=greedy -o - %s | FileCheck %s
2# https://bugs.llvm.org/show_bug.cgi?id=33620
3
4---
5# This would assert due to the empty live interval created for %9
6# on the last S_NOP with an undef subreg use.
7
8# CHECK-LABEL: name: expecting_non_empty_interval
9
10# CHECK: undef %7.sub1:vreg_64 = V_MAC_F32_e32 0, undef %1:vgpr_32, undef %7.sub1, implicit $exec
11# CHECK-NEXT: SI_SPILL_V64_SAVE %7, %stack.0, $sgpr0_sgpr1_sgpr2_sgpr3, $sgpr5, 0, implicit $exec :: (store 8 into %stack.0, align 4, addrspace 5)
12# CHECK-NEXT: undef %5.sub1:vreg_64 = V_MOV_B32_e32 1786773504, implicit $exec
13# CHECK-NEXT: dead %2:vgpr_32 = V_MUL_F32_e32 0, %5.sub1, implicit $exec
14
15# CHECK: S_NOP 0, implicit %6.sub1
16# CHECK-NEXT: %8:vreg_64 = SI_SPILL_V64_RESTORE %stack.0, $sgpr0_sgpr1_sgpr2_sgpr3, $sgpr5, 0, implicit $exec :: (load 8 from %stack.0, align 4, addrspace 5)
17# CHECK-NEXT: S_NOP 0, implicit %8.sub1
18# CHECK-NEXT: S_NOP 0, implicit undef %9.sub0
19
20name: expecting_non_empty_interval
21tracksRegLiveness: true
22registers:
23  - { id: 0, class: vreg_64, preferred-register: '' }
24  - { id: 1, class: vgpr_32, preferred-register: '' }
25  - { id: 2, class: vgpr_32, preferred-register: '' }
26  - { id: 3, class: vreg_64, preferred-register: '' }
27body:             |
28  bb.0:
29    successors: %bb.1
30    undef %0.sub1 = V_MAC_F32_e32 0, undef %1, undef %0.sub1, implicit $exec
31    undef %3.sub1 = V_MOV_B32_e32 1786773504, implicit $exec
32    dead %2 = V_MUL_F32_e32 0, %3.sub1, implicit $exec
33
34  bb.1:
35    S_NOP 0, implicit %3.sub1
36    S_NOP 0, implicit %0.sub1
37    S_NOP 0, implicit undef %0.sub0
38
39...
40
41# Similar assert which happens when trying to rematerialize.
42# https://bugs.llvm.org/show_bug.cgi?id=33884
43---
44# CHECK-LABEL: name: rematerialize_empty_interval_has_reference
45
46# CHECK-NOT: MOV
47# CHECK: undef %3.sub2:vreg_128 = V_MOV_B32_e32 1786773504, implicit $exec
48
49# CHECK: bb.1:
50# CHECK-NEXT: S_NOP 0, implicit %3.sub2
51# CHECK-NEXT: S_NOP 0, implicit undef %6.sub0
52# CHECK-NEXT: undef %4.sub2:vreg_128 = V_MOV_B32_e32 0, implicit $exec
53# CHECK-NEXT: S_NOP 0, implicit %4.sub2
54name: rematerialize_empty_interval_has_reference
55tracksRegLiveness: true
56registers:
57  - { id: 0, class: vreg_128, preferred-register: '' }
58  - { id: 1, class: vgpr_32, preferred-register: '' }
59  - { id: 2, class: vgpr_32, preferred-register: '' }
60  - { id: 3, class: vreg_128, preferred-register: '' }
61body:             |
62  bb.0:
63    successors: %bb.1
64
65    undef %0.sub2 = V_MOV_B32_e32 0, implicit $exec
66    undef %3.sub2 = V_MOV_B32_e32 1786773504, implicit $exec
67
68  bb.1:
69    S_NOP 0, implicit %3.sub2
70    S_NOP 0, implicit undef %0.sub0
71    S_NOP 0, implicit %0.sub2
72
73...
74