1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2
2 ; RUN: opt -passes=indvars -S %s | FileCheck --check-prefix=COMMON %s
3 ; RUN: opt -passes=indvars -scev-range-iter-threshold=1 -S %s | FileCheck --check-prefix=COMMON %s
5 target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
7 define i32 @test(i1 %c.0, i32 %m) {
8 ; COMMON-LABEL: define i32 @test
9 ; COMMON-SAME: (i1 [[C_0:%.*]], i32 [[M:%.*]]) {
11 ; COMMON-NEXT: br label [[OUTER_HEADER:%.*]]
12 ; COMMON: outer.header:
13 ; COMMON-NEXT: [[IV_1:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[IV_1_NEXT:%.*]], [[OUTER_LATCH:%.*]] ]
14 ; COMMON-NEXT: [[MAX_0:%.*]] = phi i32 [ 0, [[ENTRY]] ], [ [[MAX_1:%.*]], [[OUTER_LATCH]] ]
15 ; COMMON-NEXT: [[TMP0:%.*]] = sext i32 [[IV_1]] to i64
16 ; COMMON-NEXT: br label [[INNER_1:%.*]]
18 ; COMMON-NEXT: [[C_1:%.*]] = icmp slt i64 0, [[TMP0]]
19 ; COMMON-NEXT: br i1 [[C_1]], label [[INNER_1]], label [[INNER_2_HEADER_PREHEADER:%.*]]
20 ; COMMON: inner.2.header.preheader:
21 ; COMMON-NEXT: br label [[INNER_2_HEADER:%.*]]
22 ; COMMON: inner.2.header:
23 ; COMMON-NEXT: [[IV_3:%.*]] = phi i32 [ [[IV_3_NEXT:%.*]], [[INNER_2_LATCH:%.*]] ], [ 0, [[INNER_2_HEADER_PREHEADER]] ]
24 ; COMMON-NEXT: br i1 [[C_0]], label [[OUTER_LATCH]], label [[INNER_2_LATCH]]
25 ; COMMON: inner.2.latch:
26 ; COMMON-NEXT: [[IV_3_NEXT]] = add i32 [[IV_3]], 1
27 ; COMMON-NEXT: [[C_2:%.*]] = icmp ugt i32 [[IV_3]], [[IV_1]]
28 ; COMMON-NEXT: br i1 [[C_2]], label [[OUTER_LATCH]], label [[INNER_2_HEADER]]
29 ; COMMON: outer.latch:
30 ; COMMON-NEXT: [[MAX_1]] = phi i32 [ [[M]], [[INNER_2_LATCH]] ], [ 0, [[INNER_2_HEADER]] ]
31 ; COMMON-NEXT: [[IV_1_NEXT]] = add i32 [[IV_1]], 1
32 ; COMMON-NEXT: [[C_3:%.*]] = icmp ugt i32 [[IV_1]], [[MAX_0]]
33 ; COMMON-NEXT: br i1 [[C_3]], label [[EXIT:%.*]], label [[OUTER_HEADER]], !llvm.loop [[LOOP0:![0-9]+]]
35 ; COMMON-NEXT: ret i32 0
38 br label %outer.header
41 %iv.1 = phi i32 [ 0, %entry ], [ %iv.1.next, %outer.latch ]
42 %iv.2 = phi i32 [ 0, %entry ], [ %iv.2.next , %outer.latch ]
43 %max.0 = phi i32 [ 0, %entry ], [ %max.1, %outer.latch ]
44 %0 = sext i32 %iv.1 to i64
48 %c.1 = icmp slt i64 0, %0
49 br i1 %c.1, label %inner.1, label %inner.2.header
52 %iv.3 = phi i32 [ 0, %inner.1 ], [ %iv.3.next, %inner.2.latch ]
53 br i1 %c.0, label %outer.latch, label %inner.2.latch
56 %iv.3.next = add i32 %iv.3, 1
57 %c.2 = icmp ugt i32 %iv.3, %iv.2
58 br i1 %c.2, label %outer.latch, label %inner.2.header
61 %max.1 = phi i32 [ %m, %inner.2.latch ], [ %iv.3, %inner.2.header ]
62 %iv.1.next = add i32 %iv.1, 1
63 %iv.2.next = add i32 %iv.2, 1
64 %c.3 = icmp ugt i32 %iv.2, %max.0
65 br i1 %c.3, label %exit, label %outer.header, !llvm.loop !0
71 !0 = distinct !{!0, !1}
72 !1 = !{!"llvm.loop.mustprogress"}