1 ; Check that we won't interleave by more than half the "best known" estimated trip count.
4 ; The loop is expected to be vectorized by 4 and computed interleaving factor is 1.
5 ; Thus the resulting step is 4.
6 ; RUN: opt -passes=loop-vectorize -force-vector-width=4 -vectorizer-min-trip-count=4 -S < %s | FileCheck %s
8 ; The loop is expected to be vectorized by 2 and computed interleaving factor is 2.
9 ; Thus the resulting step is 4.
10 ; RUN: opt -passes=loop-vectorize -force-vector-width=2 -vectorizer-min-trip-count=4 -S < %s | FileCheck %s
12 ; Check that we won't interleave by more than "best known" estimated trip count.
14 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
15 target triple = "x86_64-unknown-linux-gnu"
17 @a = dso_local global [5 x i32] zeroinitializer, align 16
18 @b = dso_local global [5 x i32] zeroinitializer, align 16
20 ; Function Attrs: nofree norecurse nounwind uwtable
21 define dso_local void @_Z3fooi(i32 %M) local_unnamed_addr {
22 ; CHECK-LABEL: @_Z3fooi(
23 ; CHECK: [[VECTOR_BODY:vector\.body]]:
24 ; CHECK: [[INDEX:%.*]] = phi i64 [ 0, [[VECTOR_PH:%.*]] ], [ [[INDEX_NEXT:%.*]], %[[VECTOR_BODY]] ]
25 ; CHECK: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 4
28 %cmp8 = icmp sgt i32 %M, 0
29 br i1 %cmp8, label %for.body.preheader, label %for.cond.cleanup
31 for.body.preheader: ; preds = %entry
32 %wide.trip.count = zext i32 %M to i64
35 for.cond.cleanup.loopexit: ; preds = %for.body
36 br label %for.cond.cleanup
38 for.cond.cleanup: ; preds = %for.cond.cleanup.loopexit, %entry
41 for.body: ; preds = %for.body, %for.body.preheader
42 %indvars.iv = phi i64 [ 0, %for.body.preheader ], [ %indvars.iv.next, %for.body ]
43 %arrayidx = getelementptr inbounds [5 x i32], ptr @b, i64 0, i64 %indvars.iv
44 %0 = load i32, ptr %arrayidx, align 4
45 %1 = trunc i64 %indvars.iv to i32
46 %mul = mul nsw i32 %0, %1
47 %arrayidx2 = getelementptr inbounds [5 x i32], ptr @a, i64 0, i64 %indvars.iv
48 %2 = load i32, ptr %arrayidx2, align 4
49 %add = add nsw i32 %2, %mul
50 store i32 %add, ptr %arrayidx2, align 4
51 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
52 %exitcond = icmp eq i64 %indvars.iv.next, %wide.trip.count
53 br i1 %exitcond, label %for.cond.cleanup.loopexit, label %for.body, !prof !1
56 !1 = !{!"branch_weights", i32 1, i32 9}