1; RUN: opt -S -loop-vectorize -force-vector-interleave=1 -instcombine -mattr=+sve -mtriple aarch64-unknown-linux-gnu < %s | FileCheck %s 2 3define void @vec_load(i64 %N, double* nocapture %a, double* nocapture readonly %b) { 4; CHECK-LABEL: @vec_load 5; CHECK: vector.body: 6; CHECK: %[[LOAD:.*]] = load <vscale x 2 x double>, <vscale x 2 x double>* 7; CHECK: call <vscale x 2 x double> @foo_vec(<vscale x 2 x double> %[[LOAD]]) 8entry: 9 %cmp7 = icmp sgt i64 %N, 0 10 br i1 %cmp7, label %for.body, label %for.end 11 12for.body: ; preds = %for.body.preheader, %for.body 13 %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ] 14 %arrayidx = getelementptr inbounds double, double* %b, i64 %iv 15 %0 = load double, double* %arrayidx, align 8 16 %1 = call double @foo(double %0) #0 17 %add = fadd double %1, 1.000000e+00 18 %arrayidx2 = getelementptr inbounds double, double* %a, i64 %iv 19 store double %add, double* %arrayidx2, align 8 20 %iv.next = add nuw nsw i64 %iv, 1 21 %exitcond.not = icmp eq i64 %iv.next, %N 22 br i1 %exitcond.not, label %for.end, label %for.body, !llvm.loop !1 23 24for.end: ; preds = %for.body, %entry 25 ret void 26} 27 28define void @vec_scalar(i64 %N, double* nocapture %a) { 29; CHECK-LABEL: @vec_scalar 30; CHECK: vector.body: 31; CHECK: call <vscale x 2 x double> @foo_vec(<vscale x 2 x double> shufflevector (<vscale x 2 x double> insertelement (<vscale x 2 x double> poison, double 1.000000e+01, i32 0), <vscale x 2 x double> poison, <vscale x 2 x i32> zeroinitializer)) 32entry: 33 %cmp7 = icmp sgt i64 %N, 0 34 br i1 %cmp7, label %for.body, label %for.end 35 36for.body: ; preds = %for.body.preheader, %for.body 37 %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ] 38 %0 = call double @foo(double 10.0) #0 39 %sub = fsub double %0, 1.000000e+00 40 %arrayidx = getelementptr inbounds double, double* %a, i64 %iv 41 store double %sub, double* %arrayidx, align 8 42 %iv.next = add nuw nsw i64 %iv, 1 43 %exitcond.not = icmp eq i64 %iv.next, %N 44 br i1 %exitcond.not, label %for.end, label %for.body, !llvm.loop !1 45 46for.end: ; preds = %for.body, %entry 47 ret void 48} 49 50define void @vec_ptr(i64 %N, i64* noalias %a, i64** readnone %b) { 51; CHECK-LABEL: @vec_ptr 52; CHECK: vector.body: 53; CHECK: %[[LOAD:.*]] = load <vscale x 2 x i64*>, <vscale x 2 x i64*>* 54; CHECK: call <vscale x 2 x i64> @bar_vec(<vscale x 2 x i64*> %[[LOAD]]) 55entry: 56 %cmp7 = icmp sgt i64 %N, 0 57 br i1 %cmp7, label %for.body, label %for.end 58 59for.body: 60 %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ] 61 %gep = getelementptr i64*, i64** %b, i64 %iv 62 %load = load i64*, i64** %gep 63 %call = call i64 @bar(i64* %load) #1 64 %arrayidx = getelementptr inbounds i64, i64* %a, i64 %iv 65 store i64 %call, i64* %arrayidx 66 %iv.next = add nuw nsw i64 %iv, 1 67 %exitcond = icmp eq i64 %iv.next, 1024 68 br i1 %exitcond, label %for.end, label %for.body, !llvm.loop !1 69 70for.end: 71 ret void 72} 73 74define void @vec_intrinsic(i64 %N, double* nocapture readonly %a) { 75; CHECK-LABEL: @vec_intrinsic 76; CHECK: vector.body: 77; CHECK: %[[LOAD:.*]] = load <vscale x 2 x double>, <vscale x 2 x double>* 78; CHECK: call fast <vscale x 2 x double> @sin_vec(<vscale x 2 x double> %[[LOAD]]) 79entry: 80 %cmp7 = icmp sgt i64 %N, 0 81 br i1 %cmp7, label %for.body, label %for.end 82 83for.body: 84 %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ] 85 %arrayidx = getelementptr inbounds double, double* %a, i64 %iv 86 %0 = load double, double* %arrayidx, align 8 87 %1 = call fast double @llvm.sin.f64(double %0) #2 88 %add = fadd fast double %1, 1.000000e+00 89 %iv.next = add nuw nsw i64 %iv, 1 90 %exitcond = icmp eq i64 %iv.next, %N 91 br i1 %exitcond, label %for.end, label %for.body, !llvm.loop !1 92 93for.end: 94 ret void 95} 96 97declare double @foo(double) 98declare i64 @bar(i64*) 99declare double @llvm.sin.f64(double) 100 101declare <vscale x 2 x double> @foo_vec(<vscale x 2 x double>) 102declare <vscale x 2 x i64> @bar_vec(<vscale x 2 x i64*>) 103declare <vscale x 2 x double> @sin_vec(<vscale x 2 x double>) 104 105attributes #0 = { "vector-function-abi-variant"="_ZGV_LLVM_Nxv_foo(foo_vec)" } 106attributes #1 = { "vector-function-abi-variant"="_ZGV_LLVM_Nxv_bar(bar_vec)" } 107attributes #2 = { "vector-function-abi-variant"="_ZGV_LLVM_Nxv_llvm.sin.f64(sin_vec)" } 108 109!1 = distinct !{!1, !2, !3} 110!2 = !{!"llvm.loop.vectorize.width", i32 2} 111!3 = !{!"llvm.loop.vectorize.scalable.enable", i1 true} 112