1 ; RUN: opt -S -basic-aa -newgvn %s | FileCheck %s
3 ; CHECK: define i32 @main() {
5 ; CHECK-NEXT: %tmp = load i32, i32* @d, align 4
6 ; CHECK-NEXT: %tmp1 = load i32, i32* @c, align 4
7 ; CHECK-NEXT: %tobool = icmp eq i32 %tmp1, -1
8 ; CHECK-NEXT: br i1 %tobool, label %if.end, label %if.then
10 ; CHECK-NEXT: br label %L
12 ; CHECK-NEXT: %e.0 = phi i32 [ 0, %if.then ], [ %e.1, %if.then4 ]
13 ; CHECK-NEXT: br label %if.end
15 ; CHECK-NEXT: %e.1 = phi i32 [ %e.0, %L ], [ %tmp, %entry ]
16 ; CHECK-NEXT: store i32 %e.1, i32* @a, align 4
17 ; CHECK-NEXT: %tmp2 = load i32, i32* @b, align 4
18 ; CHECK-NEXT: store i32 0, i32* @b, align 4
19 ; CHECK-NEXT: %sext = shl i32 %tmp2, 16
20 ; CHECK-NEXT: %conv1 = ashr exact i32 %sext, 16
21 ; CHECK-NEXT: %add = add nsw i32 %conv1, %tmp1
22 ; CHECK-NEXT: %add2 = add nsw i32 %add, %e.1
23 ; CHECK-NEXT: store i32 %add2, i32* @a, align 4
24 ; CHECK-NEXT: %tobool3 = icmp eq i32 %add2, 0
25 ; CHECK-NEXT: br i1 %tobool3, label %if.end5, label %if.then4
27 ; CHECK-NEXT: br label %L
29 ; CHECK-NEXT: ret i32 0
32 @d = global i32 1, align 4
33 @c = common global i32 0, align 4
34 @a = common global i32 0, align 4
35 @b = common global i32 0, align 4
39 %tmp = load i32, i32* @d, align 4
40 %tmp1 = load i32, i32* @c, align 4
41 %tobool = icmp eq i32 %tmp1, -1
42 br i1 %tobool, label %if.end, label %if.then
44 if.then: ; preds = %entry
47 L: ; preds = %if.then4, %if.then
48 %e.0 = phi i32 [ 0, %if.then ], [ %e.1, %if.then4 ]
51 if.end: ; preds = %L, %entry
52 %e.1 = phi i32 [ %e.0, %L ], [ %tmp, %entry ]
53 store i32 %e.1, i32* @a, align 4
54 %tmp2 = load i32, i32* @b, align 4
55 store i32 0, i32* @b, align 4
56 %sext = shl i32 %tmp2, 16
57 %conv1 = ashr exact i32 %sext, 16
58 %tmp3 = load i32, i32* @c, align 4
59 %add = add nsw i32 %conv1, %tmp3
60 %tmp4 = load i32, i32* @a, align 4
61 %and = and i32 %tmp4, %e.1
62 %add2 = add nsw i32 %add, %and
63 store i32 %add2, i32* @a, align 4
64 %tobool3 = icmp eq i32 %add2, 0
65 br i1 %tobool3, label %if.end5, label %if.then4
67 if.then4: ; preds = %if.end
70 if.end5: ; preds = %if.end