1cee313d2SEric Christopher; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2cee313d2SEric Christopher; RUN: opt < %s -S -jump-threading | FileCheck %s
3cee313d2SEric Christopher
4cee313d2SEric Christopher; This test used to cause jump threading to try to split an edge of a callbr.
5cee313d2SEric Christopher
6cee313d2SEric Christopher@a = global i32 0
7cee313d2SEric Christopher
8cee313d2SEric Christopherdefine i32 @c() {
9cee313d2SEric Christopher; CHECK-LABEL: @c(
10cee313d2SEric Christopher; CHECK-NEXT:  entry:
1140a4078eSNikita Popov; CHECK-NEXT:    [[TMP0:%.*]] = load i32, i32* @a, align 4
12cee313d2SEric Christopher; CHECK-NEXT:    [[TOBOOL:%.*]] = icmp eq i32 [[TMP0]], 0
1340a4078eSNikita Popov; CHECK-NEXT:    br i1 [[TOBOOL]], label [[IF_ELSE:%.*]], label [[IF_END:%.*]]
1440a4078eSNikita Popov; CHECK:       if.else:
152a721374SNikita Popov; CHECK-NEXT:    callbr void asm sideeffect "", "!i"()
16*1cf6b93dSNick Desaulniers; CHECK-NEXT:    to label [[NORMAL:%.*]] [label %if.then2]
17*1cf6b93dSNick Desaulniers; CHECK:       normal:
18*1cf6b93dSNick Desaulniers; CHECK-NEXT:    br label [[IF_THEN2:%.*]]
1940a4078eSNikita Popov; CHECK:       if.end:
20cee313d2SEric Christopher; CHECK-NEXT:    [[CALL:%.*]] = call i32 @b()
21cee313d2SEric Christopher; CHECK-NEXT:    [[PHITMP:%.*]] = icmp ne i32 [[CALL]], 0
2240a4078eSNikita Popov; CHECK-NEXT:    br i1 [[PHITMP]], label [[IF_THEN2]], label [[IF_END4:%.*]]
23cee313d2SEric Christopher; CHECK:       if.then2:
24cee313d2SEric Christopher; CHECK-NEXT:    [[CALL3:%.*]] = call i32 @b()
25cee313d2SEric Christopher; CHECK-NEXT:    br label [[IF_END4]]
26cee313d2SEric Christopher; CHECK:       if.end4:
27cee313d2SEric Christopher; CHECK-NEXT:    ret i32 undef
28cee313d2SEric Christopher;
29cee313d2SEric Christopherentry:
30cee313d2SEric Christopher  %0 = load i32, i32* @a
31cee313d2SEric Christopher  %tobool = icmp eq i32 %0, 0
32cee313d2SEric Christopher  br i1 %tobool, label %if.else, label %if.then
33cee313d2SEric Christopher
34cee313d2SEric Christopherif.then:                                          ; preds = %entry
35cee313d2SEric Christopher  %call = call i32 @b() #2
36cee313d2SEric Christopher  %phitmp = icmp ne i32 %call, 0
37cee313d2SEric Christopher  br label %if.end
38cee313d2SEric Christopher
39cee313d2SEric Christopherif.else:                                          ; preds = %entry
402a721374SNikita Popov  callbr void asm sideeffect "", "!i"() #2
41cee313d2SEric Christopher  to label %normal [label %if.end]
42cee313d2SEric Christopher
43cee313d2SEric Christophernormal:                                           ; preds = %if.else
44cee313d2SEric Christopher  br label %if.end
45cee313d2SEric Christopher
46cee313d2SEric Christopherif.end:                                           ; preds = %if.else, %normal, %if.then
47cee313d2SEric Christopher  %d.0 = phi i1 [ %phitmp, %if.then ], [ undef, %normal ], [ undef, %if.else ]
48cee313d2SEric Christopher  br i1 %d.0, label %if.then2, label %if.end4
49cee313d2SEric Christopher
50cee313d2SEric Christopherif.then2:                                         ; preds = %if.end
51cee313d2SEric Christopher  %call3 = call i32 @b()
52cee313d2SEric Christopher  br label %if.end4
53cee313d2SEric Christopher
54cee313d2SEric Christopherif.end4:                                          ; preds = %if.then2, %if.end
55cee313d2SEric Christopher  ret i32 undef
56cee313d2SEric Christopher}
57cee313d2SEric Christopher
58cee313d2SEric Christopherdeclare i32 @b()
59