1 ; RUN: opt -mtriple aarch64-linux-gnu -mattr=+sve -passes=loop-vectorize,dce,instcombine -S \
2 ; RUN: -prefer-predicate-over-epilogue=scalar-epilogue <%s | FileCheck %s
4 define void @stride7_i32(ptr noalias nocapture %dst, i64 %n) #0 {
5 ; CHECK-LABEL: @stride7_i32(
7 ; CHECK: %[[VEC_IND:.*]] = phi <vscale x 4 x i64> [ %{{.*}}, %vector.ph ], [ %{{.*}}, %vector.body ]
8 ; CHECK-NEXT: %[[PTR_INDICES:.*]] = mul nuw nsw <vscale x 4 x i64> %[[VEC_IND]], shufflevector (<vscale x 4 x i64> insertelement (<vscale x 4 x i64> poison, i64 7, i64 0), <vscale x 4 x i64> poison, <vscale x 4 x i32> zeroinitializer)
9 ; CHECK-NEXT: %[[PTRS:.*]] = getelementptr inbounds i32, ptr %dst, <vscale x 4 x i64> %[[PTR_INDICES]]
10 ; CHECK-NEXT: %[[GLOAD:.*]] = call <vscale x 4 x i32> @llvm.masked.gather.nxv4i32.nxv4p0(<vscale x 4 x ptr> %[[PTRS]]
11 ; CHECK-NEXT: %[[VALS:.*]] = add nsw <vscale x 4 x i32> %[[GLOAD]],
12 ; CHECK-NEXT: call void @llvm.masked.scatter.nxv4i32.nxv4p0(<vscale x 4 x i32> %[[VALS]], <vscale x 4 x ptr> %[[PTRS]]
16 for.body: ; preds = %entry, %for.body
17 %i.05 = phi i64 [ %inc, %for.body ], [ 0, %entry ]
18 %mul = mul nuw nsw i64 %i.05, 7
19 %arrayidx = getelementptr inbounds i32, ptr %dst, i64 %mul
20 %0 = load i32, ptr %arrayidx, align 4
21 %add = add nsw i32 %0, 3
22 store i32 %add, ptr %arrayidx, align 4
23 %inc = add nuw nsw i64 %i.05, 1
24 %exitcond.not = icmp eq i64 %inc, %n
25 br i1 %exitcond.not, label %for.end, label %for.body, !llvm.loop !0
27 for.end: ; preds = %for.end.loopexit, %entry
31 define void @stride7_f64(ptr noalias nocapture %dst, i64 %n) #0 {
32 ; CHECK-LABEL: @stride7_f64(
34 ; CHECK: %[[VEC_IND:.*]] = phi <vscale x 2 x i64> [ %{{.*}}, %vector.ph ], [ %{{.*}}, %vector.body ]
35 ; CHECK-NEXT: %[[PTR_INDICES:.*]] = mul nuw nsw <vscale x 2 x i64> %[[VEC_IND]], shufflevector (<vscale x 2 x i64> insertelement (<vscale x 2 x i64> poison, i64 7, i64 0), <vscale x 2 x i64> poison, <vscale x 2 x i32> zeroinitializer)
36 ; CHECK-NEXT: %[[PTRS:.*]] = getelementptr inbounds double, ptr %dst, <vscale x 2 x i64> %[[PTR_INDICES]]
37 ; CHECK-NEXT: %[[GLOAD:.*]] = call <vscale x 2 x double> @llvm.masked.gather.nxv2f64.nxv2p0(<vscale x 2 x ptr> %[[PTRS]],
38 ; CHECK-NEXT: %[[VALS:.*]] = fadd <vscale x 2 x double> %[[GLOAD]],
39 ; CHECK-NEXT: call void @llvm.masked.scatter.nxv2f64.nxv2p0(<vscale x 2 x double> %[[VALS]], <vscale x 2 x ptr> %[[PTRS]],
43 for.body: ; preds = %entry, %for.body
44 %i.05 = phi i64 [ %inc, %for.body ], [ 0, %entry ]
45 %mul = mul nuw nsw i64 %i.05, 7
46 %arrayidx = getelementptr inbounds double, ptr %dst, i64 %mul
47 %0 = load double, ptr %arrayidx, align 8
48 %add = fadd double %0, 1.000000e+00
49 store double %add, ptr %arrayidx, align 8
50 %inc = add nuw nsw i64 %i.05, 1
51 %exitcond.not = icmp eq i64 %inc, %n
52 br i1 %exitcond.not, label %for.end, label %for.body, !llvm.loop !6
54 for.end: ; preds = %for.end.loopexit, %entry
59 define void @cond_stride7_f64(ptr noalias nocapture %dst, ptr noalias nocapture readonly %cond, i64 %n) #0 {
60 ; CHECK-LABEL: @cond_stride7_f64(
62 ; CHECK: %[[MASK:.*]] = icmp ne <vscale x 2 x i64>
63 ; CHECK: %[[PTRS:.*]] = getelementptr inbounds double, ptr %dst, <vscale x 2 x i64> %{{.*}}
64 ; CHECK-NEXT: %[[GLOAD:.*]] = call <vscale x 2 x double> @llvm.masked.gather.nxv2f64.nxv2p0(<vscale x 2 x ptr> %[[PTRS]], i32 8, <vscale x 2 x i1> %[[MASK]]
65 ; CHECK-NEXT: %[[VALS:.*]] = fadd <vscale x 2 x double> %[[GLOAD]],
66 ; CHECK-NEXT: call void @llvm.masked.scatter.nxv2f64.nxv2p0(<vscale x 2 x double> %[[VALS]], <vscale x 2 x ptr> %[[PTRS]], i32 8, <vscale x 2 x i1> %[[MASK]])
70 for.body: ; preds = %entry, %for.inc
71 %i.07 = phi i64 [ %inc, %for.inc ], [ 0, %entry ]
72 %arrayidx = getelementptr inbounds i64, ptr %cond, i64 %i.07
73 %0 = load i64, ptr %arrayidx, align 8
74 %tobool.not = icmp eq i64 %0, 0
75 br i1 %tobool.not, label %for.inc, label %if.then
77 if.then: ; preds = %for.body
78 %mul = mul nsw i64 %i.07, 7
79 %arrayidx1 = getelementptr inbounds double, ptr %dst, i64 %mul
80 %1 = load double, ptr %arrayidx1, align 8
81 %add = fadd double %1, 1.000000e+00
82 store double %add, ptr %arrayidx1, align 8
85 for.inc: ; preds = %for.body, %if.then
86 %inc = add nuw nsw i64 %i.07, 1
87 %exitcond.not = icmp eq i64 %inc, %n
88 br i1 %exitcond.not, label %for.end, label %for.body, !llvm.loop !6
90 for.end: ; preds = %for.end.loopexit, %entry
94 attributes #0 = { vscale_range(1, 16) }
95 !0 = distinct !{!0, !1, !2, !3, !4, !5}
96 !1 = !{!"llvm.loop.mustprogress"}
97 !2 = !{!"llvm.loop.vectorize.width", i32 4}
98 !3 = !{!"llvm.loop.vectorize.scalable.enable", i1 true}
99 !4 = !{!"llvm.loop.interleave.count", i32 1}
100 !5 = !{!"llvm.loop.vectorize.enable", i1 true}
101 !6 = distinct !{!6, !1, !7, !3, !4, !5}
102 !7 = !{!"llvm.loop.vectorize.width", i32 2}