• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt -jump-threading -S < %s | FileCheck %s
3
4@x = global i32 0
5@y = global i32 0
6
7declare void @f()
8declare void @g()
9
10define i32 @pre(i1 %cond, i32 %n) {
11; CHECK-LABEL: @pre(
12; CHECK-NEXT:    br i1 [[COND:%.*]], label [[C_THREAD:%.*]], label [[C:%.*]]
13; CHECK:       C.thread:
14; CHECK-NEXT:    store i32 0, i32* @x, align 4
15; CHECK-NEXT:    br label [[YES:%.*]]
16; CHECK:       C:
17; CHECK-NEXT:    [[A_PR:%.*]] = load i32, i32* @y, align 4
18; CHECK-NEXT:    [[COND2:%.*]] = icmp eq i32 [[A_PR]], 0
19; CHECK-NEXT:    br i1 [[COND2]], label [[YES]], label [[NO:%.*]]
20; CHECK:       YES:
21; CHECK-NEXT:    [[A4:%.*]] = phi i32 [ 0, [[C_THREAD]] ], [ [[A_PR]], [[C]] ]
22; CHECK-NEXT:    call void @f()
23; CHECK-NEXT:    ret i32 [[A4]]
24; CHECK:       NO:
25; CHECK-NEXT:    call void @g()
26; CHECK-NEXT:    ret i32 1
27;
28  br i1 %cond, label %A, label %B
29A:
30  store i32 0, i32* @x
31  br label %C
32B:
33  br label %C
34C:
35  %ptr = phi i32* [@x, %A], [@y, %B]
36  %a = load i32, i32* %ptr
37  %cond2 = icmp eq i32 %a, 0
38  br i1 %cond2, label %YES, label %NO
39YES:
40  call void @f()
41  ret i32 %a
42NO:
43  call void @g()
44  ret i32 1
45}
46
47define i32 @pre_freeze(i1 %cond, i32 %n) {
48; CHECK-LABEL: @pre_freeze(
49; CHECK-NEXT:    br i1 [[COND:%.*]], label [[C_THREAD:%.*]], label [[C:%.*]]
50; CHECK:       C.thread:
51; CHECK-NEXT:    store i32 0, i32* @x, align 4
52; CHECK-NEXT:    br label [[YES:%.*]]
53; CHECK:       C:
54; CHECK-NEXT:    [[A_PR:%.*]] = load i32, i32* @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:%.*]]
58; CHECK:       YES:
59; CHECK-NEXT:    [[A5:%.*]] = phi i32 [ 0, [[C_THREAD]] ], [ [[A_PR]], [[C]] ]
60; CHECK-NEXT:    call void @f()
61; CHECK-NEXT:    ret i32 [[A5]]
62; CHECK:       NO:
63; CHECK-NEXT:    call void @g()
64; CHECK-NEXT:    ret i32 1
65;
66  br i1 %cond, label %A, label %B
67A:
68  store i32 0, i32* @x
69  br label %C
70B:
71  br label %C
72C:
73  %ptr = phi i32* [@x, %A], [@y, %B]
74  %a = load i32, i32* %ptr
75  %cond2 = icmp eq i32 %a, 0
76  %cond2.fr = freeze i1 %cond2
77  br i1 %cond2.fr, label %YES, label %NO
78YES:
79  call void @f()
80  ret i32 %a
81NO:
82  call void @g()
83  ret i32 1
84}
85