brintos

brintos / llvm-project-archived public Read only

0
0
Text · 5.0 KiB · ba62ebc Raw
88 lines · plain
1; REQUIRES: asserts2; RUN: opt -passes=loop-vectorize,dce,instcombine -mcpu=core-axv2 -force-vector-interleave=1 -debug-only=loop-vectorize -S %s 2>&1  | FileCheck %s3 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 casts7; 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_i816; CHECK: LV: Found an estimated cost of {{[0-9]+}} for VF 1 For instruction:   %{{.*}} = phi17; CHECK: LV: Found an estimated cost of {{[0-9]+}} for VF 1 For instruction:   %{{.*}} = phi18; CHECK: LV: Found an estimated cost of {{[0-9]+}} for VF 1 For instruction:   %{{.*}} = getelementptr19; CHECK: LV: Found an estimated cost of {{[0-9]+}} for VF 1 For instruction:   %{{.*}} = load20; CHECK: LV: Found an estimated cost of {{[0-9]+}} for VF 1 For instruction:   %{{.*}} = zext i8 %{{.*}} to i3221; CHECK: LV: Found an estimated cost of {{[0-9]+}} for VF 1 For instruction:   %{{.*}} = getelementptr22; CHECK: LV: Found an estimated cost of {{[0-9]+}} for VF 1 For instruction:   %{{.*}} = load23; CHECK: LV: Found an estimated cost of {{[0-9]+}} for VF 1 For instruction:   %{{.*}} = zext i8 %{{.*}} to i3224; CHECK: LV: Found an estimated cost of {{[0-9]+}} for VF 1 For instruction:   %{{.*}} = and i32 %{{.*}}, 25525; CHECK: LV: Found an estimated cost of {{[0-9]+}} for VF 1 For instruction:   %{{.*}} = add26; CHECK: LV: Found an estimated cost of {{[0-9]+}} for VF 1 For instruction:   %{{.*}} = add27; CHECK: LV: Found an estimated cost of {{[0-9]+}} for VF 1 For instruction:   %{{.*}} = add28; CHECK: LV: Found an estimated cost of {{[0-9]+}} for VF 1 For instruction:   %{{.*}} = trunc29; CHECK: LV: Found an estimated cost of {{[0-9]+}} for VF 1 For instruction:   %{{.*}} = icmp30; CHECK: LV: Found an estimated cost of {{[0-9]+}} for VF 1 For instruction:   br31; CHECK: Cost of 1 for VF 2: induction instruction   %indvars.iv.next = add nuw nsw i64 %indvars.iv, 132; CHECK: Cost of 1 for VF 2: induction instruction   %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %for.body.preheader ]33; CHECK: Cost of 1 for VF 2: exit condition instruction   %exitcond = icmp eq i32 %lftr.wideiv, %n34; CHECK: Cost of 0 for VF 2: exit condition instruction   %lftr.wideiv = trunc i64 %indvars.iv.next to i3235; CHECK: Cost of 0 for VF 2: EMIT vp<[[CAN_IV:%.+]]> = CANONICAL-INDUCTION ir<0>, vp<%index.next>36; CHECK: Cost of 1 for VF 2: WIDEN-REDUCTION-PHI ir<%sum.013> = phi vp<{{.+}}>, vp<[[EXT:%.+]]>37; CHECK: Cost of 0 for VF 2: vp<[[STEPS:%.+]]> = SCALAR-STEPS vp<[[CAN_IV]]>, ir<1>38; CHECK: Cost of 0 for VF 2: CLONE ir<%arrayidx> = getelementptr inbounds ir<%a>, vp<[[STEPS]]>39; CHECK: Cost of 0 for VF 2: vp<[[VECP1:%.+]]> = vector-pointer inbounds ir<%arrayidx>40; CHECK: Cost of 1 for VF 2: WIDEN ir<%0> = load vp<[[VECP1]]>41; CHECK: Cost of 0 for VF 2: WIDEN-CAST ir<%conv> = zext ir<%0> to i3242; CHECK: Cost of 0 for VF 2: CLONE ir<%arrayidx2> = getelementptr inbounds ir<%b>, vp<[[STEPS]]>43; CHECK: Cost of 0 for VF 2: vp<[[VECP2:%.+]]> = vector-pointer inbounds ir<%arrayidx2>44; CHECK: Cost of 1 for VF 2: WIDEN ir<%1> = load vp<[[VECP2]]>45; CHECK: Cost of 0 for VF 2: WIDEN-CAST ir<%conv3> = zext ir<%1> to i3246; CHECK: Cost of 0 for VF 2: WIDEN ir<%conv4> = and ir<%sum.013>, ir<255>47; CHECK: Cost of 1 for VF 2: WIDEN ir<%add> = add ir<%conv>, ir<%conv4>48; CHECK: Cost of 1 for VF 2: WIDEN ir<%add5> = add ir<%add>, ir<%conv3>49; CHECK: Cost of 0 for VF 2: WIDEN-CAST vp<[[TRUNC:%.+]]> = trunc ir<%add5> to i850; CHECK: Cost of 0 for VF 2: WIDEN-CAST vp<[[EXT]]> = zext vp<[[TRUNC]]> to i3251; CHECK: Cost of 0 for VF 2: EMIT vp<%index.next> = add nuw vp<[[CAN_IV]]>, vp<{{.+}}>52; CHECK: Cost of 0 for VF 2: EMIT branch-on-count vp<%index.next>, vp<{{.+}}>53;54define i8 @reduction_i8(ptr nocapture readonly %a, ptr nocapture readonly %b, i32 %n) {55entry:56  %cmp.12 = icmp sgt i32 %n, 057  br i1 %cmp.12, label %for.body.preheader, label %for.cond.cleanup58 59for.body.preheader:60  br label %for.body61 62for.cond.for.cond.cleanup_crit_edge:63  %add5.lcssa = phi i32 [ %add5, %for.body ]64  %conv6 = trunc i32 %add5.lcssa to i865  br label %for.cond.cleanup66 67for.cond.cleanup:68  %sum.0.lcssa = phi i8 [ %conv6, %for.cond.for.cond.cleanup_crit_edge ], [ 0, %entry ]69  ret i8 %sum.0.lcssa70 71for.body:72  %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %for.body.preheader ]73  %sum.013 = phi i32 [ %add5, %for.body ], [ 0, %for.body.preheader ]74  %arrayidx = getelementptr inbounds i8, ptr %a, i64 %indvars.iv75  %0 = load i8, ptr %arrayidx, align 176  %conv = zext i8 %0 to i3277  %arrayidx2 = getelementptr inbounds i8, ptr %b, i64 %indvars.iv78  %1 = load i8, ptr %arrayidx2, align 179  %conv3 = zext i8 %1 to i3280  %conv4 = and i32 %sum.013, 25581  %add = add nuw nsw i32 %conv, %conv482  %add5 = add nuw nsw i32 %add, %conv383  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 184  %lftr.wideiv = trunc i64 %indvars.iv.next to i3285  %exitcond = icmp eq i32 %lftr.wideiv, %n86  br i1 %exitcond, label %for.cond.for.cond.cleanup_crit_edge, label %for.body87}88