xref: /llvm-project/llvm/test/CodeGen/SystemZ/regalloc-GR128-02.mir (revision ff9af4c43ad71eeba2cabe99609cfaa0fd54c1d0)
1# RUN: llc %s -mtriple=s390x-linux-gnu -mcpu=z13 \
2# RUN:   -start-before=register-coalescer -o - 2>&1 > /dev/null
3
4# Test that the SystemZ shouldCoalesce() implementation does not crash in
5# case of an undef use in another MBB. This was discovered in testing with
6# -systemz-subreg-liveness.
7
8--- |
9  @g_74 = external dso_local unnamed_addr global i32, align 4
10  @g_193 = external dso_local unnamed_addr global i32, align 4
11
12  define dso_local void @main() local_unnamed_addr {
13    %1 = load i32, ptr @g_193
14    %2 = or i32 %1, -1395153718
15    %3 = sdiv i32 -1395153718, %2
16    br i1 undef, label %5, label %4
17
18  ; <label>:4:                                      ; preds = %0
19    store i32 %3, ptr @g_74
20    store i32 -9, ptr @g_74
21    ret void
22
23  ; <label>:5:                                      ; preds = %0
24    unreachable
25  }
26
27...
28---
29name:            main
30alignment:       16
31tracksRegLiveness: true
32registers:
33  - { id: 0, class: grx32bit }
34  - { id: 1, class: addr64bit }
35  - { id: 2, class: gr32bit }
36  - { id: 3, class: gr32bit }
37  - { id: 4, class: gr64bit }
38  - { id: 5, class: gr128bit }
39  - { id: 6, class: gr128bit }
40  - { id: 7, class: grx32bit }
41  - { id: 8, class: gr32bit }
42  - { id: 9, class: gr128bit }
43body:             |
44  bb.0 (%ir-block.0):
45    successors: %bb.2(0x00000001), %bb.1(0x7fffffff)
46
47    %1:addr64bit = LARL @g_193
48    %2:gr32bit = IIFMux 2899813578
49    %3:gr32bit = COPY killed %2
50    %3:gr32bit = O %3, killed %1, 0, $noreg, implicit-def dead $cc :: (dereferenceable load (s32) from @g_193)
51    %4:gr64bit = LGFI -1395153718
52    undef %5.subreg_l64:gr128bit = COPY killed %4
53    %6:gr128bit = COPY killed %5
54    dead %6:gr128bit = DSGFR %6, killed %3
55    %7:grx32bit = LHIMux 0
56    CHIMux killed %7, 0, implicit-def $cc
57    BRC 14, 6, %bb.2, implicit killed $cc
58    J %bb.1
59
60  bb.1 (%ir-block.4):
61    %8:gr32bit = LHIMux -9
62    STRL killed %8, @g_74 :: (store (s32) into @g_74)
63    Return
64
65  bb.2 (%ir-block.5):
66    dead %0:grx32bit = COPY undef %6.subreg_l32
67
68...
69