1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -newgvn -S %s | FileCheck %s
4 ; Test cases to make sure the blocks are properly marked as executable, if the
5 ; state of the branch condition changes.
7 ; Test case to make sure the case where a condition cannot be simplified is
10 ; CHECK-LABEL: @test1(
12 ; CHECK-NEXT: [[CALL:%.*]] = tail call i1 @foo()
13 ; CHECK-NEXT: br i1 [[CALL]], label [[THEN:%.*]], label [[ELSE:%.*]]
15 ; CHECK-NEXT: ret i1 true
17 ; CHECK-NEXT: ret i1 false
20 %call = tail call i1 @foo()
21 br i1 %call, label %then, label %else
32 ; Make sure state changes are propagated across freeze to branches.
33 define void @test2(i1 %c) {
34 ; CHECK-LABEL: @test2(
36 ; CHECK-NEXT: br label [[LOOP_HEADER:%.*]]
38 ; CHECK-NEXT: [[P_0:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[INC:%.*]], [[LOOP_LATCH:%.*]] ]
39 ; CHECK-NEXT: [[P_1:%.*]] = phi i32 [ 1, [[ENTRY]] ], [ [[P_2:%.*]], [[LOOP_LATCH]] ]
40 ; CHECK-NEXT: br label [[LOOP_BB_1:%.*]]
42 ; CHECK-NEXT: [[INC]] = add nsw i32 [[P_0]], 1
43 ; CHECK-NEXT: [[C_1:%.*]] = icmp slt i32 [[P_0]], 0
44 ; CHECK-NEXT: [[C_1_FREEZE:%.*]] = freeze i1 [[C_1]]
45 ; CHECK-NEXT: br i1 [[C_1_FREEZE]], label [[LOOP_BB_2:%.*]], label [[LOOP_LATCH]]
47 ; CHECK-NEXT: br label [[LOOP_LATCH]]
49 ; CHECK-NEXT: [[P_2]] = phi i32 [ 0, [[LOOP_BB_2]] ], [ [[P_1]], [[LOOP_BB_1]] ]
50 ; CHECK-NEXT: [[C_2:%.*]] = icmp eq i32 [[P_2]], 123
51 ; CHECK-NEXT: br i1 [[C_2]], label [[EXIT:%.*]], label [[LOOP_HEADER]]
53 ; CHECK-NEXT: ret void
59 %p.0 = phi i32 [ 0, %entry ], [ %p.3, %loop.latch ]
60 %p.1 = phi i32 [ 1, %entry ], [ %p.2, %loop.latch ]
64 %inc = add nsw i32 %p.0, 1
65 %c.1 = icmp slt i32 %p.0, 0
66 %c.1.freeze = freeze i1 %c.1
67 br i1 %c.1.freeze, label %loop.bb.2, label %loop.latch
73 %p.2 = phi i32 [ 0, %loop.bb.2 ], [ %p.1, %loop.bb.1 ]
74 %p.3 = phi i32 [ %inc, %loop.bb.2 ], [ %inc, %loop.bb.1 ]
75 %c.2 = icmp eq i32 %p.2, 123
76 br i1 %c.2, label %exit, label %loop.header