1; This is the loop in c++ being vectorize in this file with 2;experimental.vector.reverse 3; #pragma clang loop vectorize_width(4, scalable) 4; for (int i = N-1; i >= 0; --i) 5; a[i] = b[i] + 1.0; 6 7; REQUIRES: asserts 8; RUN: opt -loop-vectorize -dce -instcombine -mtriple riscv64-linux-gnu \ 9; RUN: -mattr=+v -debug-only=loop-vectorize -scalable-vectorization=on \ 10; RUN: -riscv-v-vector-bits-min=128 -S < %s 2>&1 | FileCheck %s 11 12; CHECK-LABEL: vector_reverse_i64 13; CHECK: LV: Found an estimated cost of Invalid for VF vscale x 1 For instruction: %{{.*}} = load i32, ptr %{{.*}}, align 4 14; CHECK: LV: Found an estimated cost of Invalid for VF vscale x 1 For instruction: store i32 %{{.*}}, ptr %{{.*}}, align 4 15; CHECK: LV: Found an estimated cost of Invalid for VF vscale x 2 For instruction: %{{.*}} = load i32, ptr %{{.*}}, align 4 16; CHECK: LV: Found an estimated cost of Invalid for VF vscale x 2 For instruction: store i32 %{{.*}}, ptr %{{.*}}, align 4 17; CHECK: LV: Found an estimated cost of Invalid for VF vscale x 4 For instruction: %{{.*}} = load i32, ptr %{{.*}}, align 4 18; CHECK: LV: Found an estimated cost of Invalid for VF vscale x 4 For instruction: store i32 %{{.*}}, ptr %{{.*}}, align 4 19; CHECK: LV: Instruction with invalid costs prevented vectorization at VF=(vscale x 1, vscale x 2, vscale x 4): load %1 = load i32, ptr %arrayidx, align 4 20; CHECK: remark: <unknown>:0:0: Instruction with invalid costs prevented vectorization at VF=(vscale x 1, vscale x 2, vscale x 4): load 21; CHECK: LV: Instruction with invalid costs prevented vectorization at VF=(vscale x 1, vscale x 2, vscale x 4): store store i32 %add9, ptr %arrayidx3, align 4 22; CHECK: remark: <unknown>:0:0: Instruction with invalid costs prevented vectorization at VF=(vscale x 1, vscale x 2, vscale x 4): store 23; CHECK: LV: Selecting VF: 4. 24define void @vector_reverse_i64(ptr nocapture noundef writeonly %A, ptr nocapture noundef readonly %B, i32 noundef signext %n) { 25entry: 26 %cmp7 = icmp sgt i32 %n, 0 27 br i1 %cmp7, label %for.body.preheader, label %for.cond.cleanup 28 29for.body.preheader: ; preds = %entry 30 %0 = zext i32 %n to i64 31 br label %for.body 32 33for.cond.cleanup: ; preds = %for.body, %entry 34 ret void 35 36for.body: ; preds = %for.body.preheader, %for.body 37 %indvars.iv = phi i64 [ %0, %for.body.preheader ], [ %indvars.iv.next, %for.body ] 38 %i.0.in8 = phi i32 [ %n, %for.body.preheader ], [ %i.0, %for.body ] 39 %i.0 = add nsw i32 %i.0.in8, -1 40 %idxprom = zext i32 %i.0 to i64 41 %arrayidx = getelementptr inbounds i32, ptr %B, i64 %idxprom 42 %1 = load i32, ptr %arrayidx, align 4 43 %add9 = add i32 %1, 1 44 %arrayidx3 = getelementptr inbounds i32, ptr %A, i64 %idxprom 45 store i32 %add9, ptr %arrayidx3, align 4 46 %cmp = icmp ugt i64 %indvars.iv, 1 47 %indvars.iv.next = add nsw i64 %indvars.iv, -1 48 br i1 %cmp, label %for.body, label %for.cond.cleanup, !llvm.loop !0 49} 50 51; CHECK-LABEL: vector_reverse_f32 52; CHECK: LV: Found an estimated cost of Invalid for VF vscale x 1 For instruction: %{{.*}} = load float, ptr %{{.*}}, align 4 53; CHECK: LV: Found an estimated cost of Invalid for VF vscale x 1 For instruction: store float %{{.*}}, ptr %{{.*}}, align 4 54; CHECK: LV: Found an estimated cost of Invalid for VF vscale x 2 For instruction: %{{.*}} = load float, ptr %{{.*}}, align 4 55; CHECK: LV: Found an estimated cost of Invalid for VF vscale x 2 For instruction: store float %{{.*}}, ptr %{{.*}}, align 4 56; CHECK: LV: Found an estimated cost of Invalid for VF vscale x 4 For instruction: %{{.*}} = load float, ptr %{{.*}}, align 4 57; CHECK: LV: Found an estimated cost of Invalid for VF vscale x 4 For instruction: store float %{{.*}}, ptr %{{.*}}, align 4 58; CHECK: LV: Instruction with invalid costs prevented vectorization at VF=(vscale x 1, vscale x 2, vscale x 4): load %1 = load float, ptr %arrayidx, align 4 59; CHECK: remark: <unknown>:0:0: Instruction with invalid costs prevented vectorization at VF=(vscale x 1, vscale x 2, vscale x 4): load 60; CHECK: LV: Instruction with invalid costs prevented vectorization at VF=(vscale x 1, vscale x 2, vscale x 4): store store float %conv1, ptr %arrayidx3, align 4 61; CHECK: remark: <unknown>:0:0: Instruction with invalid costs prevented vectorization at VF=(vscale x 1, vscale x 2, vscale x 4): store 62; CHECK: LV: Selecting VF: 4. 63define void @vector_reverse_f32(ptr nocapture noundef writeonly %A, ptr nocapture noundef readonly %B, i32 noundef signext %n) { 64entry: 65 %cmp7 = icmp sgt i32 %n, 0 66 br i1 %cmp7, label %for.body.preheader, label %for.cond.cleanup 67 68for.body.preheader: ; preds = %entry 69 %0 = zext i32 %n to i64 70 br label %for.body 71 72for.cond.cleanup: ; preds = %for.body, %entry 73 ret void 74 75for.body: ; preds = %for.body.preheader, %for.body 76 %indvars.iv = phi i64 [ %0, %for.body.preheader ], [ %indvars.iv.next, %for.body ] 77 %i.0.in8 = phi i32 [ %n, %for.body.preheader ], [ %i.0, %for.body ] 78 %i.0 = add nsw i32 %i.0.in8, -1 79 %idxprom = zext i32 %i.0 to i64 80 %arrayidx = getelementptr inbounds float, ptr %B, i64 %idxprom 81 %1 = load float, ptr %arrayidx, align 4 82 %conv1 = fadd float %1, 1.000000e+00 83 %arrayidx3 = getelementptr inbounds float, ptr %A, i64 %idxprom 84 store float %conv1, ptr %arrayidx3, align 4 85 %cmp = icmp ugt i64 %indvars.iv, 1 86 %indvars.iv.next = add nsw i64 %indvars.iv, -1 87 br i1 %cmp, label %for.body, label %for.cond.cleanup, !llvm.loop !0 88} 89 90!0 = distinct !{!0, !1, !2, !3, !4} 91!1 = !{!"llvm.loop.mustprogress"} 92!2 = !{!"llvm.loop.vectorize.width", i32 4} 93!3 = !{!"llvm.loop.vectorize.scalable.enable", i1 true} 94!4 = !{!"llvm.loop.vectorize.enable", i1 true} 95