1; RUN: opt < %s -jump-threading -disable-output
2
3%struct.ham = type { i8, i8, i16, i32 }
4%struct.zot = type { i32 (...)** }
5%struct.quux.0 = type { %struct.wombat }
6%struct.wombat = type { %struct.zot }
7
8@global = external global %struct.ham*, align 8
9@global.1 = external constant i8*
10
11declare i32 @wombat.2()
12
13define void @blam() {
14bb:
15  %tmp = load i32, i32* undef
16  %tmp1 = icmp eq i32 %tmp, 0
17  br i1 %tmp1, label %bb11, label %bb2
18
19bb2:
20  %tmp3 = tail call i32 @wombat.2()
21  switch i32 %tmp3, label %bb4 [
22    i32 0, label %bb5
23    i32 1, label %bb7
24    i32 2, label %bb7
25    i32 3, label %bb11
26  ]
27
28bb4:
29  br label %bb7
30
31bb5:
32  %tmp6 = tail call i32 @wombat.2()
33  br label %bb7
34
35bb7:
36  %tmp8 = phi i32 [ 0, %bb5 ], [ 1, %bb4 ], [ 2, %bb2 ], [ 2, %bb2 ]
37  %tmp9 = icmp eq i32 %tmp8, 0
38  br i1 %tmp9, label %bb11, label %bb10
39
40bb10:
41  ret void
42
43bb11:
44  ret void
45}
46
47define void @spam(%struct.ham* %arg) {
48bb:
49  %tmp = load i8, i8* undef, align 8
50  switch i8 %tmp, label %bb11 [
51    i8 1, label %bb11
52    i8 2, label %bb11
53    i8 3, label %bb1
54    i8 4, label %bb1
55  ]
56
57bb1:
58  br label %bb2
59
60bb2:
61  %tmp3 = phi i32 [ 0, %bb1 ], [ %tmp3, %bb8 ]
62  br label %bb4
63
64bb4:
65  %tmp5 = load i8, i8* undef, align 8
66  switch i8 %tmp5, label %bb11 [
67    i8 0, label %bb11
68    i8 1, label %bb10
69    i8 2, label %bb10
70    i8 3, label %bb6
71    i8 4, label %bb6
72  ]
73
74bb6:
75  br label %bb7
76
77bb7:
78  br i1 undef, label %bb8, label %bb10
79
80bb8:
81  %tmp9 = icmp eq %struct.ham* undef, %arg
82  br i1 %tmp9, label %bb10, label %bb2
83
84bb10:
85  switch i32 %tmp3, label %bb4 [
86    i32 0, label %bb14
87    i32 1, label %bb11
88    i32 2, label %bb12
89  ]
90
91bb11:
92  unreachable
93
94bb12:
95  %tmp13 = load %struct.ham*, %struct.ham** undef
96  br label %bb14
97
98bb14:
99  %tmp15 = phi %struct.ham* [ %tmp13, %bb12 ], [ null, %bb10 ]
100  br label %bb16
101
102bb16:
103  %tmp17 = load i8, i8* undef, align 8
104  switch i8 %tmp17, label %bb11 [
105    i8 0, label %bb11
106    i8 11, label %bb18
107    i8 12, label %bb18
108  ]
109
110bb18:
111  br label %bb19
112
113bb19:
114  br label %bb20
115
116bb20:
117  %tmp21 = load %struct.ham*, %struct.ham** undef
118  switch i8 undef, label %bb22 [
119    i8 0, label %bb4
120    i8 11, label %bb10
121    i8 12, label %bb10
122  ]
123
124bb22:
125  br label %bb23
126
127bb23:
128  %tmp24 = icmp eq %struct.ham* %tmp21, null
129  br i1 %tmp24, label %bb35, label %bb25
130
131bb25:
132  %tmp26 = icmp eq %struct.ham* %tmp15, null
133  br i1 %tmp26, label %bb34, label %bb27
134
135bb27:
136  %tmp28 = load %struct.ham*, %struct.ham** undef
137  %tmp29 = icmp eq %struct.ham* %tmp28, %tmp21
138  br i1 %tmp29, label %bb35, label %bb30
139
140bb30:
141  br label %bb31
142
143bb31:
144  %tmp32 = load i8, i8* undef, align 8
145  %tmp33 = icmp eq i8 %tmp32, 0
146  br i1 %tmp33, label %bb31, label %bb34
147
148bb34:
149  br label %bb35
150
151bb35:
152  %tmp36 = phi i1 [ true, %bb34 ], [ false, %bb23 ], [ true, %bb27 ]
153  br label %bb37
154
155bb37:
156  %tmp38 = icmp eq %struct.ham* %tmp15, null
157  br i1 %tmp38, label %bb39, label %bb41
158
159bb39:
160  %tmp40 = load %struct.ham*, %struct.ham** @global
161  br label %bb41
162
163bb41:
164  %tmp42 = select i1 %tmp36, %struct.ham* undef, %struct.ham* undef
165  ret void
166}
167
168declare i32 @foo(...)
169
170define void @zot() align 2 personality i8* bitcast (i32 (...)* @foo to i8*) {
171bb:
172  invoke void @bar()
173          to label %bb1 unwind label %bb3
174
175bb1:
176  invoke void @bar()
177          to label %bb2 unwind label %bb4
178
179bb2:
180  invoke void @bar()
181          to label %bb6 unwind label %bb17
182
183bb3:
184  %tmp = landingpad { i8*, i32 }
185          catch i8* bitcast (i8** @global.1 to i8*)
186          catch i8* null
187  unreachable
188
189bb4:
190  %tmp5 = landingpad { i8*, i32 }
191          catch i8* bitcast (i8** @global.1 to i8*)
192          catch i8* null
193  unreachable
194
195bb6:
196  invoke void @bar()
197          to label %bb7 unwind label %bb19
198
199bb7:
200  invoke void @bar()
201          to label %bb10 unwind label %bb8
202
203bb8:
204  %tmp9 = landingpad { i8*, i32 }
205          cleanup
206          catch i8* bitcast (i8** @global.1 to i8*)
207          catch i8* null
208  unreachable
209
210bb10:
211  %tmp11 = load i32 (%struct.zot*)*, i32 (%struct.zot*)** undef, align 8
212  %tmp12 = invoke i32 %tmp11(%struct.zot* nonnull undef)
213          to label %bb13 unwind label %bb21
214
215bb13:
216  invoke void @bar()
217          to label %bb14 unwind label %bb23
218
219bb14:
220  %tmp15 = load i32 (%struct.zot*)*, i32 (%struct.zot*)** undef, align 8
221  %tmp16 = invoke i32 %tmp15(%struct.zot* nonnull undef)
222          to label %bb26 unwind label %bb23
223
224bb17:
225  %tmp18 = landingpad { i8*, i32 }
226          catch i8* bitcast (i8** @global.1 to i8*)
227          catch i8* null
228  unreachable
229
230bb19:
231  %tmp20 = landingpad { i8*, i32 }
232          catch i8* bitcast (i8** @global.1 to i8*)
233          catch i8* null
234  unreachable
235
236bb21:
237  %tmp22 = landingpad { i8*, i32 }
238          catch i8* bitcast (i8** @global.1 to i8*)
239          catch i8* null
240  unreachable
241
242bb23:
243  %tmp24 = phi %struct.quux.0* [ null, %bb26 ], [ null, %bb14 ], [ undef, %bb13 ]
244  %tmp25 = landingpad { i8*, i32 }
245          catch i8* bitcast (i8** @global.1 to i8*)
246          catch i8* null
247  br label %bb30
248
249bb26:
250  %tmp27 = load i32 (%struct.zot*)*, i32 (%struct.zot*)** undef, align 8
251  %tmp28 = invoke i32 %tmp27(%struct.zot* nonnull undef)
252          to label %bb29 unwind label %bb23
253
254bb29:
255  unreachable
256
257bb30:
258  %tmp31 = icmp eq %struct.quux.0* %tmp24, null
259  br i1 %tmp31, label %bb32, label %bb29
260
261bb32:
262  unreachable
263}
264
265declare void @bar()
266