84 lines · plain
1; Test VLA for reverse with fixed size vector2; This is the loop in c++ being vectorize in this file with3; shuffle reverse4; #pragma clang loop vectorize_width(8, fixed)5; for (int i = N-1; i >= 0; --i)6; a[i] = b[i] + 1.0;7 8; RUN: opt -passes=loop-vectorize,dce -mtriple aarch64-linux-gnu -S \9; RUN: -prefer-predicate-over-epilogue=scalar-epilogue < %s | FileCheck %s10 11define void @vector_reverse_f64(i64 %N, ptr %a, ptr %b) #0 {12; CHECK-LABEL: vector_reverse_f6413; CHECK-LABEL: vector.body14; CHECK: %[[GEP:.*]] = getelementptr inbounds double, ptr %{{.*}}, i64 015; CHECK-NEXT: %[[GEP1:.*]] = getelementptr inbounds double, ptr %[[GEP]], i64 -716; CHECK-NEXT: %[[WIDE:.*]] = load <8 x double>, ptr %[[GEP1]], align 817; CHECK-NEXT: %[[REVERSE:.*]] = shufflevector <8 x double> %[[WIDE]], <8 x double> poison, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>18; CHECK-NEXT: %[[FADD:.*]] = fadd <8 x double> %[[REVERSE]]19; CHECK-NEXT: %[[GEP2:.*]] = getelementptr inbounds double, ptr {{.*}}, i64 {{.*}}20; CHECK-NEXT: %[[GEP3:.*]] = getelementptr inbounds double, ptr %[[GEP2]], i64 021; CHECK-NEXT: %[[GEP4:.*]] = getelementptr inbounds double, ptr %[[GEP3]], i64 -722; CHECK-NEXT: %[[REVERSE6:.*]] = shufflevector <8 x double> %[[FADD]], <8 x double> poison, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>23; CHECK-NEXT: store <8 x double> %[[REVERSE6]], ptr %[[GEP4]], align 824 25entry:26 %cmp7 = icmp sgt i64 %N, 027 br i1 %cmp7, label %for.body, label %for.cond.cleanup28 29for.cond.cleanup: ; preds = %for.cond.cleanup, %entry30 ret void31 32for.body: ; preds = %entry, %for.body33 %i.08.in = phi i64 [ %i.08, %for.body ], [ %N, %entry ]34 %i.08 = add nsw i64 %i.08.in, -135 %arrayidx = getelementptr inbounds double, ptr %b, i64 %i.0836 %0 = load double, ptr %arrayidx, align 837 %add = fadd double %0, 1.000000e+0038 %arrayidx1 = getelementptr inbounds double, ptr %a, i64 %i.0839 store double %add, ptr %arrayidx1, align 840 %cmp = icmp sgt i64 %i.08.in, 141 br i1 %cmp, label %for.body, label %for.cond.cleanup, !llvm.loop !042}43 44define void @vector_reverse_i64(i64 %N, ptr %a, ptr %b) #0 {45; CHECK-LABEL: vector_reverse_i6446; CHECK-LABEL: vector.body47; CHECK: %[[GEP:.*]] = getelementptr inbounds i64, ptr %{{.*}}, i64 048; CHECK-NEXT: %[[GEP1:.*]] = getelementptr inbounds i64, ptr %[[GEP]], i64 -749; CHECK-NEXT: %[[WIDE:.*]] = load <8 x i64>, ptr %[[GEP1]], align 850; CHECK-NEXT: %[[REVERSE:.*]] = shufflevector <8 x i64> %[[WIDE]], <8 x i64> poison, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>51; CHECK-NEXT: %[[FADD:.*]] = add <8 x i64> %[[REVERSE]]52; CHECK-NEXT: %[[GEP2:.*]] = getelementptr inbounds i64, ptr {{.*}}, i64 {{.*}}53; CHECK-NEXT: %[[GEP3:.*]] = getelementptr inbounds i64, ptr %[[GEP2]], i64 054; CHECK-NEXT: %[[GEP4:.*]] = getelementptr inbounds i64, ptr %[[GEP3]], i64 -755; CHECK-NEXT: %[[REVERSE6:.*]] = shufflevector <8 x i64> %[[FADD]], <8 x i64> poison, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>56; CHECK-NEXT: store <8 x i64> %[[REVERSE6]], ptr %[[GEP4]], align 857 58entry:59 %cmp8 = icmp sgt i64 %N, 060 br i1 %cmp8, label %for.body, label %for.cond.cleanup61 62for.cond.cleanup: ; preds = %for.cond.cleanup, %entry63 ret void64 65for.body: ; preds = %entry, %for.body66 %i.09.in = phi i64 [ %i.09, %for.body ], [ %N, %entry ]67 %i.09 = add nsw i64 %i.09.in, -168 %arrayidx = getelementptr inbounds i64, ptr %b, i64 %i.0969 %0 = load i64, ptr %arrayidx, align 870 %add = add i64 %0, 171 %arrayidx2 = getelementptr inbounds i64, ptr %a, i64 %i.0972 store i64 %add, ptr %arrayidx2, align 873 %cmp = icmp sgt i64 %i.09.in, 174 br i1 %cmp, label %for.body, label %for.cond.cleanup, !llvm.loop !075}76 77attributes #0 = { "target-cpu"="generic" "target-features"="+neon,+sve" }78 79!0 = distinct !{!0, !1, !2, !3, !4}80!1 = !{!"llvm.loop.mustprogress"}81!2 = !{!"llvm.loop.vectorize.width", i32 8}82!3 = !{!"llvm.loop.vectorize.scalable.enable", i1 false}83!4 = !{!"llvm.loop.vectorize.enable", i1 true}84