| ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py |
| ; RUN: opt < %s -loops -gvn -S | FileCheck -check-prefix=CHECK-PRE %s |
| ; RUN: opt < %s -loops -gvn -sccp -S | FileCheck -check-prefix=CHECK-SCCP %s |
| |
| @b = external global i32, align 4 |
| |
| define void @main(i1 %cond) { |
| ; CHECK-PRE-LABEL: @main( |
| ; CHECK-PRE-NEXT: entry: |
| ; CHECK-PRE-NEXT: store i32 0, i32* @b, align 4 |
| ; CHECK-PRE-NEXT: br label [[WHILE_BODY3:%.*]] |
| ; CHECK-PRE: while.cond.loopexit.loopexit: |
| ; CHECK-PRE-NEXT: ret void |
| ; CHECK-PRE: while.body3: |
| ; CHECK-PRE-NEXT: [[TMP0:%.*]] = phi i32 [ [[TMP1:%.*]], [[IF_END:%.*]] ], [ 0, [[ENTRY:%.*]] ] |
| ; CHECK-PRE-NEXT: [[TOBOOL4_NOT:%.*]] = icmp eq i32 [[TMP0]], 0 |
| ; CHECK-PRE-NEXT: br i1 [[TOBOOL4_NOT]], label [[IF_END]], label [[IF_THEN:%.*]] |
| ; CHECK-PRE: if.then: |
| ; CHECK-PRE-NEXT: tail call void @foo() |
| ; CHECK-PRE-NEXT: [[DOTPRE:%.*]] = load i32, i32* @b, align 4 |
| ; CHECK-PRE-NEXT: br label [[IF_END]] |
| ; CHECK-PRE: if.end: |
| ; CHECK-PRE-NEXT: [[TMP1]] = phi i32 [ [[DOTPRE]], [[IF_THEN]] ], [ 0, [[WHILE_BODY3]] ] |
| ; CHECK-PRE-NEXT: br i1 [[COND:%.*]], label [[WHILE_COND_LOOPEXIT_LOOPEXIT:%.*]], label [[WHILE_BODY3]] |
| ; |
| ; CHECK-SCCP-LABEL: @main( |
| ; CHECK-SCCP-NEXT: entry: |
| ; CHECK-SCCP-NEXT: store i32 0, i32* @b, align 4 |
| ; CHECK-SCCP-NEXT: br label [[WHILE_BODY3:%.*]] |
| ; CHECK-SCCP: while.cond.loopexit.loopexit: |
| ; CHECK-SCCP-NEXT: ret void |
| ; CHECK-SCCP: while.body3: |
| ; CHECK-SCCP-NEXT: br i1 true, label [[IF_END:%.*]], label [[IF_THEN:%.*]] |
| ; CHECK-SCCP: if.then: |
| ; CHECK-SCCP-NEXT: br label [[IF_END]] |
| ; CHECK-SCCP: if.end: |
| ; CHECK-SCCP-NEXT: br i1 [[COND:%.*]], label [[WHILE_COND_LOOPEXIT_LOOPEXIT:%.*]], label [[WHILE_BODY3]] |
| ; |
| entry: |
| store i32 0, i32* @b |
| br label %while.body3.lr.ph |
| |
| while.cond.loopexit.loopexit: ; preds = %if.end |
| ret void |
| |
| while.body3.lr.ph: ; preds = %while.cond1.preheader |
| %0 = load i32, i32* @b, align 4 |
| %1 = icmp eq i32 %0, 0 |
| br label %while.body3 |
| |
| while.body3: ; preds = %if.end, %while.body3.lr.ph |
| %2 = load i32, i32* @b, align 4 |
| %tobool4.not = icmp eq i32 %2, 0 |
| br i1 %tobool4.not, label %if.end, label %if.then |
| |
| if.then: ; preds = %while.body3 |
| tail call void @foo() |
| br label %if.end |
| |
| if.end: ; preds = %if.then, %while.body3 |
| br i1 %cond, label %while.cond.loopexit.loopexit, label %while.body3 |
| } |
| |
| declare void @foo() |
| |