1; This is the loop in c++ being vectorize in this file with 2; shuffle reverse 3 4;#pragma clang loop vectorize_width(4, fixed) 5; for (long int i = N - 1; i >= 0; i--) 6; { 7; if (cond[i]) 8; a[i] += 1; 9; } 10 11; The test checks if the mask is being correctly created, reverted and used 12 13; RUN: opt -loop-vectorize -dce -instcombine -mtriple aarch64-linux-gnu -S < %s | FileCheck %s 14 15target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128" 16target triple = "aarch64-unknown-linux-gnu" 17 18define void @vector_reverse_mask_v4i1(double* %a, double* %cond, i64 %N) #0 { 19; CHECK-LABEL: vector.body: 20; CHECK: %[[REVERSE6:.*]] = shufflevector <4 x i1> %{{.*}}, <4 x i1> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0> 21; CHECK: %[[WIDEMSKLOAD:.*]] = call <4 x double> @llvm.masked.load.v4f64.p0v4f64(<4 x double>* nonnull %{{.*}}, i32 8, <4 x i1> %[[REVERSE6]], <4 x double> poison) 22; CHECK-NEXT: %[[FADD:.*]] = fadd <4 x double> %[[WIDEMSKLOAD]] 23; CHECK: call void @llvm.masked.store.v4f64.p0v4f64(<4 x double> %[[FADD]], <4 x double>* %{{.*}}, i32 8, <4 x i1> %[[REVERSE6]]) 24 25entry: 26 %cmp7 = icmp sgt i64 %N, 0 27 br i1 %cmp7, label %for.body, label %for.cond.cleanup 28 29for.cond.cleanup: ; preds = %for.cond.cleanup, %entry 30 ret void 31 32for.body: ; preds = %for.body, %entry 33 %i.08.in = phi i64 [ %i.08, %for.inc ], [ %N, %entry ] 34 %i.08 = add nsw i64 %i.08.in, -1 35 %arrayidx = getelementptr inbounds double, double* %cond, i64 %i.08 36 %0 = load double, double* %arrayidx, align 8 37 %tobool = fcmp une double %0, 0.000000e+00 38 br i1 %tobool, label %if.then, label %for.inc 39 40if.then: ; preds = %for.body 41 %arrayidx1 = getelementptr inbounds double, double* %a, i64 %i.08 42 %1 = load double, double* %arrayidx1, align 8 43 %add = fadd double %1, 1.000000e+00 44 store double %add, double* %arrayidx1, align 8 45 br label %for.inc 46 47for.inc: ; preds = %for.body, %if.then 48 %cmp = icmp sgt i64 %i.08.in, 1 49 br i1 %cmp, label %for.body, label %for.cond.cleanup, !llvm.loop !0 50} 51 52attributes #0 = {"target-cpu"="generic" "target-features"="+neon,+sve"} 53 54 55!0 = distinct !{!0, !1, !2, !3, !4} 56!1 = !{!"llvm.loop.mustprogress"} 57!2 = !{!"llvm.loop.vectorize.width", i32 4} 58!3 = !{!"llvm.loop.vectorize.scalable.enable", i1 false} 59!4 = !{!"llvm.loop.vectorize.enable", i1 true} 60