1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes="loop(indvars),loop-vectorize" -S %s | FileCheck %s
4 target triple = "x86_64-unknown-linux-gnu"
6 ; After indvars, the backedge taken count for %loop2 becomes 1, but SCEV
7 ; retains the cached original BTC, as the loop is in dead code. Make sure
8 ; LV does not crash when trying to select an interleave count for a loop with zero cost.
9 define void @pr54413(ptr %ptr.base) {
10 ; CHECK-LABEL: @pr54413(
12 ; CHECK-NEXT: br label [[LOOP1:%.*]]
14 ; CHECK-NEXT: br i1 true, label [[LOOP1_LATCH:%.*]], label [[LOOP2_PREHEADER:%.*]]
15 ; CHECK: loop2.preheader:
16 ; CHECK-NEXT: br label [[LOOP2:%.*]]
18 ; CHECK-NEXT: [[PTR_NEXT:%.*]] = getelementptr inbounds i64, ptr [[PTR_BASE:%.*]], i64 1
19 ; CHECK-NEXT: br i1 true, label [[LOOP2_EXIT:%.*]], label [[LOOP2]]
21 ; CHECK-NEXT: [[PTR_NEXT_LCSSA:%.*]] = phi ptr [ [[PTR_NEXT]], [[LOOP2]] ]
22 ; CHECK-NEXT: br label [[LOOP1_LATCH]]
24 ; CHECK-NEXT: br label [[LOOP1]]
30 br i1 true, label %loop1.latch, label %loop2.preheader
36 %iv = phi i64 [ 0, %loop2.preheader ], [ %iv.next, %loop2 ]
37 %ptr = phi ptr [ %ptr.base, %loop2.preheader ], [ %ptr.next, %loop2 ]
38 %iv.next = add nuw nsw i64 %iv, 1
39 %ptr.next = getelementptr inbounds i64, ptr %ptr, i64 1
40 %cmp = icmp eq i64 %iv, 1024
41 br i1 %cmp, label %loop2.exit, label %loop2
44 %ptr.next.lcssa = phi ptr [ %ptr.next, %loop2 ]