1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature
2 ; RUN: opt < %s -S -passes=ipsccp | FileCheck %s
4 ; After the first round of Solver.Solve(), the return value of @testf still
5 ; undefined as we hit a branch on undef. Therefore the conditional branch on
6 ; @testf's return value in @bar is unknown. In ResolvedUndefsIn, we force the
7 ; false branch to be feasible. We later discover that @testf actually
8 ; returns true, so we end up with an unfolded "br i1 true".
10 ; CHECK-LABEL: define {{[^@]+}}@test1() {
12 ; CHECK-NEXT: br label [[IF_THEN:%.*]]
14 ; CHECK-NEXT: [[FOO:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[NEXT:%.*]], [[IF_THEN]] ]
15 ; CHECK-NEXT: [[NEXT]] = add i32 [[FOO]], 1
16 ; CHECK-NEXT: [[CALL:%.*]] = call i1 @testf()
17 ; CHECK-NEXT: br i1 true, label [[IF_END:%.*]], label [[IF_THEN]]
19 ; CHECK-NEXT: ret void
23 if.then: ; preds = %entry, %if.then
24 %foo = phi i32 [ 0, %entry], [ %next, %if.then]
25 %next = add i32 %foo, 1
26 %call = call i1 @testf()
27 br i1 %call, label %if.end, label %if.then
29 if.end: ; preds = %if.then, %entry
33 define internal i1 @testf() {
34 ; CHECK-LABEL: define {{[^@]+}}@testf() {
36 ; CHECK-NEXT: br label [[IF_END3:%.*]]
38 ; CHECK-NEXT: ret i1 undef
41 br i1 undef, label %if.then1, label %if.end3
43 if.then1: ; preds = %if.end
46 if.end3: ; preds = %if.then1, %entry
50 ; Call sites in unreachable blocks should not be a problem.
52 ; CHECK-LABEL: define {{[^@]+}}@test2() {
54 ; CHECK-NEXT: br label [[IF_END:%.*]]
56 ; CHECK-NEXT: [[CALL2:%.*]] = call i1 @testf()
57 ; CHECK-NEXT: ret i1 true
62 if.then: ; preds = %entry, %if.then
63 %call = call i1 @testf()
64 br i1 %call, label %if.end, label %if.then
66 if.end: ; preds = %if.then, %entry
67 %call2 = call i1 @testf()