1; RUN: llc -march=hexagon -machine-sink-split < %s
2; REQUIRES: asserts
3; MachineSink should not sink an MI which is used in a non-phi instruction
4; in an MBB with multiple predecessors.
5
6target triple = "hexagon-unknown--elf"
7
8; Function Attrs: nounwind
9define void @f0() #0 {
10b0:
11  br i1 undef, label %b1, label %b2
12
13b1:                                               ; preds = %b0
14  unreachable
15
16b2:                                               ; preds = %b0
17  %v0 = load i8*, i8** undef, align 4
18  %v1 = getelementptr inbounds i8, i8* %v0, i32 1
19  %v2 = load i8, i8* %v0, align 1, !tbaa !0
20  %v3 = zext i8 %v2 to i32
21  %v4 = shl nuw nsw i32 %v3, 8
22  br i1 undef, label %b3, label %b5
23
24b3:                                               ; preds = %b2
25  br i1 undef, label %b15, label %b4
26
27b4:                                               ; preds = %b3
28  br label %b5
29
30b5:                                               ; preds = %b4, %b2
31  %v5 = phi i8* [ undef, %b4 ], [ %v1, %b2 ]
32  %v6 = load i8, i8* %v5, align 1, !tbaa !0
33  %v7 = zext i8 %v6 to i32
34  %v8 = add nsw i32 %v7, %v4
35  %v9 = add nsw i32 %v8, -2
36  br label %b6
37
38b6:                                               ; preds = %b8, %b5
39  br i1 false, label %b7, label %b8
40
41b7:                                               ; preds = %b6
42  unreachable
43
44b8:                                               ; preds = %b6
45  br i1 undef, label %b6, label %b9
46
47b9:                                               ; preds = %b8
48  br i1 undef, label %b10, label %b14
49
50b10:                                              ; preds = %b9
51  br i1 undef, label %b11, label %b13
52
53b11:                                              ; preds = %b10
54  br i1 undef, label %b12, label %b13
55
56b12:                                              ; preds = %b11
57  unreachable
58
59b13:                                              ; preds = %b11, %b10
60  store i32 %v9, i32* undef, align 4, !tbaa !3
61  unreachable
62
63b14:                                              ; preds = %b9
64  unreachable
65
66b15:                                              ; preds = %b3
67  ret void
68}
69
70attributes #0 = { nounwind }
71
72!0 = !{!1, !1, i64 0}
73!1 = !{!"omnipotent char", !2, i64 0}
74!2 = !{!"Simple C/C++ TBAA"}
75!3 = !{!4, !4, i64 0}
76!4 = !{!"int", !1, i64 0}
77