1; REQUIRES: asserts 2; RUN: opt < %s -loop-vectorize -mcpu=core-axv2 -force-vector-interleave=1 -dce -instcombine -debug-only=loop-vectorize -S < %s 2>&1 | FileCheck %s 3 4target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" 5 6; Make sure we ignore the costs of the redundant reduction casts 7; char reduction_i8(char *a, char *b, int n) { 8; char sum = 0; 9; for (int i = 0; i < n; ++i) 10; sum += (a[i] + b[i]); 11; return sum; 12; } 13; 14 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 46; 47define i8 @reduction_i8(i8* nocapture readonly %a, i8* nocapture readonly %b, i32 %n) { 48entry: 49 %cmp.12 = icmp sgt i32 %n, 0 50 br i1 %cmp.12, label %for.body.preheader, label %for.cond.cleanup 51 52for.body.preheader: 53 br label %for.body 54 55for.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 59 60for.cond.cleanup: 61 %sum.0.lcssa = phi i8 [ %conv6, %for.cond.for.cond.cleanup_crit_edge ], [ 0, %entry ] 62 ret i8 %sum.0.lcssa 63 64for.body: 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, i8* %a, i64 %indvars.iv 68 %0 = load i8, i8* %arrayidx, align 1 69 %conv = zext i8 %0 to i32 70 %arrayidx2 = getelementptr inbounds i8, i8* %b, i64 %indvars.iv 71 %1 = load i8, i8* %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 80} 81