1 ; RUN: opt -S -loop-unroll -unroll-runtime %s -o - | FileCheck %s
2 ; RUN: opt -S -loop-unroll -unroll-runtime -unroll-max-upperbound=6 %s -o - | FileCheck %s --check-prefix=UPPER
4 target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
6 @global = dso_local local_unnamed_addr global i32 0, align 4
7 @global.1 = dso_local local_unnamed_addr global i8* null, align 4
9 ; Check that loop in hoge_3, with a runtime upperbound of 3, is not unrolled.
14 ; CHECK: br i1 %{{.*}}, label %loop
19 ; UPPER: br i1 %{{.*}}, label %loop
20 define dso_local void @hoge_3(i8 %arg) {
22 %x = load i32, i32* @global, align 4
23 %y = load i8*, i8** @global.1, align 4
24 %0 = icmp ult i32 %x, 17
25 br i1 %0, label %loop, label %exit
28 %iv = phi i32 [ %x, %entry ], [ %iv.next, %loop ]
29 %ptr = phi i8* [ %y, %entry ], [ %ptr.next, %loop ]
30 %iv.next = add nuw i32 %iv, 8
31 %ptr.next = getelementptr inbounds i8, i8* %ptr, i32 1
32 store i8 %arg, i8* %ptr.next, align 1
33 %1 = icmp ult i32 %iv.next, 17
34 br i1 %1, label %loop, label %exit
40 ; Check that loop in hoge_5, with a runtime upperbound of 5, is unrolled when -unroll-max-upperbound=4
45 ; CHECK: br i1 %{{.*}}, label %loop
51 ; UPPER: br i1 %{{.*}}, label %loop
52 define dso_local void @hoge_5(i8 %arg) {
54 %x = load i32, i32* @global, align 4
55 %y = load i8*, i8** @global.1, align 4
56 %0 = icmp ult i32 %x, 17
57 br i1 %0, label %loop, label %exit
60 %iv = phi i32 [ %x, %entry ], [ %iv.next, %loop ]
61 %ptr = phi i8* [ %y, %entry ], [ %ptr.next, %loop ]
62 %iv.next = add nuw i32 %iv, 4
63 %ptr.next = getelementptr inbounds i8, i8* %ptr, i32 1
64 store i8 %arg, i8* %ptr.next, align 1
65 %1 = icmp ult i32 %iv.next, 17
66 br i1 %1, label %loop, label %exit