1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -passes=jump-threading < %s | FileCheck %s
4 %struct.ham = type { i8, i8, i16, i32 }
5 %struct.zot = type { ptr }
6 %struct.quux.0 = type { %struct.wombat }
7 %struct.wombat = type { %struct.zot }
9 @global = external global ptr, align 8
10 @global.1 = external constant ptr
12 declare i32 @wombat.2()
17 ; CHECK-NEXT: [[TMP:%.*]] = load i32, ptr undef, align 4
18 ; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i32 [[TMP]], 0
19 ; CHECK-NEXT: br i1 [[TMP1]], label [[BB11:%.*]], label [[BB2:%.*]]
21 ; CHECK-NEXT: [[TMP3:%.*]] = tail call i32 @wombat.2()
22 ; CHECK-NEXT: switch i32 [[TMP3]], label [[BB10:%.*]] [
23 ; CHECK-NEXT: i32 0, label [[BB7:%.*]]
24 ; CHECK-NEXT: i32 1, label [[BB10]]
25 ; CHECK-NEXT: i32 2, label [[BB10]]
26 ; CHECK-NEXT: i32 3, label [[BB11]]
29 ; CHECK-NEXT: [[TMP6:%.*]] = tail call i32 @wombat.2()
30 ; CHECK-NEXT: br label [[BB11]]
32 ; CHECK-NEXT: ret void
34 ; CHECK-NEXT: ret void
37 %tmp = load i32, ptr undef
38 %tmp1 = icmp eq i32 %tmp, 0
39 br i1 %tmp1, label %bb11, label %bb2
42 %tmp3 = tail call i32 @wombat.2()
43 switch i32 %tmp3, label %bb4 [
54 %tmp6 = tail call i32 @wombat.2()
58 %tmp8 = phi i32 [ 0, %bb5 ], [ 1, %bb4 ], [ 2, %bb2 ], [ 2, %bb2 ]
59 %tmp9 = icmp eq i32 %tmp8, 0
60 br i1 %tmp9, label %bb11, label %bb10
69 define void @spam(ptr %arg) {
72 ; CHECK-NEXT: [[TMP:%.*]] = load i8, ptr undef, align 8
73 ; CHECK-NEXT: switch i8 [[TMP]], label [[BB11:%.*]] [
74 ; CHECK-NEXT: i8 1, label [[BB11]]
75 ; CHECK-NEXT: i8 2, label [[BB11]]
76 ; CHECK-NEXT: i8 3, label [[BB1:%.*]]
77 ; CHECK-NEXT: i8 4, label [[BB1]]
80 ; CHECK-NEXT: br label [[BB2:%.*]]
82 ; CHECK-NEXT: [[TMP3:%.*]] = phi i32 [ 0, [[BB1]] ], [ [[TMP3]], [[BB8:%.*]] ]
83 ; CHECK-NEXT: br label [[BB4:%.*]]
85 ; CHECK-NEXT: [[TMP5:%.*]] = load i8, ptr undef, align 8
86 ; CHECK-NEXT: switch i8 [[TMP5]], label [[BB11]] [
87 ; CHECK-NEXT: i8 0, label [[BB11]]
88 ; CHECK-NEXT: i8 1, label [[BB10:%.*]]
89 ; CHECK-NEXT: i8 2, label [[BB10]]
90 ; CHECK-NEXT: i8 3, label [[BB8]]
91 ; CHECK-NEXT: i8 4, label [[BB8]]
94 ; CHECK-NEXT: [[TMP9:%.*]] = icmp eq ptr undef, [[ARG:%.*]]
95 ; CHECK-NEXT: br i1 [[TMP9]], label [[BB10]], label [[BB2]]
97 ; CHECK-NEXT: switch i32 [[TMP3]], label [[BB4]] [
98 ; CHECK-NEXT: i32 0, label [[BB16:%.*]]
99 ; CHECK-NEXT: i32 1, label [[BB11]]
100 ; CHECK-NEXT: i32 2, label [[BB12:%.*]]
103 ; CHECK-NEXT: unreachable
105 ; CHECK-NEXT: [[TMP13:%.*]] = load ptr, ptr undef, align 8
106 ; CHECK-NEXT: br label [[BB16]]
108 ; CHECK-NEXT: [[TMP15:%.*]] = phi ptr [ [[TMP13]], [[BB12]] ], [ null, [[BB10]] ]
109 ; CHECK-NEXT: [[TMP17:%.*]] = load i8, ptr undef, align 8
110 ; CHECK-NEXT: switch i8 [[TMP17]], label [[BB11]] [
111 ; CHECK-NEXT: i8 0, label [[BB11]]
112 ; CHECK-NEXT: i8 11, label [[BB23:%.*]]
113 ; CHECK-NEXT: i8 12, label [[BB23]]
116 ; CHECK-NEXT: [[TMP21:%.*]] = load ptr, ptr undef, align 8
117 ; CHECK-NEXT: [[TMP24:%.*]] = icmp eq ptr [[TMP21]], null
118 ; CHECK-NEXT: br i1 [[TMP24]], label [[BB37:%.*]], label [[BB25:%.*]]
120 ; CHECK-NEXT: [[TMP26:%.*]] = icmp eq ptr [[TMP15]], null
121 ; CHECK-NEXT: br i1 [[TMP26]], label [[BB41_THREAD:%.*]], label [[BB27:%.*]]
123 ; CHECK-NEXT: [[TMP28:%.*]] = load ptr, ptr undef, align 8
124 ; CHECK-NEXT: [[TMP29:%.*]] = icmp eq ptr [[TMP28]], [[TMP21]]
125 ; CHECK-NEXT: br i1 [[TMP29]], label [[BB41_THREAD]], label [[BB30:%.*]]
127 ; CHECK-NEXT: [[TMP32_PR:%.*]] = load i8, ptr undef, align 8
128 ; CHECK-NEXT: br label [[BB31:%.*]]
130 ; CHECK-NEXT: [[TMP32:%.*]] = phi i8 [ [[TMP32]], [[BB31]] ], [ [[TMP32_PR]], [[BB30]] ]
131 ; CHECK-NEXT: [[TMP33:%.*]] = icmp eq i8 [[TMP32]], 0
132 ; CHECK-NEXT: br i1 [[TMP33]], label [[BB31]], label [[BB37]]
134 ; CHECK-NEXT: [[TMP36:%.*]] = phi i1 [ false, [[BB23]] ], [ true, [[BB31]] ]
135 ; CHECK-NEXT: [[TMP38:%.*]] = icmp eq ptr [[TMP15]], null
136 ; CHECK-NEXT: br i1 [[TMP38]], label [[BB39:%.*]], label [[BB41:%.*]]
138 ; CHECK-NEXT: [[TMP364:%.*]] = phi i1 [ [[TMP36]], [[BB37]] ]
139 ; CHECK-NEXT: [[TMP40:%.*]] = load ptr, ptr @global, align 8
140 ; CHECK-NEXT: br i1 [[TMP364]], label [[BB41_THREAD]], label [[BB41_THREAD]]
142 ; CHECK-NEXT: [[TMP363:%.*]] = phi i1 [ [[TMP36]], [[BB37]] ]
143 ; CHECK-NEXT: br i1 [[TMP363]], label [[BB41_THREAD]], label [[BB41_THREAD]]
144 ; CHECK: bb41.thread:
145 ; CHECK-NEXT: [[TMP0:%.*]] = phi ptr [ undef, [[BB41]] ], [ undef, [[BB39]] ], [ undef, [[BB39]] ], [ undef, [[BB41]] ], [ undef, [[BB27]] ], [ undef, [[BB25]] ]
146 ; CHECK-NEXT: ret void
149 %tmp = load i8, ptr undef, align 8
150 switch i8 %tmp, label %bb11 [
161 %tmp3 = phi i32 [ 0, %bb1 ], [ %tmp3, %bb8 ]
165 %tmp5 = load i8, ptr undef, align 8
166 switch i8 %tmp5, label %bb11 [
178 br i1 undef, label %bb8, label %bb10
181 %tmp9 = icmp eq ptr undef, %arg
182 br i1 %tmp9, label %bb10, label %bb2
185 switch i32 %tmp3, label %bb4 [
195 %tmp13 = load ptr, ptr undef
199 %tmp15 = phi ptr [ %tmp13, %bb12 ], [ null, %bb10 ]
203 %tmp17 = load i8, ptr undef, align 8
204 switch i8 %tmp17, label %bb11 [
217 %tmp21 = load ptr, ptr undef
218 switch i8 undef, label %bb22 [
228 %tmp24 = icmp eq ptr %tmp21, null
229 br i1 %tmp24, label %bb35, label %bb25
232 %tmp26 = icmp eq ptr %tmp15, null
233 br i1 %tmp26, label %bb34, label %bb27
236 %tmp28 = load ptr, ptr undef
237 %tmp29 = icmp eq ptr %tmp28, %tmp21
238 br i1 %tmp29, label %bb35, label %bb30
244 %tmp32 = load i8, ptr undef, align 8
245 %tmp33 = icmp eq i8 %tmp32, 0
246 br i1 %tmp33, label %bb31, label %bb34
252 %tmp36 = phi i1 [ true, %bb34 ], [ false, %bb23 ], [ true, %bb27 ]
256 %tmp38 = icmp eq ptr %tmp15, null
257 br i1 %tmp38, label %bb39, label %bb41
260 %tmp40 = load ptr, ptr @global
264 %tmp42 = select i1 %tmp36, ptr undef, ptr undef
268 declare i32 @foo(...)
270 define void @zot() align 2 personality ptr @foo {
273 ; CHECK-NEXT: invoke void @bar()
274 ; CHECK-NEXT: to label [[BB1:%.*]] unwind label [[BB3:%.*]]
276 ; CHECK-NEXT: invoke void @bar()
277 ; CHECK-NEXT: to label [[BB2:%.*]] unwind label [[BB4:%.*]]
279 ; CHECK-NEXT: invoke void @bar()
280 ; CHECK-NEXT: to label [[BB6:%.*]] unwind label [[BB17:%.*]]
282 ; CHECK-NEXT: [[TMP:%.*]] = landingpad { ptr, i32 }
283 ; CHECK-NEXT: catch ptr @global.1
284 ; CHECK-NEXT: catch ptr null
285 ; CHECK-NEXT: unreachable
287 ; CHECK-NEXT: [[TMP5:%.*]] = landingpad { ptr, i32 }
288 ; CHECK-NEXT: catch ptr @global.1
289 ; CHECK-NEXT: catch ptr null
290 ; CHECK-NEXT: unreachable
292 ; CHECK-NEXT: invoke void @bar()
293 ; CHECK-NEXT: to label [[BB7:%.*]] unwind label [[BB19:%.*]]
295 ; CHECK-NEXT: invoke void @bar()
296 ; CHECK-NEXT: to label [[BB10:%.*]] unwind label [[BB8:%.*]]
298 ; CHECK-NEXT: [[TMP9:%.*]] = landingpad { ptr, i32 }
299 ; CHECK-NEXT: cleanup
300 ; CHECK-NEXT: catch ptr @global.1
301 ; CHECK-NEXT: catch ptr null
302 ; CHECK-NEXT: unreachable
304 ; CHECK-NEXT: [[TMP11:%.*]] = load ptr, ptr undef, align 8
305 ; CHECK-NEXT: [[TMP12:%.*]] = invoke i32 [[TMP11]](ptr nonnull undef)
306 ; CHECK-NEXT: to label [[BB13:%.*]] unwind label [[BB21:%.*]]
308 ; CHECK-NEXT: invoke void @bar()
309 ; CHECK-NEXT: to label [[BB14:%.*]] unwind label [[BB30:%.*]]
311 ; CHECK-NEXT: [[TMP15:%.*]] = load ptr, ptr undef, align 8
312 ; CHECK-NEXT: [[TMP16:%.*]] = invoke i32 [[TMP15]](ptr nonnull undef)
313 ; CHECK-NEXT: to label [[BB26:%.*]] unwind label [[BB30_THREAD:%.*]]
315 ; CHECK-NEXT: [[TMP18:%.*]] = landingpad { ptr, i32 }
316 ; CHECK-NEXT: catch ptr @global.1
317 ; CHECK-NEXT: catch ptr null
318 ; CHECK-NEXT: unreachable
320 ; CHECK-NEXT: [[TMP20:%.*]] = landingpad { ptr, i32 }
321 ; CHECK-NEXT: catch ptr @global.1
322 ; CHECK-NEXT: catch ptr null
323 ; CHECK-NEXT: unreachable
325 ; CHECK-NEXT: [[TMP22:%.*]] = landingpad { ptr, i32 }
326 ; CHECK-NEXT: catch ptr @global.1
327 ; CHECK-NEXT: catch ptr null
328 ; CHECK-NEXT: unreachable
330 ; CHECK-NEXT: [[TMP27:%.*]] = load ptr, ptr undef, align 8
331 ; CHECK-NEXT: [[TMP28:%.*]] = invoke i32 [[TMP27]](ptr nonnull undef)
332 ; CHECK-NEXT: to label [[BB29:%.*]] unwind label [[BB30_THREAD]]
334 ; CHECK-NEXT: unreachable
335 ; CHECK: bb30.thread:
336 ; CHECK-NEXT: [[LPAD_THR_COMM:%.*]] = landingpad { ptr, i32 }
337 ; CHECK-NEXT: catch ptr @global.1
338 ; CHECK-NEXT: catch ptr null
339 ; CHECK-NEXT: br label [[BB32:%.*]]
341 ; CHECK-NEXT: [[LPAD_THR_COMM_SPLIT_LP:%.*]] = landingpad { ptr, i32 }
342 ; CHECK-NEXT: catch ptr @global.1
343 ; CHECK-NEXT: catch ptr null
344 ; CHECK-NEXT: br label [[BB32]]
346 ; CHECK-NEXT: unreachable
350 to label %bb1 unwind label %bb3
354 to label %bb2 unwind label %bb4
358 to label %bb6 unwind label %bb17
361 %tmp = landingpad { ptr, i32 }
367 %tmp5 = landingpad { ptr, i32 }
374 to label %bb7 unwind label %bb19
378 to label %bb10 unwind label %bb8
381 %tmp9 = landingpad { ptr, i32 }
388 %tmp11 = load ptr, ptr undef, align 8
389 %tmp12 = invoke i32 %tmp11(ptr nonnull undef)
390 to label %bb13 unwind label %bb21
394 to label %bb14 unwind label %bb23
397 %tmp15 = load ptr, ptr undef, align 8
398 %tmp16 = invoke i32 %tmp15(ptr nonnull undef)
399 to label %bb26 unwind label %bb23
402 %tmp18 = landingpad { ptr, i32 }
408 %tmp20 = landingpad { ptr, i32 }
414 %tmp22 = landingpad { ptr, i32 }
420 %tmp24 = phi ptr [ null, %bb26 ], [ null, %bb14 ], [ undef, %bb13 ]
421 %tmp25 = landingpad { ptr, i32 }
427 %tmp27 = load ptr, ptr undef, align 8
428 %tmp28 = invoke i32 %tmp27(ptr nonnull undef)
429 to label %bb29 unwind label %bb23
435 %tmp31 = icmp eq ptr %tmp24, null
436 br i1 %tmp31, label %bb32, label %bb29