1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4
2 ; RUN: opt -S -passes=newgvn %s | FileCheck %s
5 @d = global i32 1, align 4
6 @c = common global i32 0, align 4
7 @a = common global i32 0, align 4
8 @b = common global i32 0, align 4
11 ; CHECK-LABEL: define i32 @main() {
13 ; CHECK-NEXT: [[TMP:%.*]] = load i32, ptr @d, align 4
14 ; CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr @c, align 4
15 ; CHECK-NEXT: [[TOBOOL:%.*]] = icmp eq i32 [[TMP1]], -1
16 ; CHECK-NEXT: br i1 [[TOBOOL]], label [[IF_END:%.*]], label [[IF_THEN:%.*]]
18 ; CHECK-NEXT: br label [[L:%.*]]
20 ; CHECK-NEXT: [[E_0:%.*]] = phi i32 [ 0, [[IF_THEN]] ], [ [[E_1:%.*]], [[IF_THEN4:%.*]] ]
21 ; CHECK-NEXT: br label [[IF_END]]
23 ; CHECK-NEXT: [[E_1]] = phi i32 [ [[E_0]], [[L]] ], [ [[TMP]], [[ENTRY:%.*]] ]
24 ; CHECK-NEXT: store i32 [[E_1]], ptr @a, align 4
25 ; CHECK-NEXT: [[TMP2:%.*]] = load i32, ptr @b, align 4
26 ; CHECK-NEXT: store i32 0, ptr @b, align 4
27 ; CHECK-NEXT: [[SEXT:%.*]] = shl i32 [[TMP2]], 16
28 ; CHECK-NEXT: [[CONV1:%.*]] = ashr exact i32 [[SEXT]], 16
29 ; CHECK-NEXT: [[ADD:%.*]] = add nsw i32 [[CONV1]], [[TMP1]]
30 ; CHECK-NEXT: [[ADD2:%.*]] = add nsw i32 [[ADD]], [[E_1]]
31 ; CHECK-NEXT: store i32 [[ADD2]], ptr @a, align 4
32 ; CHECK-NEXT: [[TOBOOL3:%.*]] = icmp eq i32 [[ADD2]], 0
33 ; CHECK-NEXT: br i1 [[TOBOOL3]], label [[IF_END5:%.*]], label [[IF_THEN4]]
35 ; CHECK-NEXT: br label [[L]]
37 ; CHECK-NEXT: ret i32 0
40 %tmp = load i32, ptr @d, align 4
41 %tmp1 = load i32, ptr @c, align 4
42 %tobool = icmp eq i32 %tmp1, -1
43 br i1 %tobool, label %if.end, label %if.then
45 if.then: ; preds = %entry
48 L: ; preds = %if.then4, %if.then
49 %e.0 = phi i32 [ 0, %if.then ], [ %e.1, %if.then4 ]
52 if.end: ; preds = %L, %entry
53 %e.1 = phi i32 [ %e.0, %L ], [ %tmp, %entry ]
54 store i32 %e.1, ptr @a, align 4
55 %tmp2 = load i32, ptr @b, align 4
56 store i32 0, ptr @b, align 4
57 %sext = shl i32 %tmp2, 16
58 %conv1 = ashr exact i32 %sext, 16
59 %tmp3 = load i32, ptr @c, align 4
60 %add = add nsw i32 %conv1, %tmp3
61 %tmp4 = load i32, ptr @a, align 4
62 %and = and i32 %tmp4, %e.1
63 %add2 = add nsw i32 %add, %and
64 store i32 %add2, ptr @a, align 4
65 %tobool3 = icmp eq i32 %add2, 0
66 br i1 %tobool3, label %if.end5, label %if.then4
68 if.then4: ; preds = %if.end
71 if.end5: ; preds = %if.end