1; RUN: opt -passes=loop-vectorize -debug-only=loop-vectorize -enable-arm-maskedgatscat -tail-predication=force-enabled -disable-output < %s 2>&1 | FileCheck %s --check-prefixes=CHECK-COST,CHECK-COST-2 2; REQUIRES: asserts 3 4target datalayout = "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64" 5target triple = "thumbv8.1m.main-none-none-eabi" 6 7define void @pred_loop(ptr %off, ptr %data, ptr %dst, i32 %n) #0 { 8 9; CHECK-COST: LV: Found an estimated cost of 0 for VF 1 For instruction: %i.09 = phi i32 [ %add, %for.body ], [ 0, %for.body.preheader ] 10; CHECK-COST-NEXT: LV: Found an estimated cost of 1 for VF 1 For instruction: %add = add nuw nsw i32 %i.09, 1 11; CHECK-COST-NEXT: LV: Found an estimated cost of 0 for VF 1 For instruction: %arrayidx = getelementptr inbounds i32, ptr %data, i32 %add 12; CHECK-COST-NEXT: LV: Found an estimated cost of 1 for VF 1 For instruction: %0 = load i32, ptr %arrayidx, align 4 13; CHECK-COST-NEXT: LV: Found an estimated cost of 1 for VF 1 For instruction: %add1 = add nsw i32 %0, 5 14; CHECK-COST-NEXT: LV: Found an estimated cost of 0 for VF 1 For instruction: %arrayidx2 = getelementptr inbounds i32, ptr %dst, i32 %i.09 15; CHECK-COST-NEXT: LV: Found an estimated cost of 1 for VF 1 For instruction: store i32 %add1, ptr %arrayidx2, align 4 16; CHECK-COST-NEXT: LV: Found an estimated cost of 1 for VF 1 For instruction: %exitcond.not = icmp eq i32 %add, %n 17; CHECK-COST-NEXT: LV: Found an estimated cost of 0 for VF 1 For instruction: br i1 %exitcond.not, label %exit.loopexit, label %for.body 18; CHECK-COST-NEXT: LV: Scalar loop costs: 5. 19 20entry: 21 %cmp8 = icmp sgt i32 %n, 0 22 br i1 %cmp8, label %for.body, label %exit 23 24exit: ; preds = %for.body, %entry 25 ret void 26 27for.body: ; preds = %entry, %for.body 28 %i.09 = phi i32 [ %add, %for.body ], [ 0, %entry ] 29 %add = add nuw nsw i32 %i.09, 1 30 %arrayidx = getelementptr inbounds i32, ptr %data, i32 %add 31 %0 = load i32, ptr %arrayidx, align 4 32 %add1 = add nsw i32 %0, 5 33 %arrayidx2 = getelementptr inbounds i32, ptr %dst, i32 %i.09 34 store i32 %add1, ptr %arrayidx2, align 4 35 %exitcond.not = icmp eq i32 %add, %n 36 br i1 %exitcond.not, label %exit, label %for.body 37} 38 39define i32 @if_convert(ptr %a, ptr %b, i32 %start, i32 %end) #0 { 40 41; CHECK-COST-2: LV: Found an estimated cost of 0 for VF 1 For instruction: %i.032 = phi i32 [ %inc, %if.end ], [ %start, %for.body.preheader ] 42; CHECK-COST-2-NEXT: LV: Found an estimated cost of 0 for VF 1 For instruction: %arrayidx = getelementptr inbounds i32, ptr %a, i32 %i.032 43; CHECK-COST-2-NEXT: LV: Found an estimated cost of 1 for VF 1 For instruction: %0 = load i32, ptr %arrayidx, align 4 44; CHECK-COST-2-NEXT: LV: Found an estimated cost of 0 for VF 1 For instruction: %arrayidx2 = getelementptr inbounds i32, ptr %b, i32 %i.032 45; CHECK-COST-2-NEXT: LV: Found an estimated cost of 1 for VF 1 For instruction: %1 = load i32, ptr %arrayidx2, align 4 46; CHECK-COST-2-NEXT: LV: Found an estimated cost of 1 for VF 1 For instruction: %cmp3 = icmp sgt i32 %0, %1 47; CHECK-COST-2-NEXT: LV: Found an estimated cost of 0 for VF 1 For instruction: br i1 %cmp3, label %if.then, label %if.end 48; CHECK-COST-2-NEXT: LV: Found an estimated cost of 1 for VF 1 For instruction: %mul = mul nsw i32 %0, 5 49; CHECK-COST-2-NEXT: LV: Found an estimated cost of 1 for VF 1 For instruction: %add = add nsw i32 %mul, 3 50; CHECK-COST-2-NEXT: LV: Found an estimated cost of 0 for VF 1 For instruction: %factor = shl i32 %add, 1 51; CHECK-COST-2-NEXT: LV: Found an estimated cost of 1 for VF 1 For instruction: %sub = sub i32 %0, %1 52; CHECK-COST-2-NEXT: LV: Found an estimated cost of 1 for VF 1 For instruction: %add7 = add i32 %sub, %factor 53; CHECK-COST-2-NEXT: LV: Found an estimated cost of 1 for VF 1 For instruction: store i32 %add7, ptr %arrayidx2, align 4 54; CHECK-COST-2-NEXT: LV: Found an estimated cost of 0 for VF 1 For instruction: br label %if.end 55; CHECK-COST-2-NEXT: LV: Found an estimated cost of 0 for VF 1 For instruction: %k.0 = phi i32 [ %add, %if.then ], [ %0, %for.body ] 56; CHECK-COST-2-NEXT: LV: Found an estimated cost of 1 for VF 1 For instruction: store i32 %k.0, ptr %arrayidx, align 4 57; CHECK-COST-2-NEXT: LV: Found an estimated cost of 1 for VF 1 For instruction: %inc = add nsw i32 %i.032, 1 58; CHECK-COST-2-NEXT: LV: Found an estimated cost of 1 for VF 1 For instruction: %exitcond.not = icmp eq i32 %inc, %end 59; CHECK-COST-2-NEXT: LV: Found an estimated cost of 0 for VF 1 For instruction: br i1 %exitcond.not, label %for.cond.cleanup.loopexit, label %for.body 60; CHECK-COST-2-NEXT: LV: Scalar loop costs: 8. 61 62entry: 63 %cmp31 = icmp slt i32 %start, %end 64 br i1 %cmp31, label %for.body.preheader, label %for.cond.cleanup 65 66for.body.preheader: ; preds = %entry 67 br label %for.body 68 69for.cond.cleanup.loopexit: ; preds = %if.end 70 br label %for.cond.cleanup 71 72for.cond.cleanup: ; preds = %for.cond.cleanup.loopexit, %entry 73 ret i32 undef 74 75for.body: ; preds = %for.body.preheader, %if.end 76 %i.032 = phi i32 [ %inc, %if.end ], [ %start, %for.body.preheader ] 77 %arrayidx = getelementptr inbounds i32, ptr %a, i32 %i.032 78 %0 = load i32, ptr %arrayidx, align 4 79 %arrayidx2 = getelementptr inbounds i32, ptr %b, i32 %i.032 80 %1 = load i32, ptr %arrayidx2, align 4 81 %cmp3 = icmp sgt i32 %0, %1 82 br i1 %cmp3, label %if.then, label %if.end 83 84if.then: ; preds = %for.body 85 %mul = mul nsw i32 %0, 5 86 %add = add nsw i32 %mul, 3 87 %factor = shl i32 %add, 1 88 %sub = sub i32 %0, %1 89 %add7 = add i32 %sub, %factor 90 store i32 %add7, ptr %arrayidx2, align 4 91 br label %if.end 92 93if.end: ; preds = %if.then, %for.body 94 %k.0 = phi i32 [ %add, %if.then ], [ %0, %for.body ] 95 store i32 %k.0, ptr %arrayidx, align 4 96 %inc = add nsw i32 %i.032, 1 97 %exitcond.not = icmp eq i32 %inc, %end 98 br i1 %exitcond.not, label %for.cond.cleanup.loopexit, label %for.body 99} 100 101attributes #0 = { "target-features"="+armv8.1-m.main,+dsp,+fp-armv8d16sp,+fp16,+fullfp16,+hwdiv,+lob,+mve,+mve.fp,+ras,+strict-align,+thumb-mode,+vfp2sp,+vfp3d16sp,+vfp4d16sp"} 102