1 ; RUN: opt -S -passes=loop-vectorize -mattr=+sve -mtriple aarch64-linux-gnu \
2 ; RUN: -prefer-predicate-over-epilogue=scalar-epilogue < %s | FileCheck %s
4 define void @invariant_load(i64 %n, ptr noalias nocapture %a, ptr nocapture readonly %b) {
5 ; CHECK-LABEL: @invariant_load
6 ; CHECK: %[[GEP:.*]] = getelementptr inbounds i32, ptr %b, i64 42
8 ; CHECK: %[[INVLOAD:.*]] = load i32, ptr %[[GEP]]
9 ; CHECK-NEXT: %[[SPLATINS:.*]] = insertelement <vscale x 4 x i32> poison, i32 %[[INVLOAD]], i64 0
10 ; CHECK-NEXT: %[[SPLAT:.*]] = shufflevector <vscale x 4 x i32> %[[SPLATINS]], <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer
11 ; CHECK: %[[LOAD:.*]] = load <vscale x 4 x i32>, ptr
12 ; CHECK-NEXT: %[[ADD:.*]] = add nsw <vscale x 4 x i32> %[[SPLAT]], %[[LOAD]]
13 ; CHECK: store <vscale x 4 x i32> %[[ADD]], ptr
17 for.body: ; preds = %for.body.lr.ph, %for.body
18 %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]
19 %arrayidx = getelementptr inbounds i32, ptr %b, i64 42
20 %0 = load i32, ptr %arrayidx, align 4
21 %arrayidx1 = getelementptr inbounds i32, ptr %b, i64 %iv
22 %1 = load i32, ptr %arrayidx1, align 4
23 %add = add nsw i32 %0, %1
24 %arrayidx2 = getelementptr inbounds i32, ptr %a, i64 %iv
25 store i32 %add, ptr %arrayidx2, align 4
26 %iv.next = add nuw nsw i64 %iv, 1
27 %exitcond.not = icmp eq i64 %iv.next, %n
28 br i1 %exitcond.not, label %for.end, label %for.body, !llvm.loop !1
30 for.end: ; preds = %for.body
34 !1 = distinct !{!1, !2, !3, !4}
35 !2 = !{!"llvm.loop.vectorize.width", i32 4}
36 !3 = !{!"llvm.loop.interleave.count", i32 1}
37 !4 = !{!"llvm.loop.vectorize.scalable.enable", i1 true}