1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -indvars -loop-deletion -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -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: [[TMP0:%.*]] = add i32 [[ARG]], -11
32 ; CHECK-NEXT: [[TMP1:%.*]] = lshr i32 [[TMP0]], 1
33 ; CHECK-NEXT: [[TMP2:%.*]] = add nuw i32 [[TMP1]], 1
34 ; CHECK-NEXT: [[TMP8:%.*]] = select i1 [[TMP]], i32 [[TMP2]], i32 0
35 ; CHECK-NEXT: ret i32 [[TMP8]]
38 %tmp = icmp ugt i32 %arg, 10
39 br i1 %tmp, label %bb1, label %bb7
41 bb1: ; preds = %bb1, %bb
42 %tmp2 = phi i32 [ %tmp5, %bb1 ], [ 0, %bb ]
43 %tmp3 = phi i32 [ %tmp4, %bb1 ], [ %arg, %bb ]
44 %tmp4 = add i32 %tmp3, -2
45 %tmp5 = add i32 %tmp2, 1
46 %tmp6 = icmp ugt i32 %tmp4, 10
47 br i1 %tmp6, label %bb1, label %bb7
49 bb7: ; preds = %bb1, %bb
50 %tmp8 = phi i32 [ 0, %bb ], [ %tmp5, %bb1 ]