1*ceb6c23bSDavid Sherwood; RUN: opt -loop-vectorize -dce -instcombine -mtriple aarch64-linux-gnu -mattr=+sve \ 2*ceb6c23bSDavid Sherwood; RUN: -prefer-predicate-over-epilogue=scalar-epilogue < %s -S | FileCheck %s 32e080eb0SDavid Sherwood 42e080eb0SDavid Sherwood 52e080eb0SDavid Sherwoodtarget datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128" 62e080eb0SDavid Sherwoodtarget triple = "aarch64-unknown-linux-gnu" 72e080eb0SDavid Sherwood 82e080eb0SDavid Sherwooddefine void @cmpsel_i32(i32* noalias nocapture %a, i32* noalias nocapture readonly %b, i64 %n) { 92e080eb0SDavid Sherwood; CHECK-LABEL: @cmpsel_i32( 102e080eb0SDavid Sherwood; CHECK-NEXT: entry: 112e080eb0SDavid Sherwood; CHECK: vector.body: 12872f7000SDávid Bolvanský; CHECK: [[WIDE_LOAD:%.*]] = load <vscale x 4 x i32>, <vscale x 4 x i32>* {{.*}}, align 4 13872f7000SDávid Bolvanský; CHECK-NEXT: [[TMP1:%.*]] = icmp eq <vscale x 4 x i32> [[WIDE_LOAD]], zeroinitializer 14872f7000SDávid Bolvanský; CHECK-NEXT: [[TMP2:%.*]] = select <vscale x 4 x i1> [[TMP1]], <vscale x 4 x i32> shufflevector (<vscale x 4 x i32> insertelement (<vscale x 4 x i32> poison, i32 2, i32 0), <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer), <vscale x 4 x i32> shufflevector (<vscale x 4 x i32> insertelement (<vscale x 4 x i32> poison, i32 10, i32 0), <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer) 15872f7000SDávid Bolvanský; CHECK: store <vscale x 4 x i32> [[TMP2]], <vscale x 4 x i32>* {{.*}}, align 4 162e080eb0SDavid Sherwood; 172e080eb0SDavid Sherwoodentry: 1800e65f33SDavid Sherwood br label %for.body 192e080eb0SDavid Sherwood 202e080eb0SDavid Sherwoodfor.body: ; preds = %entry, %for.body 212e080eb0SDavid Sherwood %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ] 222e080eb0SDavid Sherwood %arrayidx = getelementptr inbounds i32, i32* %b, i64 %indvars.iv 232e080eb0SDavid Sherwood %0 = load i32, i32* %arrayidx, align 4 242e080eb0SDavid Sherwood %tobool.not = icmp eq i32 %0, 0 252e080eb0SDavid Sherwood %cond = select i1 %tobool.not, i32 2, i32 10 262e080eb0SDavid Sherwood %arrayidx2 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv 272e080eb0SDavid Sherwood store i32 %cond, i32* %arrayidx2, align 4 282e080eb0SDavid Sherwood %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1 292e080eb0SDavid Sherwood %exitcond.not = icmp eq i64 %indvars.iv.next, %n 302e080eb0SDavid Sherwood br i1 %exitcond.not, label %for.end.loopexit, label %for.body, !llvm.loop !0 312e080eb0SDavid Sherwood 322e080eb0SDavid Sherwoodfor.end.loopexit: ; preds = %for.body 332e080eb0SDavid Sherwood br label %for.end 342e080eb0SDavid Sherwood 352e080eb0SDavid Sherwoodfor.end: ; preds = %for.end.loopexit, %entry 362e080eb0SDavid Sherwood ret void 372e080eb0SDavid Sherwood} 382e080eb0SDavid Sherwood 392e080eb0SDavid Sherwooddefine void @cmpsel_f32(float* noalias nocapture %a, float* noalias nocapture readonly %b, i64 %n) { 402e080eb0SDavid Sherwood; CHECK-LABEL: @cmpsel_f32( 412e080eb0SDavid Sherwood; CHECK-NEXT: entry: 422e080eb0SDavid Sherwood; CHECK: vector.body: 43872f7000SDávid Bolvanský; CHECK: [[WIDE_LOAD:%.*]] = load <vscale x 4 x float>, <vscale x 4 x float>* {{.*}}, align 4 44872f7000SDávid Bolvanský; CHECK-NEXT: [[TMP1:%.*]] = fcmp ogt <vscale x 4 x float> [[WIDE_LOAD]], shufflevector (<vscale x 4 x float> insertelement (<vscale x 4 x float> poison, float 3.000000e+00, i32 0), <vscale x 4 x float> poison, <vscale x 4 x i32> zeroinitializer) 45872f7000SDávid Bolvanský; CHECK-NEXT: [[TMP2:%.*]] = select <vscale x 4 x i1> [[TMP1]], <vscale x 4 x float> shufflevector (<vscale x 4 x float> insertelement (<vscale x 4 x float> poison, float 1.000000e+01, i32 0), <vscale x 4 x float> poison, <vscale x 4 x i32> zeroinitializer), <vscale x 4 x float> shufflevector (<vscale x 4 x float> insertelement (<vscale x 4 x float> poison, float 2.000000e+00, i32 0), <vscale x 4 x float> poison, <vscale x 4 x i32> zeroinitializer) 46872f7000SDávid Bolvanský; CHECK: store <vscale x 4 x float> [[TMP2]], <vscale x 4 x float>* {{.*}}, align 4 472e080eb0SDavid Sherwood 482e080eb0SDavid Sherwoodentry: 4900e65f33SDavid Sherwood br label %for.body 502e080eb0SDavid Sherwood 512e080eb0SDavid Sherwoodfor.body: ; preds = %entry, %for.body 522e080eb0SDavid Sherwood %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ] 532e080eb0SDavid Sherwood %arrayidx = getelementptr inbounds float, float* %b, i64 %indvars.iv 542e080eb0SDavid Sherwood %0 = load float, float* %arrayidx, align 4 552e080eb0SDavid Sherwood %cmp1 = fcmp ogt float %0, 3.000000e+00 562e080eb0SDavid Sherwood %conv = select i1 %cmp1, float 1.000000e+01, float 2.000000e+00 572e080eb0SDavid Sherwood %arrayidx3 = getelementptr inbounds float, float* %a, i64 %indvars.iv 582e080eb0SDavid Sherwood store float %conv, float* %arrayidx3, align 4 592e080eb0SDavid Sherwood %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1 602e080eb0SDavid Sherwood %exitcond.not = icmp eq i64 %indvars.iv.next, %n 6100e65f33SDavid Sherwood br i1 %exitcond.not, label %for.end, label %for.body, !llvm.loop !0 6200e65f33SDavid Sherwood 6300e65f33SDavid Sherwoodfor.end: ; preds = %for.body, %entry 6400e65f33SDavid Sherwood ret void 6500e65f33SDavid Sherwood} 6600e65f33SDavid Sherwood 6700e65f33SDavid Sherwooddefine void @fneg_f32(float* noalias nocapture %a, float* noalias nocapture readonly %b, i64 %n) { 6800e65f33SDavid Sherwood; CHECK-LABEL: @fneg_f32( 6900e65f33SDavid Sherwood; CHECK-NEXT: entry: 7000e65f33SDavid Sherwood; CHECK: vector.body: 71872f7000SDávid Bolvanský; CHECK: [[WIDE_LOAD:%.*]] = load <vscale x 4 x float>, <vscale x 4 x float>* {{.*}}, align 4 72872f7000SDávid Bolvanský; CHECK-NEXT: [[TMP1:%.*]] = fneg <vscale x 4 x float> [[WIDE_LOAD]] 73872f7000SDávid Bolvanský; CHECK: store <vscale x 4 x float> [[TMP1]], <vscale x 4 x float>* {{.*}}, align 4 7400e65f33SDavid Sherwood 7500e65f33SDavid Sherwoodentry: 7600e65f33SDavid Sherwood br label %for.body 7700e65f33SDavid Sherwood 7800e65f33SDavid Sherwoodfor.body: ; preds = %entry, %for.body 7900e65f33SDavid Sherwood %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ] 8000e65f33SDavid Sherwood %arrayidx = getelementptr inbounds float, float* %b, i64 %indvars.iv 8100e65f33SDavid Sherwood %0 = load float, float* %arrayidx, align 4 8200e65f33SDavid Sherwood %fneg = fneg float %0 8300e65f33SDavid Sherwood %arrayidx3 = getelementptr inbounds float, float* %a, i64 %indvars.iv 8400e65f33SDavid Sherwood store float %fneg, float* %arrayidx3, align 4 8500e65f33SDavid Sherwood %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1 8600e65f33SDavid Sherwood %exitcond.not = icmp eq i64 %indvars.iv.next, %n 8700e65f33SDavid Sherwood br i1 %exitcond.not, label %for.end, label %for.body, !llvm.loop !0 882e080eb0SDavid Sherwood 892e080eb0SDavid Sherwoodfor.end: ; preds = %for.body, %entry 902e080eb0SDavid Sherwood ret void 912e080eb0SDavid Sherwood} 922e080eb0SDavid Sherwood 932e080eb0SDavid Sherwood!0 = distinct !{!0, !1, !2, !3, !4, !5} 942e080eb0SDavid Sherwood!1 = !{!"llvm.loop.mustprogress"} 952e080eb0SDavid Sherwood!2 = !{!"llvm.loop.vectorize.width", i32 4} 962e080eb0SDavid Sherwood!3 = !{!"llvm.loop.vectorize.scalable.enable", i1 true} 972e080eb0SDavid Sherwood!4 = !{!"llvm.loop.interleave.count", i32 1} 982e080eb0SDavid Sherwood!5 = !{!"llvm.loop.vectorize.enable", i1 true} 99