1; Test VLA for reverse with fixed size vector 2; This is the loop in c++ being vectorize in this file with 3; shuffle reverse 4; #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 -loop-vectorize -dce -mtriple aarch64-linux-gnu -S < %s | FileCheck %s 9 10define void @vector_reverse_f64(i64 %N, double* %a, double* %b) #0 { 11; CHECK-LABEL: vector_reverse_f64 12; CHECK-LABEL: vector.body 13; CHECK: %[[GEP:.*]] = getelementptr inbounds double, double* %{{.*}}, i32 0 14; CHECK-NEXT: %[[GEP1:.*]] = getelementptr inbounds double, double* %[[GEP]], i32 -7 15; CHECK-NEXT: %[[CAST:.*]] = bitcast double* %[[GEP1]] to <8 x double>* 16; CHECK-NEXT: %[[WIDE:.*]] = load <8 x double>, <8 x double>* %[[CAST]], align 8 17; 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, double* {{.*}}, i64 {{.*}} 20; 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> 21; CHECK-NEXT: %[[GEP3:.*]] = getelementptr inbounds double, double* %[[GEP2]], i32 0 22; CHECK-NEXT: %[[GEP4:.*]] = getelementptr inbounds double, double* %[[GEP3]], i32 -7 23; CHECK-NEXT: %[[CAST:.*]] = bitcast double* %[[GEP4]] to <8 x double>* 24; CHECK-NEXT: store <8 x double> %[[REVERSE6]], <8 x double>* %[[CAST]], align 8 25 26entry: 27 %cmp7 = icmp sgt i64 %N, 0 28 br i1 %cmp7, label %for.body, label %for.cond.cleanup 29 30for.cond.cleanup: ; preds = %for.cond.cleanup, %entry 31 ret void 32 33for.body: ; preds = %entry, %for.body 34 %i.08.in = phi i64 [ %i.08, %for.body ], [ %N, %entry ] 35 %i.08 = add nsw i64 %i.08.in, -1 36 %arrayidx = getelementptr inbounds double, double* %b, i64 %i.08 37 %0 = load double, double* %arrayidx, align 8 38 %add = fadd double %0, 1.000000e+00 39 %arrayidx1 = getelementptr inbounds double, double* %a, i64 %i.08 40 store double %add, double* %arrayidx1, align 8 41 %cmp = icmp sgt i64 %i.08.in, 1 42 br i1 %cmp, label %for.body, label %for.cond.cleanup, !llvm.loop !0 43} 44 45define void @vector_reverse_i64(i64 %N, i64* %a, i64* %b) #0 { 46; CHECK-LABEL: vector_reverse_i64 47; CHECK-LABEL: vector.body 48; CHECK: %[[GEP:.*]] = getelementptr inbounds i64, i64* %{{.*}}, i32 0 49; CHECK-NEXT: %[[GEP1:.*]] = getelementptr inbounds i64, i64* %[[GEP]], i32 -7 50; CHECK-NEXT: %[[CAST:.*]] = bitcast i64* %[[GEP1]] to <8 x i64>* 51; CHECK-NEXT: %[[WIDE:.*]] = load <8 x i64>, <8 x i64>* %[[CAST]], align 8 52; 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> 53; CHECK-NEXT: %[[FADD:.*]] = add <8 x i64> %[[REVERSE]] 54; CHECK-NEXT: %[[GEP2:.*]] = getelementptr inbounds i64, i64* {{.*}}, i64 {{.*}} 55; 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: %[[GEP3:.*]] = getelementptr inbounds i64, i64* %[[GEP2]], i32 0 57; CHECK-NEXT: %[[GEP4:.*]] = getelementptr inbounds i64, i64* %[[GEP3]], i32 -7 58; CHECK-NEXT: %[[CAST1:.*]] = bitcast i64* %[[GEP4]] to <8 x i64>* 59; CHECK-NEXT: store <8 x i64> %[[REVERSE6]], <8 x i64>* %[[CAST1]], align 8 60 61entry: 62 %cmp8 = icmp sgt i64 %N, 0 63 br i1 %cmp8, label %for.body, label %for.cond.cleanup 64 65for.cond.cleanup: ; preds = %for.cond.cleanup, %entry 66 ret void 67 68for.body: ; preds = %entry, %for.body 69 %i.09.in = phi i64 [ %i.09, %for.body ], [ %N, %entry ] 70 %i.09 = add nsw i64 %i.09.in, -1 71 %arrayidx = getelementptr inbounds i64, i64* %b, i64 %i.09 72 %0 = load i64, i64* %arrayidx, align 8 73 %add = add i64 %0, 1 74 %arrayidx2 = getelementptr inbounds i64, i64* %a, i64 %i.09 75 store i64 %add, i64* %arrayidx2, align 8 76 %cmp = icmp sgt i64 %i.09.in, 1 77 br i1 %cmp, label %for.body, label %for.cond.cleanup, !llvm.loop !0 78} 79 80attributes #0 = { "target-cpu"="generic" "target-features"="+neon,+sve" } 81 82!0 = distinct !{!0, !1, !2, !3, !4} 83!1 = !{!"llvm.loop.mustprogress"} 84!2 = !{!"llvm.loop.vectorize.width", i32 8} 85!3 = !{!"llvm.loop.vectorize.scalable.enable", i1 false} 86!4 = !{!"llvm.loop.vectorize.enable", i1 true} 87