1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=loop-unroll -unroll-allow-partial -S %s -verify-loop-info -verify-dom-info -verify-loop-lcssa | FileCheck %s
4 @table = internal unnamed_addr global [344 x i32] zeroinitializer, align 16
6 define i32 @test_partial_unroll_with_breakout_at_iter0() {
9 ; CHECK-LABEL: @test_partial_unroll_with_breakout_at_iter0(
11 ; CHECK-NEXT: br label [[FOR_HEADER:%.*]]
13 ; CHECK-NEXT: [[RED:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[RED_NEXT_3:%.*]], [[FOR_LATCH_3:%.*]] ]
14 ; CHECK-NEXT: [[IV:%.*]] = phi i64 [ 0, [[ENTRY]] ], [ [[IV_NEXT_3:%.*]], [[FOR_LATCH_3]] ]
15 ; CHECK-NEXT: [[RED_NEXT:%.*]] = add nuw nsw i32 10, [[RED]]
16 ; CHECK-NEXT: [[IV_NEXT:%.*]] = add nuw nsw i64 [[IV]], 2
17 ; CHECK-NEXT: [[PTR:%.*]] = getelementptr inbounds [344 x i32], ptr @table, i64 0, i64 [[IV_NEXT]]
18 ; CHECK-NEXT: store i32 [[RED_NEXT]], ptr [[PTR]], align 4
19 ; CHECK-NEXT: br label [[FOR_LATCH:%.*]]
21 ; CHECK-NEXT: [[RED_NEXT_1:%.*]] = add nuw nsw i32 10, [[RED_NEXT]]
22 ; CHECK-NEXT: [[IV_NEXT_1:%.*]] = add nuw nsw i64 [[IV]], 4
23 ; CHECK-NEXT: [[PTR_1:%.*]] = getelementptr inbounds [344 x i32], ptr @table, i64 0, i64 [[IV_NEXT_1]]
24 ; CHECK-NEXT: store i32 [[RED_NEXT_1]], ptr [[PTR_1]], align 4
25 ; CHECK-NEXT: br label [[FOR_LATCH_1:%.*]]
27 ; CHECK-NEXT: [[RED_NEXT_2:%.*]] = add nuw nsw i32 10, [[RED_NEXT_1]]
28 ; CHECK-NEXT: [[IV_NEXT_2:%.*]] = add nuw nsw i64 [[IV]], 6
29 ; CHECK-NEXT: [[PTR_2:%.*]] = getelementptr inbounds [344 x i32], ptr @table, i64 0, i64 [[IV_NEXT_2]]
30 ; CHECK-NEXT: store i32 [[RED_NEXT_2]], ptr [[PTR_2]], align 4
31 ; CHECK-NEXT: br label [[FOR_LATCH_2:%.*]]
33 ; CHECK-NEXT: [[RED_NEXT_3]] = add nuw nsw i32 10, [[RED_NEXT_2]]
34 ; CHECK-NEXT: [[IV_NEXT_3]] = add nuw nsw i64 [[IV]], 8
35 ; CHECK-NEXT: [[PTR_3:%.*]] = getelementptr inbounds [344 x i32], ptr @table, i64 0, i64 [[IV_NEXT_3]]
36 ; CHECK-NEXT: store i32 [[RED_NEXT_3]], ptr [[PTR_3]], align 4
37 ; CHECK-NEXT: [[EXITCOND_1_I_3:%.*]] = icmp eq i64 [[IV_NEXT_3]], 344
38 ; CHECK-NEXT: br i1 [[EXITCOND_1_I_3]], label [[EXIT:%.*]], label [[FOR_LATCH_3]]
40 ; CHECK-NEXT: br label [[FOR_HEADER]]
42 ; CHECK-NEXT: ret i32 0
47 for.header: ; preds = %for.body28.i.for.body28.i_crit_edge, %for.body.i
48 %red = phi i32 [ 0, %entry ], [ %red.next, %for.latch ]
49 %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.latch ]
50 %red.next = add i32 10, %red
51 %iv.next = add nuw nsw i64 %iv, 2
52 %ptr = getelementptr inbounds [344 x i32], ptr @table, i64 0, i64 %iv.next
53 store i32 %red.next, ptr %ptr, align 4
54 %exitcond.1.i = icmp eq i64 %iv.next, 344
55 br i1 %exitcond.1.i, label %exit, label %for.latch
57 for.latch: ; preds = %for.header