1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes='require<loops>,gvn' -S | FileCheck -check-prefix=CHECK-PRE %s
3 ; RUN: opt < %s -passes='require<loops>,gvn,sccp' -S | FileCheck -check-prefix=CHECK-SCCP %s
5 @b = external global i32, align 4
7 define void @main(i1 %cond) {
8 ; CHECK-PRE-LABEL: @main(
9 ; CHECK-PRE-NEXT: entry:
10 ; CHECK-PRE-NEXT: store i32 0, ptr @b, align 4
11 ; CHECK-PRE-NEXT: br label [[WHILE_BODY3:%.*]]
12 ; CHECK-PRE: while.cond.loopexit.loopexit:
13 ; CHECK-PRE-NEXT: ret void
14 ; CHECK-PRE: while.body3:
15 ; CHECK-PRE-NEXT: [[TMP0:%.*]] = phi i32 [ [[TMP1:%.*]], [[IF_END:%.*]] ], [ 0, [[ENTRY:%.*]] ]
16 ; CHECK-PRE-NEXT: [[TOBOOL4_NOT:%.*]] = icmp eq i32 [[TMP0]], 0
17 ; CHECK-PRE-NEXT: br i1 [[TOBOOL4_NOT]], label [[IF_END]], label [[IF_THEN:%.*]]
19 ; CHECK-PRE-NEXT: tail call void @foo()
20 ; CHECK-PRE-NEXT: [[DOTPRE:%.*]] = load i32, ptr @b, align 4
21 ; CHECK-PRE-NEXT: br label [[IF_END]]
23 ; CHECK-PRE-NEXT: [[TMP1]] = phi i32 [ [[DOTPRE]], [[IF_THEN]] ], [ 0, [[WHILE_BODY3]] ]
24 ; CHECK-PRE-NEXT: br i1 [[COND:%.*]], label [[WHILE_COND_LOOPEXIT_LOOPEXIT:%.*]], label [[WHILE_BODY3]]
26 ; CHECK-SCCP-LABEL: @main(
27 ; CHECK-SCCP-NEXT: entry:
28 ; CHECK-SCCP-NEXT: store i32 0, ptr @b, align 4
29 ; CHECK-SCCP-NEXT: br label [[WHILE_BODY3:%.*]]
30 ; CHECK-SCCP: while.cond.loopexit.loopexit:
31 ; CHECK-SCCP-NEXT: ret void
32 ; CHECK-SCCP: while.body3:
33 ; CHECK-SCCP-NEXT: br label [[IF_END:%.*]]
35 ; CHECK-SCCP-NEXT: br i1 [[COND:%.*]], label [[WHILE_COND_LOOPEXIT_LOOPEXIT:%.*]], label [[WHILE_BODY3]]
39 br label %while.body3.lr.ph
41 while.cond.loopexit.loopexit: ; preds = %if.end
44 while.body3.lr.ph: ; preds = %while.cond1.preheader
45 %0 = load i32, ptr @b, align 4
46 %1 = icmp eq i32 %0, 0
49 while.body3: ; preds = %if.end, %while.body3.lr.ph
50 %2 = load i32, ptr @b, align 4
51 %tobool4.not = icmp eq i32 %2, 0
52 br i1 %tobool4.not, label %if.end, label %if.then
54 if.then: ; preds = %while.body3
58 if.end: ; preds = %if.then, %while.body3
59 br i1 %cond, label %while.cond.loopexit.loopexit, label %while.body3