blob: 62124ce3876268495acb147606dedeac0271be89 [file] [log] [blame]
Dehao Chenc3f87f02017-01-17 23:39:33 +00001; RUN: opt < %s -S -unroll-partial-threshold=20 -unroll-threshold=20 -loop-unroll -unroll-allow-partial -unroll-runtime -unroll-allow-remainder -unroll-max-percent-threshold-boost=100 | FileCheck %s
Zia Ansaria82a58a42016-04-04 19:24:46 +00002
3; The Loop TripCount is 9. However unroll factors 3 or 9 exceed given threshold.
4; The test checks that we choose a smaller, power-of-two, unroll count and do not give up on unrolling.
5
6; CHECK: for.body:
7; CHECK: store
8; CHECK: for.body.1:
9; CHECK: store
10
11define void @foo(i32* nocapture %a, i32* nocapture readonly %b) nounwind uwtable {
12entry:
13 br label %for.body
14
15for.body: ; preds = %for.body, %entry
16 %indvars.iv = phi i64 [ 1, %entry ], [ %indvars.iv.next, %for.body ]
17 %arrayidx = getelementptr inbounds i32, i32* %b, i64 %indvars.iv
18 %ld = load i32, i32* %arrayidx, align 4
19 %idxprom1 = sext i32 %ld to i64
20 %arrayidx2 = getelementptr inbounds i32, i32* %a, i64 %idxprom1
21 %st = trunc i64 %indvars.iv to i32
22 store i32 %st, i32* %arrayidx2, align 4
23 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
Dehao Chencc763442016-12-30 00:50:28 +000024 %exitcond = icmp eq i64 %indvars.iv.next, 20
Zia Ansaria82a58a42016-04-04 19:24:46 +000025 br i1 %exitcond, label %for.end, label %for.body
26
27for.end: ; preds = %for.body
28 ret void
29}