1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt -loop-vectorize -enable-vplan-native-path -S %s | FileCheck %s
3
4declare i1 @cond()
5
6; Make sure we do not vectorize (or crash) on outer loops with uncomputable
7; trip-counts.
8
9define void @test() {
10; CHECK-LABEL: @test(
11; CHECK-NEXT:  entry:
12; CHECK-NEXT:    br label [[FOR1_HEADER:%.*]]
13; CHECK:       for1.header:
14; CHECK-NEXT:    br label [[FOR2_HEADER:%.*]]
15; CHECK:       for2.header:
16; CHECK-NEXT:    [[INDVARS_IV:%.*]] = phi i64 [ 0, [[FOR1_HEADER]] ], [ [[INDVARS_IV_NEXT:%.*]], [[FOR2_HEADER]] ]
17; CHECK-NEXT:    [[INDVARS_IV_NEXT]] = add nuw nsw i64 [[INDVARS_IV]], 1
18; CHECK-NEXT:    [[EXITCOND:%.*]] = icmp eq i64 [[INDVARS_IV_NEXT]], 0
19; CHECK-NEXT:    br i1 [[EXITCOND]], label [[FOR1_LATCH:%.*]], label [[FOR2_HEADER]]
20; CHECK:       for1.latch:
21; CHECK-NEXT:    [[C:%.*]] = call i1 @cond()
22; CHECK-NEXT:    br i1 [[C]], label [[EXIT:%.*]], label [[FOR1_HEADER]], !llvm.loop !0
23; CHECK:       exit:
24; CHECK-NEXT:    ret void
25;
26entry:
27  br label %for1.header
28
29for1.header:                                  ; preds = %for.cond.cleanup3, %for.cond1.preheader.lr.ph
30  br label %for2.header
31
32for2.header:                                       ; preds = %for.body10, %for.body10.preheader
33  %indvars.iv = phi i64 [ 0, %for1.header ], [ %indvars.iv.next, %for2.header ]
34  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
35  %exitcond = icmp eq i64 %indvars.iv.next, 0
36  br i1 %exitcond, label %for1.latch, label %for2.header
37
38for1.latch:                                ; preds = %for.cond.cleanup9
39  %c = call i1 @cond()
40  br i1 %c, label %exit, label %for1.header, !llvm.loop !0
41
42exit:                                 ; preds = %for.cond.cleanup3, %entry
43  ret void
44}
45
46!0 = distinct !{!0, !1}
47!1 = !{!"llvm.loop.vectorize.enable", i1 true}
48