1; This is the loop in c++ being vectorize in this file with
2; experimental.vector.reverse
3
4;#pragma clang loop vectorize_width(4, scalable)
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 2>%t | FileCheck %s
14
15; RUN: FileCheck --check-prefix=WARN --allow-empty %s <%t
16
17; If this check fails please read test/CodeGen/AArch64/README for instructions on how to resolve it.
18; WARN-NOT: warning
19
20
21target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
22target triple = "aarch64-unknown-linux-gnu"
23
24define void @vector_reverse_mask_nxv4i1(double* %a, double* %cond, i64 %N) #0 {
25; CHECK-LABEL: vector.body:
26; CHECK: %[[REVERSE6:.*]] = call <vscale x 4 x i1> @llvm.experimental.vector.reverse.nxv4i1(<vscale x 4 x i1> %{{.*}})
27; CHECK: %[[WIDEMSKLOAD:.*]] = call <vscale x 4 x double> @llvm.masked.load.nxv4f64.p0nxv4f64(<vscale x 4 x double>* nonnull %{{.*}}, i32 8, <vscale x 4 x i1> %[[REVERSE6]], <vscale x 4 x double> poison)
28; CHECK-NEXT: %[[REVERSE7:.*]] = call <vscale x 4 x double> @llvm.experimental.vector.reverse.nxv4f64(<vscale x 4 x double> %[[WIDEMSKLOAD]])
29; CHECK-NEXT: %[[FADD:.*]] = fadd <vscale x 4 x double> %[[REVERSE7]]
30; CHECK-NEXT: %[[REVERSE8:.*]] = call <vscale x 4 x double> @llvm.experimental.vector.reverse.nxv4f64(<vscale x 4 x double> %[[FADD]])
31; CHECK:  %[[REVERSE9:.*]] = call <vscale x 4 x i1> @llvm.experimental.vector.reverse.nxv4i1(<vscale x 4 x i1> %{{.*}})
32; CHECK: call void @llvm.masked.store.nxv4f64.p0nxv4f64(<vscale x 4 x double> %[[REVERSE8]], <vscale x 4 x double>* %{{.*}}, i32 8, <vscale x 4 x i1> %[[REVERSE9]]
33
34entry:
35  %cmp7 = icmp sgt i64 %N, 0
36  br i1 %cmp7, label %for.body, label %for.cond.cleanup
37
38for.cond.cleanup:                                 ; preds = %for.cond.cleanup, %entry
39  ret void
40
41for.body:                                         ; preds = %for.body, %entry
42  %i.08.in = phi i64 [ %i.08, %for.inc ], [ %N, %entry ]
43  %i.08 = add nsw i64 %i.08.in, -1
44  %arrayidx = getelementptr inbounds double, double* %cond, i64 %i.08
45  %0 = load double, double* %arrayidx, align 8
46  %tobool = fcmp une double %0, 0.000000e+00
47  br i1 %tobool, label %if.then, label %for.inc
48
49if.then:                                          ; preds = %for.body
50  %arrayidx1 = getelementptr inbounds double, double* %a, i64 %i.08
51  %1 = load double, double* %arrayidx1, align 8
52  %add = fadd double %1, 1.000000e+00
53  store double %add, double* %arrayidx1, align 8
54  br label %for.inc
55
56for.inc:                                          ; preds = %for.body, %if.then
57  %cmp = icmp sgt i64 %i.08.in, 1
58  br i1 %cmp, label %for.body, label %for.cond.cleanup, !llvm.loop !0
59}
60
61attributes #0 = {"target-cpu"="generic" "target-features"="+neon,+sve"}
62
63
64!0 = distinct !{!0, !1, !2, !3, !4}
65!1 = !{!"llvm.loop.mustprogress"}
66!2 = !{!"llvm.loop.vectorize.width", i32 4}
67!3 = !{!"llvm.loop.vectorize.scalable.enable", i1 true}
68!4 = !{!"llvm.loop.vectorize.enable", i1 true}
69