1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -indvars -loop-deletion -simplifycfg -S | FileCheck %s
4 ; Testcase distilled from 256.bzip2
8 ; CHECK-NEXT: ret i32 364
13 loopentry: ; preds = %loopentry, %entry
14 %indvar1 = phi i32 [ 0, %entry ], [ %indvar.next2, %loopentry ] ; <i32> [#uses=1]
15 %h.0 = phi i32 [ %tmp.2, %loopentry ], [ 4, %entry ] ; <i32> [#uses=1]
16 %tmp.1 = mul i32 %h.0, 3 ; <i32> [#uses=1]
17 %tmp.2 = add i32 %tmp.1, 1 ; <i32> [#uses=2]
18 %indvar.next2 = add i32 %indvar1, 1 ; <i32> [#uses=2]
19 %exitcond3 = icmp ne i32 %indvar.next2, 4 ; <i1> [#uses=1]
20 br i1 %exitcond3, label %loopentry, label %loopexit
22 loopexit: ; preds = %loopentry
27 define i32 @test2(i32 %arg) {
28 ; CHECK-LABEL: @test2(
30 ; CHECK-NEXT: [[TMP:%.*]] = icmp ugt i32 [[ARG:%.*]], 10
31 ; CHECK-NEXT: br i1 [[TMP]], label [[BB1_PREHEADER:%.*]], label [[BB7:%.*]]
32 ; CHECK: bb1.preheader:
33 ; CHECK-NEXT: [[TMP0:%.*]] = add i32 [[ARG]], -11
34 ; CHECK-NEXT: [[TMP1:%.*]] = lshr i32 [[TMP0]], 1
35 ; CHECK-NEXT: [[TMP2:%.*]] = add nuw i32 [[TMP1]], 1
36 ; CHECK-NEXT: br label [[BB7]]
38 ; CHECK-NEXT: [[TMP8:%.*]] = phi i32 [ 0, [[BB:%.*]] ], [ [[TMP2]], [[BB1_PREHEADER]] ]
39 ; CHECK-NEXT: ret i32 [[TMP8]]
42 %tmp = icmp ugt i32 %arg, 10
43 br i1 %tmp, label %bb1, label %bb7
45 bb1: ; preds = %bb1, %bb
46 %tmp2 = phi i32 [ %tmp5, %bb1 ], [ 0, %bb ]
47 %tmp3 = phi i32 [ %tmp4, %bb1 ], [ %arg, %bb ]
48 %tmp4 = add i32 %tmp3, -2
49 %tmp5 = add i32 %tmp2, 1
50 %tmp6 = icmp ugt i32 %tmp4, 10
51 br i1 %tmp6, label %bb1, label %bb7
53 bb7: ; preds = %bb1, %bb
54 %tmp8 = phi i32 [ 0, %bb ], [ %tmp5, %bb1 ]