Wei Mi | edae87d | 2015-08-25 16:43:47 +0000 | [diff] [blame] | 1 | ; RUN: opt %s -loop-vectorize -force-vector-interleave=1 -force-vector-width=4 -S | FileCheck %s |
| 2 | ; RUN: opt %s -loop-vectorize -force-vector-interleave=2 -force-vector-width=4 -S | FileCheck %s -check-prefix=UNROLL |
| 3 | |
| 4 | target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" |
Wei Mi | edae87d | 2015-08-25 16:43:47 +0000 | [diff] [blame] | 5 | |
| 6 | @b = common global [1000 x i32] zeroinitializer, align 16 |
| 7 | @c = common global [1000 x i32] zeroinitializer, align 16 |
| 8 | @a = common global [1000 x i32] zeroinitializer, align 16 |
| 9 | |
| 10 | ; Generate min.iters.check to skip the vector loop and jump to scalar.ph directly when loop iteration number is less than VF * UF. |
| 11 | ; CHECK-LABEL: foo( |
| 12 | ; CHECK: %min.iters.check = icmp ult i64 %N, 4 |
| 13 | ; CHECK: br i1 %min.iters.check, label %scalar.ph, label %min.iters.checked |
| 14 | ; UNROLL-LABEL: foo( |
| 15 | ; UNROLL: %min.iters.check = icmp ult i64 %N, 8 |
| 16 | ; UNROLL: br i1 %min.iters.check, label %scalar.ph, label %min.iters.checked |
| 17 | |
| 18 | define void @foo(i64 %N) { |
| 19 | entry: |
| 20 | %cmp.8 = icmp sgt i64 %N, 0 |
| 21 | br i1 %cmp.8, label %for.body.preheader, label %for.end |
| 22 | |
| 23 | for.body.preheader: ; preds = %entry |
| 24 | br label %for.body |
| 25 | |
| 26 | for.body: ; preds = %for.body, %for.body.preheader |
| 27 | %i.09 = phi i64 [ %inc, %for.body ], [ 0, %for.body.preheader ] |
| 28 | %arrayidx = getelementptr inbounds [1000 x i32], [1000 x i32]* @b, i64 0, i64 %i.09 |
| 29 | %tmp = load i32, i32* %arrayidx, align 4 |
| 30 | %arrayidx1 = getelementptr inbounds [1000 x i32], [1000 x i32]* @c, i64 0, i64 %i.09 |
| 31 | %tmp1 = load i32, i32* %arrayidx1, align 4 |
| 32 | %add = add nsw i32 %tmp1, %tmp |
| 33 | %arrayidx2 = getelementptr inbounds [1000 x i32], [1000 x i32]* @a, i64 0, i64 %i.09 |
| 34 | store i32 %add, i32* %arrayidx2, align 4 |
| 35 | %inc = add nuw nsw i64 %i.09, 1 |
| 36 | %exitcond = icmp eq i64 %inc, %N |
| 37 | br i1 %exitcond, label %for.end.loopexit, label %for.body |
| 38 | |
| 39 | for.end.loopexit: ; preds = %for.body |
| 40 | br label %for.end |
| 41 | |
| 42 | for.end: ; preds = %for.end.loopexit, %entry |
| 43 | ret void |
| 44 | } |