1; RUN: llc -march=hexagon < %s | FileCheck %s
2; REQUIRES: asserts
3
4; Test that the compiler doesn't assert because IMPLICIT_DEF instructions are
5; are added to the same packet as a use. This test case asserts if the
6; IMPLICIT_DEFs are not handled properly.
7;
8; r0 = IMPLICIT_DEF
9; r1 = IMPLICIT_DEF
10; S2_storerd_io r29, 0, d0
11
12; CHECK: memd(r29+#0) = r{{[0-9]+}}:{{[0-9]+}}
13; CHECK: memd(r29+#0) = r{{[0-9]+}}:{{[0-9]+}}
14
15define i8** @f0(i8* %a0) local_unnamed_addr {
16b0:
17  %v0 = tail call i8* @f1(i32 0)
18  %v1 = tail call i8* @f1(i32 8)
19  %v2 = bitcast i8* %v1 to i8**
20  %v3 = load i32, i32* undef, align 4
21  %v4 = tail call i8* @f4(i8* %a0, i32 0, i32 %v3)
22  %v5 = sub nsw i32 %v3, 0
23  br label %b1
24
25b1:                                               ; preds = %b0
26  switch i8 undef, label %b3 [
27    i8 0, label %b4
28    i8 92, label %b2
29    i8 44, label %b4
30  ]
31
32b2:                                               ; preds = %b1
33  unreachable
34
35b3:                                               ; preds = %b1
36  unreachable
37
38b4:                                               ; preds = %b1, %b1
39  br label %b5
40
41b5:                                               ; preds = %b4
42  br i1 undef, label %b27, label %b6
43
44b6:                                               ; preds = %b5
45  %v6 = ptrtoint i8* %v4 to i32
46  %v7 = sub i32 0, %v6
47  %v8 = call i8* @f4(i8* nonnull %v4, i32 0, i32 %v7)
48  %v9 = call i8* @f4(i8* nonnull %v4, i32 undef, i32 %v5)
49  br label %b7
50
51b7:                                               ; preds = %b6
52  br i1 undef, label %b8, label %b9
53
54b8:                                               ; preds = %b7
55  br label %b9
56
57b9:                                               ; preds = %b8, %b7
58  %v10 = phi i32 [ 2, %b8 ], [ 0, %b7 ]
59  %v11 = load i8, i8* %v9, align 1
60  switch i8 %v11, label %b12 [
61    i8 43, label %b10
62    i8 45, label %b10
63  ]
64
65b10:                                              ; preds = %b9, %b9
66  br i1 undef, label %b11, label %b12
67
68b11:                                              ; preds = %b10
69  %v12 = call i64 @f6(i8* nonnull %v9, i8** nonnull undef, i32 10)
70  %v13 = load i8*, i8** undef, align 4
71  %v14 = ptrtoint i8* %v13 to i32
72  br label %b15
73
74b12:                                              ; preds = %b10, %b9
75  switch i8 undef, label %b14 [
76    i8 0, label %b13
77    i8 46, label %b13
78  ]
79
80b13:                                              ; preds = %b12, %b12
81  br label %b15
82
83b14:                                              ; preds = %b12
84  unreachable
85
86b15:                                              ; preds = %b13, %b11
87  %v15 = phi i32 [ undef, %b13 ], [ %v14, %b11 ]
88  %v16 = phi i32 [ 2, %b13 ], [ 1, %b11 ]
89  %v17 = phi i64 [ undef, %b13 ], [ %v12, %b11 ]
90  %v18 = call i32* @f5()
91  br label %b16
92
93b16:                                              ; preds = %b15
94  %v19 = icmp ne i32 %v10, %v16
95  %v20 = or i1 undef, %v19
96  br i1 %v20, label %b17, label %b18
97
98b17:                                              ; preds = %b16
99  call void @f2(i8* %v8)
100  br label %b27
101
102b18:                                              ; preds = %b16
103  br i1 undef, label %b19, label %b20
104
105b19:                                              ; preds = %b18
106  br label %b24
107
108b20:                                              ; preds = %b18
109  %v21 = add i32 %v5, -2
110  %v22 = sub i32 %v21, %v7
111  %v23 = add i32 %v22, %v15
112  %v24 = sub i32 %v23, 0
113  br label %b21
114
115b21:                                              ; preds = %b20
116  %v25 = icmp ne i32 %v24, 2
117  %v26 = and i1 %v25, undef
118  br i1 %v26, label %b22, label %b23
119
120b22:                                              ; preds = %b21
121  unreachable
122
123b23:                                              ; preds = %b21
124  br label %b24
125
126b24:                                              ; preds = %b23, %b19
127  %v27 = phi i64 [ 0, %b19 ], [ %v17, %b23 ]
128  br label %b25
129
130b25:                                              ; preds = %b24
131  %v28 = icmp sgt i64 undef, %v27
132  br i1 %v28, label %b28, label %b26
133
134b26:                                              ; preds = %b25
135  unreachable
136
137b27:                                              ; preds = %b17, %b5
138  call void @f2(i8* %v4)
139  call void @f2(i8* %v0)
140  %v29 = call i8* @f3(i8* undef, i8* nonnull %a0)
141  ret i8** %v2
142
143b28:                                              ; preds = %b25
144  call void @f2(i8* %v9)
145  unreachable
146}
147
148declare i8* @f1(i32) local_unnamed_addr
149
150declare void @f2(i8* nocapture) local_unnamed_addr
151
152declare i8* @f3(i8*, i8* nocapture readonly) local_unnamed_addr
153
154declare i8* @f4(i8*, i32, i32) local_unnamed_addr
155
156declare i32* @f5() local_unnamed_addr
157
158declare i64 @f6(i8*, i8**, i32) local_unnamed_addr
159