1# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2# RUN: llc -mtriple=amdgcn-amd-amdhsa -verify-coalescing -run-pass=simple-register-coalescing -verify-machineinstrs -o - %s | FileCheck %s
3
4# Bug 39602: Avoid "Couldn't join subrange" error when clearing valid
5# lanes on an implicit_def that later cannot be erased.
6
7---
8name: lost_valid_lanes_maybe_erasable_implicit_def
9tracksRegLiveness: true
10body:             |
11  ; CHECK-LABEL: name: lost_valid_lanes_maybe_erasable_implicit_def
12  ; CHECK: bb.0:
13  ; CHECK:   successors: %bb.1(0x80000000)
14  ; CHECK:   undef %0.sub1:sreg_64 = IMPLICIT_DEF
15  ; CHECK: bb.1:
16  ; CHECK:   %0.sub0:sreg_64 = S_MOV_B32 0
17  ; CHECK:   [[COPY:%[0-9]+]]:sreg_64 = COPY %0
18  ; CHECK:   dead %0.sub1:sreg_64 = COPY %0.sub0
19  ; CHECK:   S_ENDPGM 0, implicit [[COPY]].sub1
20  bb.0:
21    successors: %bb.1
22    undef %0.sub1:sreg_64 = IMPLICIT_DEF
23
24  bb.1:
25    %0.sub0:sreg_64 = S_MOV_B32 0
26    %1:sreg_64 = COPY %0:sreg_64
27    dead %0.sub1:sreg_64 = COPY %0.sub0:sreg_64
28    S_ENDPGM 0, implicit %1.sub1:sreg_64
29
30...
31---
32# Same as previous, except with a real value instead of
33# IMPLICIT_DEF. These should both be handled the same way.
34
35name:  lost_valid_lanes_real_value
36tracksRegLiveness: true
37body:             |
38  ; CHECK-LABEL: name: lost_valid_lanes_real_value
39  ; CHECK: bb.0:
40  ; CHECK:   successors: %bb.1(0x80000000)
41  ; CHECK:   undef %0.sub1:sreg_64 = S_MOV_B32 -1
42  ; CHECK: bb.1:
43  ; CHECK:   %0.sub0:sreg_64 = S_MOV_B32 0
44  ; CHECK:   [[COPY:%[0-9]+]]:sreg_64 = COPY %0
45  ; CHECK:   dead %0.sub1:sreg_64 = COPY %0.sub0
46  ; CHECK:   S_ENDPGM 0, implicit [[COPY]].sub1
47  bb.0:
48    successors: %bb.1
49    undef %0.sub1:sreg_64 = S_MOV_B32 -1
50
51  bb.1:
52    %0.sub0:sreg_64 = S_MOV_B32 0
53    %1:sreg_64 = COPY %0:sreg_64
54    dead %0.sub1:sreg_64 = COPY %0.sub0:sreg_64
55    S_ENDPGM 0, implicit %1.sub1:sreg_64
56
57...
58