1; RUN: opt -loop-vectorize -scalable-vectorization=on -force-target-instruction-cost=1 -dce -instcombine < %s -S | FileCheck %s 2 3target triple = "aarch64-linux-gnu" 4 5; Test a case where the vectorised induction variable is used to 6; generate a mask: 7; for (long long i = 0; i < n; i++) { 8; if (i & 0x1) 9; a[i] = b[i]; 10; } 11 12define void @cond_ind64(i32* noalias nocapture %a, i32* noalias nocapture readonly %b, i64 %n) #0 { 13; CHECK-LABEL: @cond_ind64( 14; CHECK: vector.body: 15; CHECK-NEXT: %[[INDEX:.*]] = phi i64 [ 0, %vector.ph ], [ %{{.*}}, %vector.body ] 16; CHECK: %[[STEPVEC:.*]] = call <vscale x 4 x i64> @llvm.experimental.stepvector.nxv4i64() 17; CHECK-NEXT: %[[TMP1:.*]] = insertelement <vscale x 4 x i64> poison, i64 %[[INDEX]], i32 0 18; CHECK-NEXT: %[[IDXSPLT:.*]] = shufflevector <vscale x 4 x i64> %[[TMP1]], <vscale x 4 x i64> poison, <vscale x 4 x i32> zeroinitializer 19; CHECK-NEXT: %[[VECIND:.*]] = add <vscale x 4 x i64> %[[IDXSPLT]], %[[STEPVEC]] 20; CHECK-NEXT: %[[MASK:.*]] = trunc <vscale x 4 x i64> %[[VECIND]] to <vscale x 4 x i1> 21; CHECK: %[[LOAD:.*]] = call <vscale x 4 x i32> @llvm.masked.load.nxv4i32.p0nxv4i32(<vscale x 4 x i32>* %{{.*}}, i32 4, <vscale x 4 x i1> %[[MASK]], <vscale x 4 x i32> poison) 22; CHECK: call void @llvm.masked.store.nxv4i32.p0nxv4i32(<vscale x 4 x i32> %[[LOAD]], <vscale x 4 x i32>* %{{.*}}, i32 4, <vscale x 4 x i1> %[[MASK]]) 23entry: 24 br label %for.body 25 26for.body: ; preds = %entry, %for.inc 27 %i.08 = phi i64 [ %inc, %for.inc ], [ 0, %entry ] 28 %and = and i64 %i.08, 1 29 %tobool.not = icmp eq i64 %and, 0 30 br i1 %tobool.not, label %for.inc, label %if.then 31 32if.then: ; preds = %for.body 33 %arrayidx = getelementptr inbounds i32, i32* %b, i64 %i.08 34 %0 = load i32, i32* %arrayidx, align 4 35 %arrayidx1 = getelementptr inbounds i32, i32* %a, i64 %i.08 36 store i32 %0, i32* %arrayidx1, align 4 37 br label %for.inc 38 39for.inc: ; preds = %for.body, %if.then 40 %inc = add nuw nsw i64 %i.08, 1 41 %exitcond.not = icmp eq i64 %inc, %n 42 br i1 %exitcond.not, label %exit, label %for.body, !llvm.loop !0 43 44exit: ; preds = %for.inc 45 ret void 46} 47 48attributes #0 = { "target-features"="+sve" } 49 50!0 = distinct !{!0, !1, !2, !3, !4, !5} 51!1 = !{!"llvm.loop.mustprogress"} 52!2 = !{!"llvm.loop.vectorize.scalable.enable", i1 true} 53!3 = !{!"llvm.loop.vectorize.enable", i1 true} 54!4 = !{!"llvm.loop.vectorize.width", i32 4} 55!5 = !{!"llvm.loop.interleave.count", i32 1} 56