2 ; RUN: opt < %s -passes=loop-vectorize,dce,instcombine -mcpu=core-axv2 -force-vector-interleave=1 -debug-only=loop-vectorize -S < %s 2>&1 | FileCheck %s
4 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
6 ; Make sure we ignore the costs of the redundant reduction casts
7 ; char reduction_i8(char *a, char *b, int n) {
9 ; for (int i = 0; i < n; ++i)
10 ; sum += (a[i] + b[i]);
15 ; CHECK-LABEL: reduction_i8
16 ; CHECK: LV: Found an estimated cost of {{[0-9]+}} for VF 1 For instruction: %{{.*}} = phi
17 ; CHECK: LV: Found an estimated cost of {{[0-9]+}} for VF 1 For instruction: %{{.*}} = phi
18 ; CHECK: LV: Found an estimated cost of {{[0-9]+}} for VF 1 For instruction: %{{.*}} = getelementptr
19 ; CHECK: LV: Found an estimated cost of {{[0-9]+}} for VF 1 For instruction: %{{.*}} = load
20 ; CHECK: LV: Found an estimated cost of {{[0-9]+}} for VF 1 For instruction: %{{.*}} = zext i8 %{{.*}} to i32
21 ; CHECK: LV: Found an estimated cost of {{[0-9]+}} for VF 1 For instruction: %{{.*}} = getelementptr
22 ; CHECK: LV: Found an estimated cost of {{[0-9]+}} for VF 1 For instruction: %{{.*}} = load
23 ; CHECK: LV: Found an estimated cost of {{[0-9]+}} for VF 1 For instruction: %{{.*}} = zext i8 %{{.*}} to i32
24 ; CHECK: LV: Found an estimated cost of {{[0-9]+}} for VF 1 For instruction: %{{.*}} = and i32 %{{.*}}, 255
25 ; CHECK: LV: Found an estimated cost of {{[0-9]+}} for VF 1 For instruction: %{{.*}} = add
26 ; CHECK: LV: Found an estimated cost of {{[0-9]+}} for VF 1 For instruction: %{{.*}} = add
27 ; CHECK: LV: Found an estimated cost of {{[0-9]+}} for VF 1 For instruction: %{{.*}} = add
28 ; CHECK: LV: Found an estimated cost of {{[0-9]+}} for VF 1 For instruction: %{{.*}} = trunc
29 ; CHECK: LV: Found an estimated cost of {{[0-9]+}} for VF 1 For instruction: %{{.*}} = icmp
30 ; CHECK: LV: Found an estimated cost of {{[0-9]+}} for VF 1 For instruction: br
31 ; CHECK: LV: Found an estimated cost of {{[0-9]+}} for VF 2 For instruction: %{{.*}} = phi
32 ; CHECK: LV: Found an estimated cost of {{[0-9]+}} for VF 2 For instruction: %{{.*}} = phi
33 ; CHECK: LV: Found an estimated cost of {{[0-9]+}} for VF 2 For instruction: %{{.*}} = getelementptr
34 ; CHECK: LV: Found an estimated cost of {{[0-9]+}} for VF 2 For instruction: %{{.*}} = load
35 ; CHECK-NOT: LV: Found an estimated cost of {{[0-9]+}} for VF 2 For instruction: %{{.*}} = zext i8 %{{.*}} to i32
36 ; CHECK: LV: Found an estimated cost of {{[0-9]+}} for VF 2 For instruction: %{{.*}} = getelementptr
37 ; CHECK: LV: Found an estimated cost of {{[0-9]+}} for VF 2 For instruction: %{{.*}} = load
38 ; CHECK-NOT: LV: Found an estimated cost of {{[0-9]+}} for VF 2 For instruction: %{{.*}} = zext i8 %{{.*}} to i32
39 ; CHECK-NOT: LV: Found an estimated cost of {{[0-9]+}} for VF 2 For instruction: %{{.*}} = and i32 %{{.*}}, 255
40 ; CHECK: LV: Found an estimated cost of {{[0-9]+}} for VF 2 For instruction: %{{.*}} = add
41 ; CHECK: LV: Found an estimated cost of {{[0-9]+}} for VF 2 For instruction: %{{.*}} = add
42 ; CHECK: LV: Found an estimated cost of {{[0-9]+}} for VF 2 For instruction: %{{.*}} = add
43 ; CHECK: LV: Found an estimated cost of {{[0-9]+}} for VF 2 For instruction: %{{.*}} = trunc
44 ; CHECK: LV: Found an estimated cost of {{[0-9]+}} for VF 2 For instruction: %{{.*}} = icmp
45 ; CHECK: LV: Found an estimated cost of {{[0-9]+}} for VF 2 For instruction: br
47 define i8 @reduction_i8(ptr nocapture readonly %a, ptr nocapture readonly %b, i32 %n) {
49 %cmp.12 = icmp sgt i32 %n, 0
50 br i1 %cmp.12, label %for.body.preheader, label %for.cond.cleanup
55 for.cond.for.cond.cleanup_crit_edge:
56 %add5.lcssa = phi i32 [ %add5, %for.body ]
57 %conv6 = trunc i32 %add5.lcssa to i8
58 br label %for.cond.cleanup
61 %sum.0.lcssa = phi i8 [ %conv6, %for.cond.for.cond.cleanup_crit_edge ], [ 0, %entry ]
65 %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %for.body.preheader ]
66 %sum.013 = phi i32 [ %add5, %for.body ], [ 0, %for.body.preheader ]
67 %arrayidx = getelementptr inbounds i8, ptr %a, i64 %indvars.iv
68 %0 = load i8, ptr %arrayidx, align 1
69 %conv = zext i8 %0 to i32
70 %arrayidx2 = getelementptr inbounds i8, ptr %b, i64 %indvars.iv
71 %1 = load i8, ptr %arrayidx2, align 1
72 %conv3 = zext i8 %1 to i32
73 %conv4 = and i32 %sum.013, 255
74 %add = add nuw nsw i32 %conv, %conv4
75 %add5 = add nuw nsw i32 %add, %conv3
76 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
77 %lftr.wideiv = trunc i64 %indvars.iv.next to i32
78 %exitcond = icmp eq i32 %lftr.wideiv, %n
79 br i1 %exitcond, label %for.cond.for.cond.cleanup_crit_edge, label %for.body