1; RUN: opt -S -unroll-runtime -loop-unroll < %s | FileCheck %s
2
3target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
4
5;; Check that we don't emit expensive instructions to compute trip
6;; counts when unrolling loops.
7
8define i32 @test(i64 %v12, i8* %array, i64* %loc) {
9; CHECK-LABEL: @test(
10; CHECK-NOT: udiv
11entry:
12  %step = load i64, i64* %loc, !range !0
13  br label %loop
14
15loop:                                           ; preds = %entry, %loop
16  %k.015 = phi i64 [ %v15, %loop ], [ %v12, %entry ]
17  %v14 = getelementptr inbounds i8, i8* %array, i64 %k.015
18  store i8 0, i8* %v14
19  %v15 = add nuw nsw i64 %k.015, %step
20  %v16 = icmp slt i64 %v15, 8193
21  br i1 %v16, label %loop, label %loopexit
22
23loopexit:                             ; preds = %loop
24  ret i32 0
25}
26
27!0 = !{i64 1, i64 100}
28