2 ; RUN: opt < %s -passes='loop-vectorize' -force-vector-width=2 -enable-epilogue-vectorization -epilogue-vectorization-force-VF=2 --debug-only=loop-vectorize -S 2>&1 | FileCheck %s
4 target datalayout = "e-m:e-i64:64-n32:64-v256:256:256-v512:512:512"
6 ; Currently we cannot handle reduction loops.
7 ; CHECK: LV: Checking a loop in "f1"
8 ; CHECK: LEV: Unable to vectorize epilogue because the loop is not a supported candidate.
10 define signext i32 @f1(i8* noalias %A, i32 signext %n) {
12 %cmp1 = icmp sgt i32 %n, 0
13 br i1 %cmp1, label %for.body.preheader, label %for.end
15 for.body.preheader: ; preds = %entry
16 %wide.trip.count = zext i32 %n to i64
19 for.body: ; preds = %for.body.preheader, %for.body
20 %indvars.iv = phi i64 [ 0, %for.body.preheader ], [ %indvars.iv.next, %for.body ]
21 %sum.02 = phi i32 [ %add, %for.body ], [ 0, %for.body.preheader ]
22 %arrayidx = getelementptr inbounds i8, i8* %A, i64 %indvars.iv
23 %0 = load i8, i8* %arrayidx, align 1
24 %conv = zext i8 %0 to i32
25 %add = add nuw nsw i32 %sum.02, %conv
26 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
27 %exitcond = icmp ne i64 %indvars.iv.next, %wide.trip.count
28 br i1 %exitcond, label %for.body, label %for.end.loopexit
30 for.end.loopexit: ; preds = %for.body
31 %add.lcssa = phi i32 [ %add, %for.body ]
34 for.end: ; preds = %for.end.loopexit, %entry
35 %sum.0.lcssa = phi i32 [ 0, %entry ], [ %add.lcssa, %for.end.loopexit ]
39 ; Currently we cannot handle live-out variables that are recurrences.
40 ; CHECK: LV: Checking a loop in "f2"
41 ; CHECK: LEV: Unable to vectorize epilogue because the loop is not a supported candidate.
43 define signext i32 @f2(i8* noalias %A, i32 signext %n) {
45 %cmp1 = icmp sgt i32 %n, 0
46 br i1 %cmp1, label %for.body.preheader, label %for.end
48 for.body.preheader: ; preds = %entry
49 %wide.trip.count = zext i32 %n to i64
52 for.body: ; preds = %for.body.preheader, %for.body
53 %indvars.iv = phi i64 [ 0, %for.body.preheader ], [ %indvars.iv.next, %for.body ]
54 %arrayidx = getelementptr inbounds i8, i8* %A, i64 %indvars.iv
55 %0 = load i8, i8* %arrayidx, align 1
57 %arrayidx3 = getelementptr inbounds i8, i8* %A, i64 %indvars.iv
58 store i8 %add, i8* %arrayidx3, align 1
59 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
60 %exitcond = icmp ne i64 %indvars.iv.next, %wide.trip.count
61 br i1 %exitcond, label %for.body, label %for.end.loopexit
63 for.end.loopexit: ; preds = %for.body
64 %inc.lcssa.wide = phi i64 [ %indvars.iv.next, %for.body ]
65 %1 = trunc i64 %inc.lcssa.wide to i32
68 for.end: ; preds = %for.end.loopexit, %entry
69 %i.0.lcssa = phi i32 [ 0, %entry ], [ %1, %for.end.loopexit ]
73 ; Currently we cannot handle widended/truncated inductions.
74 ; CHECK: LV: Checking a loop in "f3"
75 ; CHECK: LEV: Unable to vectorize epilogue because the loop is not a supported candidate.
77 define void @f3(i8* noalias %A, i32 signext %n) {
79 %cmp1 = icmp sgt i32 %n, 0
80 br i1 %cmp1, label %for.body.preheader, label %for.end
82 for.body.preheader: ; preds = %entry
83 %wide.trip.count = zext i32 %n to i64
86 for.body: ; preds = %for.body.preheader, %for.body
87 %indvars.iv = phi i64 [ 0, %for.body.preheader ], [ %indvars.iv.next, %for.body ]
88 %0 = trunc i64 %indvars.iv to i32
89 %conv = trunc i32 %0 to i8
90 %arrayidx = getelementptr inbounds i8, i8* %A, i64 %indvars.iv
91 store i8 %conv, i8* %arrayidx, align 1
92 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
93 %exitcond = icmp ne i64 %indvars.iv.next, %wide.trip.count
94 br i1 %exitcond, label %for.body, label %for.end.loopexit
96 for.end.loopexit: ; preds = %for.body
99 for.end: ; preds = %for.end.loopexit, %entry