1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt < %s -S -jump-threading | FileCheck %s
3
4; This test used to cause jump threading to try to split an edge of a callbr.
5
6@a = global i32 0
7
8define i32 @c() {
9; CHECK-LABEL: @c(
10; CHECK-NEXT:  entry:
11; CHECK-NEXT:    [[TMP0:%.*]] = load i32, i32* @a
12; CHECK-NEXT:    [[TOBOOL:%.*]] = icmp eq i32 [[TMP0]], 0
13; CHECK-NEXT:    br i1 [[TOBOOL]], label [[IF_ELSE:%.*]], label [[IF_THEN:%.*]]
14; CHECK:       if.then:
15; CHECK-NEXT:    [[CALL:%.*]] = call i32 @b()
16; CHECK-NEXT:    [[PHITMP:%.*]] = icmp ne i32 [[CALL]], 0
17; CHECK-NEXT:    br i1 [[PHITMP]], label [[IF_THEN2:%.*]], label [[IF_END4:%.*]]
18; CHECK:       if.else:
19; CHECK-NEXT:    callbr void asm sideeffect "", "X"(i8* blockaddress(@c, [[IF_THEN2]]))
20; CHECK-NEXT:    to label [[IF_END_THREAD:%.*]] [label %if.then2]
21; CHECK:       if.end.thread:
22; CHECK-NEXT:    br label [[IF_THEN2]]
23; CHECK:       if.then2:
24; CHECK-NEXT:    [[CALL3:%.*]] = call i32 @b()
25; CHECK-NEXT:    br label [[IF_END4]]
26; CHECK:       if.end4:
27; CHECK-NEXT:    ret i32 undef
28;
29entry:
30  %0 = load i32, i32* @a
31  %tobool = icmp eq i32 %0, 0
32  br i1 %tobool, label %if.else, label %if.then
33
34if.then:                                          ; preds = %entry
35  %call = call i32 @b() #2
36  %phitmp = icmp ne i32 %call, 0
37  br label %if.end
38
39if.else:                                          ; preds = %entry
40  callbr void asm sideeffect "", "X"(i8* blockaddress(@c, %if.end)) #2
41  to label %normal [label %if.end]
42
43normal:                                           ; preds = %if.else
44  br label %if.end
45
46if.end:                                           ; preds = %if.else, %normal, %if.then
47  %d.0 = phi i1 [ %phitmp, %if.then ], [ undef, %normal ], [ undef, %if.else ]
48  br i1 %d.0, label %if.then2, label %if.end4
49
50if.then2:                                         ; preds = %if.end
51  %call3 = call i32 @b()
52  br label %if.end4
53
54if.end4:                                          ; preds = %if.then2, %if.end
55  ret i32 undef
56}
57
58declare i32 @b()
59