Home | History | Annotate | Download | only in LoopVectorize
      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"
      5 target triple = "x86_64-unknown-linux-gnu"
      6 
      7 @b = common global [1000 x i32] zeroinitializer, align 16
      8 @c = common global [1000 x i32] zeroinitializer, align 16
      9 @a = common global [1000 x i32] zeroinitializer, align 16
     10 
     11 ; Generate min.iters.check to skip the vector loop and jump to scalar.ph directly when loop iteration number is less than VF * UF.
     12 ; CHECK-LABEL: foo(
     13 ; CHECK: %min.iters.check = icmp ult i64 %N, 4
     14 ; CHECK: br i1 %min.iters.check, label %scalar.ph, label %min.iters.checked
     15 ; UNROLL-LABEL: foo(
     16 ; UNROLL: %min.iters.check = icmp ult i64 %N, 8
     17 ; UNROLL: br i1 %min.iters.check, label %scalar.ph, label %min.iters.checked
     18 
     19 define void @foo(i64 %N) {
     20 entry:
     21   %cmp.8 = icmp sgt i64 %N, 0
     22   br i1 %cmp.8, label %for.body.preheader, label %for.end
     23 
     24 for.body.preheader:                               ; preds = %entry
     25   br label %for.body
     26 
     27 for.body:                                         ; preds = %for.body, %for.body.preheader
     28   %i.09 = phi i64 [ %inc, %for.body ], [ 0, %for.body.preheader ]
     29   %arrayidx = getelementptr inbounds [1000 x i32], [1000 x i32]* @b, i64 0, i64 %i.09
     30   %tmp = load i32, i32* %arrayidx, align 4
     31   %arrayidx1 = getelementptr inbounds [1000 x i32], [1000 x i32]* @c, i64 0, i64 %i.09
     32   %tmp1 = load i32, i32* %arrayidx1, align 4
     33   %add = add nsw i32 %tmp1, %tmp
     34   %arrayidx2 = getelementptr inbounds [1000 x i32], [1000 x i32]* @a, i64 0, i64 %i.09
     35   store i32 %add, i32* %arrayidx2, align 4
     36   %inc = add nuw nsw i64 %i.09, 1
     37   %exitcond = icmp eq i64 %inc, %N
     38   br i1 %exitcond, label %for.end.loopexit, label %for.body
     39 
     40 for.end.loopexit:                                 ; preds = %for.body
     41   br label %for.end
     42 
     43 for.end:                                          ; preds = %for.end.loopexit, %entry
     44   ret void
     45 }
     46