blob: cb5f422a04891dffee6b7771ed1fded546055e2d [file] [log] [blame]
Quentin Colombetc74271c2019-03-26 21:27:15 +00001# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2# RUN: llc -mtriple s390x-ibm-linux -mcpu=z13 -systemz-subreg-liveness -verify-machineinstrs -start-before simple-register-coalescing -stop-after greedy -o - %s | FileCheck %s
3
4# Check that when we split the live-range with several active lanes
5# as part of the live-range update, we correctly eliminate the VNI from
6# the relevant part.
7#
8# In this specific test, the register coalescer will:
9# 1. Merge %0 with %1, creating a live-range for the full value subreg_l32 + subreg_h32
10# (actually %0 gets merge with %1 via rematerialization, and technically %0 and %1
11# remain two different live-ranges.)
12# 2. Merge %2 with %1 triggering a split into the subreg_l32 + subreg_h32 ranges, since
13# %2 only touches subreg_l32. As part of the split the subrange covering subreg_h32
14# must contain only the VNI for the high part (i.e., the one tied with the remaaat of %0).
15# This used to be broken and trigger a machine verifier error, because we were not
16# clearing the dead value w.r.t. lanes when doing the splitting. I.e., we were ending
17# with a subrange referring a value that did not define that lane.
18#
19# PR40835
20---
21name: main
22tracksRegLiveness: true
23body: |
24 bb.0:
25
26 ; CHECK-LABEL: name: main
27 ; CHECK: [[LGHI:%[0-9]+]]:gr64bit = LGHI 43
28 ; CHECK: [[LGHI1:%[0-9]+]]:gr64bit = LGHI 43
29 ; CHECK: [[LGHI1]].subreg_l32:gr64bit = MSR [[LGHI1]].subreg_l32, [[LGHI1]].subreg_l32
30 ; CHECK: [[LGHI1]].subreg_l32:gr64bit = AHIMux [[LGHI1]].subreg_l32, 9, implicit-def dead $cc
31 ; CHECK: undef %3.subreg_l64:gr128bit = LGFI -245143785, implicit [[LGHI1]].subreg_l32
32 ; CHECK: [[DLGR:%[0-9]+]]:gr128bit = DLGR [[DLGR]], [[LGHI]]
33 ; CHECK: Return implicit [[DLGR]]
34 %0:gr64bit = LGHI 43
35 %1:gr32bit = COPY %0.subreg_l32
36 %1:gr32bit = MSR %1, %1
37 %2:gr32bit = COPY killed %1
38 %2:gr32bit = AHIMux killed %2, 9, implicit-def dead $cc
39 undef %3.subreg_l64:gr128bit = LGFI -245143785, implicit killed %2
40 %3:gr128bit = DLGR %3:gr128bit, killed %0
41 Return implicit killed %3
42
43...
44
45# Make sure the compiler does not choke on VNIs that don't
46# an explicit MI as definition.
47# In that specific example, this is the PHI not explicitly
48# represented for the value carried by %7.
49---
50name: segfault
51tracksRegLiveness: true
52liveins: []
53body: |
54 ; CHECK-LABEL: name: segfault
55 ; CHECK: bb.0:
56 ; CHECK: successors: %bb.1(0x80000000)
57 ; CHECK: [[LGHI:%[0-9]+]]:addr64bit = LGHI 0
58 ; CHECK: bb.1:
59 ; CHECK: successors: %bb.1(0x80000000)
60 ; CHECK: ADJCALLSTACKDOWN 0, 0
61 ; CHECK: [[LGFR:%[0-9]+]]:gr64bit = LGFR [[LGHI]].subreg_l32
62 ; CHECK: $r2d = LGHI 123
63 ; CHECK: $r3d = LGHI 0
64 ; CHECK: $r4d = LGHI 0
65 ; CHECK: $r5d = COPY [[LGFR]]
Yusra Syeda8b624a32021-02-17 16:06:02 -050066 ; CHECK: KILL killed $r2d, killed $r3d, killed $r4d, $r5d, csr_systemz_elf, implicit-def dead $r14d, implicit-def dead $cc
Quentin Colombetc74271c2019-03-26 21:27:15 +000067 ; CHECK: ADJCALLSTACKUP 0, 0
68 ; CHECK: [[LGHI]]:addr64bit = nuw nsw LA [[LGHI]], 1, $noreg
69 ; CHECK: J %bb.1
70 bb.0:
71 successors: %bb.1(0x80000000)
72
73 %2:gr64bit = LGHI 0
74 %5:gr64bit = LGHI 123
75 %7:addr64bit = COPY %2
76
77 bb.1:
78 successors: %bb.1(0x80000000)
79
80 %0:addr64bit = COPY killed %7
81 ADJCALLSTACKDOWN 0, 0
82 %3:gr32bit = COPY %0.subreg_l32
83 %4:gr64bit = LGFR killed %3
84 $r2d = COPY %5
85 $r3d = COPY %2
86 $r4d = COPY %2
87 $r5d = COPY killed %4
Yusra Syeda8b624a32021-02-17 16:06:02 -050088 KILL killed $r2d, killed $r3d, killed $r4d, killed $r5d, csr_systemz_elf, implicit-def dead $r14d, implicit-def dead $cc
Quentin Colombetc74271c2019-03-26 21:27:15 +000089 ADJCALLSTACKUP 0, 0
90 %1:gr64bit = nuw nsw LA killed %0, 1, $noreg
91 %7:addr64bit = COPY killed %1
92 J %bb.1
93
94...