1 ; RUN: opt -passes=loop-vectorize,dce,instcombine -mtriple aarch64-linux-gnu -mattr=+sve \
2 ; RUN: -prefer-predicate-over-epilogue=scalar-epilogue -S %s -o - | FileCheck %s
4 define void @mloadstore_f32(ptr noalias nocapture %a, ptr noalias nocapture readonly %b, i64 %n) {
5 ; CHECK-LABEL: @mloadstore_f32
7 ; CHECK: %[[LOAD1:.*]] = load <vscale x 4 x float>, ptr
8 ; CHECK-NEXT: %[[MASK:.*]] = fcmp ogt <vscale x 4 x float> %[[LOAD1]],
9 ; CHECK-NEXT: %[[GEPA:.*]] = getelementptr float, ptr %a,
10 ; CHECK-NEXT: %[[LOAD2:.*]] = call <vscale x 4 x float> @llvm.masked.load.nxv4f32.p0(ptr %[[GEPA]], i32 4, <vscale x 4 x i1> %[[MASK]]
11 ; CHECK-NEXT: %[[FADD:.*]] = fadd <vscale x 4 x float> %[[LOAD1]], %[[LOAD2]]
12 ; CHECK-NEXT: call void @llvm.masked.store.nxv4f32.p0(<vscale x 4 x float> %[[FADD]], ptr %[[GEPA]], i32 4, <vscale x 4 x i1> %[[MASK]])
16 for.body: ; preds = %entry, %for.inc
17 %i.011 = phi i64 [ %inc, %for.inc ], [ 0, %entry ]
18 %arrayidx = getelementptr inbounds float, ptr %b, i64 %i.011
19 %0 = load float, ptr %arrayidx, align 4
20 %cmp1 = fcmp ogt float %0, 0.000000e+00
21 br i1 %cmp1, label %if.then, label %for.inc
23 if.then: ; preds = %for.body
24 %arrayidx3 = getelementptr inbounds float, ptr %a, i64 %i.011
25 %1 = load float, ptr %arrayidx3, align 4
26 %add = fadd float %0, %1
27 store float %add, ptr %arrayidx3, align 4
30 for.inc: ; preds = %for.body, %if.then
31 %inc = add nuw nsw i64 %i.011, 1
32 %exitcond.not = icmp eq i64 %inc, %n
33 br i1 %exitcond.not, label %exit, label %for.body, !llvm.loop !0
35 exit: ; preds = %for.inc
39 define void @mloadstore_i32(ptr noalias nocapture %a, ptr noalias nocapture readonly %b, i64 %n) {
40 ; CHECK-LABEL: @mloadstore_i32
42 ; CHECK: %[[LOAD1:.*]] = load <vscale x 4 x i32>, ptr
43 ; CHECK-NEXT: %[[MASK:.*]] = icmp ne <vscale x 4 x i32> %[[LOAD1]],
44 ; CHECK-NEXT: %[[GEPA:.*]] = getelementptr i32, ptr %a,
45 ; CHECK-NEXT: %[[LOAD2:.*]] = call <vscale x 4 x i32> @llvm.masked.load.nxv4i32.p0(ptr %[[GEPA]], i32 4, <vscale x 4 x i1> %[[MASK]]
46 ; CHECK-NEXT: %[[FADD:.*]] = add <vscale x 4 x i32> %[[LOAD1]], %[[LOAD2]]
47 ; CHECK-NEXT: call void @llvm.masked.store.nxv4i32.p0(<vscale x 4 x i32> %[[FADD]], ptr %[[GEPA]], i32 4, <vscale x 4 x i1> %[[MASK]])
51 for.body: ; preds = %entry, %for.inc
52 %i.011 = phi i64 [ %inc, %for.inc ], [ 0, %entry ]
53 %arrayidx = getelementptr inbounds i32, ptr %b, i64 %i.011
54 %0 = load i32, ptr %arrayidx, align 4
55 %cmp1 = icmp ne i32 %0, 0
56 br i1 %cmp1, label %if.then, label %for.inc
58 if.then: ; preds = %for.body
59 %arrayidx3 = getelementptr inbounds i32, ptr %a, i64 %i.011
60 %1 = load i32, ptr %arrayidx3, align 4
62 store i32 %add, ptr %arrayidx3, align 4
65 for.inc: ; preds = %for.body, %if.then
66 %inc = add nuw nsw i64 %i.011, 1
67 %exitcond.not = icmp eq i64 %inc, %n
68 br i1 %exitcond.not, label %exit, label %for.body, !llvm.loop !0
70 exit: ; preds = %for.inc
74 !0 = distinct !{!0, !1, !2, !3, !4, !5}
75 !1 = !{!"llvm.loop.mustprogress"}
76 !2 = !{!"llvm.loop.vectorize.width", i32 4}
77 !3 = !{!"llvm.loop.vectorize.scalable.enable", i1 true}
78 !4 = !{!"llvm.loop.interleave.count", i32 1}
79 !5 = !{!"llvm.loop.vectorize.enable", i1 true}