1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=jump-threading -S < %s | FileCheck %s
10 define i32 @pre(i1 %cond, i32 %n) {
12 ; CHECK-NEXT: br i1 [[COND:%.*]], label [[C_THREAD:%.*]], label [[C:%.*]]
14 ; CHECK-NEXT: store i32 0, ptr @x, align 4
15 ; CHECK-NEXT: br label [[YES:%.*]]
17 ; CHECK-NEXT: [[A_PR:%.*]] = load i32, ptr @y, align 4
18 ; CHECK-NEXT: [[COND2:%.*]] = icmp eq i32 [[A_PR]], 0
19 ; CHECK-NEXT: br i1 [[COND2]], label [[YES]], label [[NO:%.*]]
21 ; CHECK-NEXT: [[A4:%.*]] = phi i32 [ 0, [[C_THREAD]] ], [ [[A_PR]], [[C]] ]
22 ; CHECK-NEXT: call void @f()
23 ; CHECK-NEXT: ret i32 [[A4]]
25 ; CHECK-NEXT: call void @g()
26 ; CHECK-NEXT: ret i32 1
28 br i1 %cond, label %A, label %B
35 %ptr = phi ptr [@x, %A], [@y, %B]
36 %a = load i32, ptr %ptr
37 %cond2 = icmp eq i32 %a, 0
38 br i1 %cond2, label %YES, label %NO
47 define i32 @pre_freeze(i1 %cond, i32 %n) {
48 ; CHECK-LABEL: @pre_freeze(
49 ; CHECK-NEXT: br i1 [[COND:%.*]], label [[C_THREAD:%.*]], label [[C:%.*]]
51 ; CHECK-NEXT: store i32 0, ptr @x, align 4
52 ; CHECK-NEXT: br label [[YES:%.*]]
54 ; CHECK-NEXT: [[A_PR:%.*]] = load i32, ptr @y, align 4
55 ; CHECK-NEXT: [[COND2:%.*]] = icmp eq i32 [[A_PR]], 0
56 ; CHECK-NEXT: [[COND2_FR:%.*]] = freeze i1 [[COND2]]
57 ; CHECK-NEXT: br i1 [[COND2_FR]], label [[YES]], label [[NO:%.*]]
59 ; CHECK-NEXT: [[A5:%.*]] = phi i32 [ 0, [[C_THREAD]] ], [ [[A_PR]], [[C]] ]
60 ; CHECK-NEXT: call void @f()
61 ; CHECK-NEXT: ret i32 [[A5]]
63 ; CHECK-NEXT: call void @g()
64 ; CHECK-NEXT: ret i32 1
66 br i1 %cond, label %A, label %B
73 %ptr = phi ptr [@x, %A], [@y, %B]
74 %a = load i32, ptr %ptr
75 %cond2 = icmp eq i32 %a, 0
76 %cond2.fr = freeze i1 %cond2
77 br i1 %cond2.fr, label %YES, label %NO