Dehao Chen | c3f87f0 | 2017-01-17 23:39:33 +0000 | [diff] [blame] | 1 | ; 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 |
Teresa Johnson | ecd9013 | 2017-08-02 20:35:29 +0000 | [diff] [blame] | 2 | ; RUN: opt < %s -S -passes='require<opt-remark-emit>,unroll' -unroll-partial-threshold=20 -unroll-threshold=20 -unroll-allow-partial -unroll-runtime -unroll-allow-remainder -unroll-max-percent-threshold-boost=100 | FileCheck %s |
Chandler Carruth | eab3b90 | 2017-01-26 02:13:50 +0000 | [diff] [blame] | 3 | ; |
| 4 | ; Also check that the simple unroller doesn't allow the partial unrolling. |
| 5 | ; RUN: opt < %s -S -passes='require<opt-remark-emit>,loop(unroll-full)' -unroll-partial-threshold=20 -unroll-threshold=20 -unroll-allow-partial -unroll-runtime -unroll-allow-remainder -unroll-max-percent-threshold-boost=100 | FileCheck %s --check-prefix=CHECK-NO-UNROLL |
Zia Ansari | a82a58a4 | 2016-04-04 19:24:46 +0000 | [diff] [blame] | 6 | |
| 7 | ; The Loop TripCount is 9. However unroll factors 3 or 9 exceed given threshold. |
| 8 | ; The test checks that we choose a smaller, power-of-two, unroll count and do not give up on unrolling. |
| 9 | |
| 10 | ; CHECK: for.body: |
| 11 | ; CHECK: store |
| 12 | ; CHECK: for.body.1: |
| 13 | ; CHECK: store |
| 14 | |
Chandler Carruth | eab3b90 | 2017-01-26 02:13:50 +0000 | [diff] [blame] | 15 | ; CHECK-NO-UNROLL: for.body: |
| 16 | ; CHECK-NO-UNROLL: store |
| 17 | ; CHECK-NO-UNROLL-NOT: store |
| 18 | |
Zia Ansari | a82a58a4 | 2016-04-04 19:24:46 +0000 | [diff] [blame] | 19 | define void @foo(i32* nocapture %a, i32* nocapture readonly %b) nounwind uwtable { |
| 20 | entry: |
| 21 | br label %for.body |
| 22 | |
| 23 | for.body: ; preds = %for.body, %entry |
| 24 | %indvars.iv = phi i64 [ 1, %entry ], [ %indvars.iv.next, %for.body ] |
| 25 | %arrayidx = getelementptr inbounds i32, i32* %b, i64 %indvars.iv |
| 26 | %ld = load i32, i32* %arrayidx, align 4 |
| 27 | %idxprom1 = sext i32 %ld to i64 |
| 28 | %arrayidx2 = getelementptr inbounds i32, i32* %a, i64 %idxprom1 |
| 29 | %st = trunc i64 %indvars.iv to i32 |
| 30 | store i32 %st, i32* %arrayidx2, align 4 |
| 31 | %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1 |
Dehao Chen | cc76344 | 2016-12-30 00:50:28 +0000 | [diff] [blame] | 32 | %exitcond = icmp eq i64 %indvars.iv.next, 20 |
Zia Ansari | a82a58a4 | 2016-04-04 19:24:46 +0000 | [diff] [blame] | 33 | br i1 %exitcond, label %for.end, label %for.body |
| 34 | |
| 35 | for.end: ; preds = %for.body |
| 36 | ret void |
| 37 | } |