2 ; RUN: opt -loop-vectorize -S -mcpu=core-avx2 --debug-only=loop-vectorize -vectorizer-maximize-bandwidth < %s 2>&1 | FileCheck %s
4 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
5 target triple = "x86_64-unknown-linux-gnu"
7 ; Function Attrs: norecurse nounwind readonly uwtable
8 define i32 @doit_stride3(i8* nocapture readonly %Ptr, i32 %Nels) {
9 ;CHECK: LV: Found an estimated cost of 1 for VF 1 For instruction: %0 = load i8
10 ;CHECK: LV: Found an estimated cost of 11 for VF 2 For instruction: %0 = load i8
11 ;CHECK: LV: Found an estimated cost of 5 for VF 4 For instruction: %0 = load i8
12 ;CHECK: LV: Found an estimated cost of 10 for VF 8 For instruction: %0 = load i8
13 ;CHECK: LV: Found an estimated cost of 13 for VF 16 For instruction: %0 = load i8
14 ;CHECK: LV: Found an estimated cost of 16 for VF 32 For instruction: %0 = load i8
16 %cmp13 = icmp sgt i32 %Nels, 0
17 br i1 %cmp13, label %for.body.preheader, label %for.end
23 %Ptr.addr.016 = phi i8* [ %incdec.ptr2, %for.body ], [ %Ptr, %for.body.preheader ]
24 %i.015 = phi i32 [ %inc, %for.body ], [ 0, %for.body.preheader ]
25 %s.014 = phi i32 [ %add6, %for.body ], [ 0, %for.body.preheader ]
26 %incdec.ptr = getelementptr inbounds i8, i8* %Ptr.addr.016, i64 1
27 %0 = load i8, i8* %Ptr.addr.016, align 1
28 %incdec.ptr1 = getelementptr inbounds i8, i8* %Ptr.addr.016, i64 2
29 %1 = load i8, i8* %incdec.ptr, align 1
30 %incdec.ptr2 = getelementptr inbounds i8, i8* %Ptr.addr.016, i64 3
31 %2 = load i8, i8* %incdec.ptr1, align 1
32 %conv = zext i8 %0 to i32
33 %conv3 = zext i8 %1 to i32
34 %conv4 = zext i8 %2 to i32
35 %add = add i32 %s.014, %conv
36 %add5 = add i32 %add, %conv3
37 %add6 = add i32 %add5, %conv4
38 %inc = add nuw nsw i32 %i.015, 1
39 %exitcond = icmp eq i32 %inc, %Nels
40 br i1 %exitcond, label %for.end.loopexit, label %for.body
43 %add6.lcssa = phi i32 [ %add6, %for.body ]
47 %s.0.lcssa = phi i32 [ 0, %entry ], [ %add6.lcssa, %for.end.loopexit ]
51 ; Function Attrs: norecurse nounwind readonly uwtable
52 define i32 @doit_stride4(i8* nocapture readonly %Ptr, i32 %Nels) local_unnamed_addr {
53 ;CHECK: LV: Found an estimated cost of 1 for VF 1 For instruction: %0 = load i8
54 ;CHECK: LV: Found an estimated cost of 13 for VF 2 For instruction: %0 = load i8
55 ;CHECK: LV: Found an estimated cost of 5 for VF 4 For instruction: %0 = load i8
56 ;CHECK: LV: Found an estimated cost of 21 for VF 8 For instruction: %0 = load i8
57 ;CHECK: LV: Found an estimated cost of 41 for VF 16 For instruction: %0 = load i8
58 ;CHECK: LV: Found an estimated cost of 84 for VF 32 For instruction: %0 = load i8
60 %cmp59 = icmp sgt i32 %Nels, 0
61 br i1 %cmp59, label %for.body.preheader, label %for.end
66 for.body: ; preds = %for.body.preheader, %for.body
67 %Ptr.addr.062 = phi i8* [ %incdec.ptr3, %for.body ], [ %Ptr, %for.body.preheader ]
68 %i.061 = phi i32 [ %inc, %for.body ], [ 0, %for.body.preheader ]
69 %s.060 = phi i32 [ %cond39, %for.body ], [ 0, %for.body.preheader ]
70 %incdec.ptr = getelementptr inbounds i8, i8* %Ptr.addr.062, i64 1
71 %0 = load i8, i8* %Ptr.addr.062, align 1
72 %incdec.ptr1 = getelementptr inbounds i8, i8* %Ptr.addr.062, i64 2
73 %1 = load i8, i8* %incdec.ptr, align 1
74 %incdec.ptr2 = getelementptr inbounds i8, i8* %Ptr.addr.062, i64 3
75 %2 = load i8, i8* %incdec.ptr1, align 1
76 %incdec.ptr3 = getelementptr inbounds i8, i8* %Ptr.addr.062, i64 4
77 %3 = load i8, i8* %incdec.ptr2, align 1
78 %cmp5 = icmp ult i8 %0, %1
79 %.sink = select i1 %cmp5, i8 %0, i8 %1
80 %cmp12 = icmp ult i8 %.sink, %2
81 %.sink40 = select i1 %cmp12, i8 %.sink, i8 %2
82 %cmp23 = icmp ult i8 %.sink40, %3
83 %.sink41 = select i1 %cmp23, i8 %.sink40, i8 %3
84 %conv28 = zext i8 %.sink41 to i32
85 %cmp33 = icmp slt i32 %s.060, %conv28
86 %cond39 = select i1 %cmp33, i32 %s.060, i32 %conv28
87 %inc = add nuw nsw i32 %i.061, 1
88 %exitcond = icmp eq i32 %inc, %Nels
89 br i1 %exitcond, label %for.end.loopexit, label %for.body
92 %cond39.lcssa = phi i32 [ %cond39, %for.body ]
96 %s.0.lcssa = phi i32 [ 0, %entry ], [ %cond39.lcssa, %for.end.loopexit ]