brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.1 KiB · 8123651 Raw
92 lines · plain
1; RUN: opt < %s -passes=loop-vectorize -S | FileCheck %s2; RUN: opt < %s -passes=loop-vectorize -prefer-predicate-over-epilogue=predicate-dont-vectorize -S | FileCheck %s3 4target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"5target triple = "aarch64-unknown-linux-gnu"6 7; The test predication_in_loop corresponds8; to the following function9;   for (long long i = 0; i < 1024; i++) {10;    if (cond[i])11;      a[i] /= b[i];12;  }13 14define void  @predication_in_loop(ptr %a, ptr %b, ptr %cond) #0 {15; CHECK-LABEL: @predication_in_loop16; CHECK:  sdiv <vscale x 4 x i32>17;18entry:19  br label %for.body20 21for.cond.cleanup:                                 ; preds = %for.inc, %entry22  ret void23 24for.body:                                         ; preds = %entry, %for.inc25  %i.09 = phi i64 [ %inc, %for.inc ], [ 0, %entry ]26  %arrayidx = getelementptr inbounds i32, ptr %cond, i64 %i.0927  %0 = load i32, ptr %arrayidx, align 428  %tobool.not = icmp eq i32 %0, 029  br i1 %tobool.not, label %for.inc, label %if.then30 31if.then:                                          ; preds = %for.body32  %arrayidx1 = getelementptr inbounds i32, ptr %b, i64 %i.0933  %1 = load i32, ptr %arrayidx1, align 434  %arrayidx2 = getelementptr inbounds i32, ptr %a, i64 %i.0935  %2 = load i32, ptr %arrayidx2, align 436  %div = sdiv i32 %2, %137  store i32 %div, ptr %arrayidx2, align 438  br label %for.inc39 40for.inc:                                          ; preds = %for.body, %if.then41  %inc = add nuw nsw i64 %i.09, 142  %exitcond.not = icmp eq i64 %inc, 102443  br i1 %exitcond.not, label %for.cond.cleanup, label %for.body, !llvm.loop !044}45 46 47;48; This test unpredicated_loop_predication_through_tailfolding corresponds49; to the following function50;   for (long long i = 0; i < 1024; i++) {51;      a[i] /= b[i];52;  }53 54; Scalarization not possible in the main loop when there is no predication and55; epilogue should not be able to allow scalarization56; otherwise it could  be able to vectorize, but will not because57; "Max legal vector width too small, scalable vectorization unfeasible.."58 59define void @unpredicated_loop_predication_through_tailfolding(ptr %a, ptr %b) #0 {60; CHECK-LABEL: @unpredicated_loop_predication_through_tailfolding61; CHECK-NOT:  sdiv <vscale x 4 x i32>62 63entry:64  br label %loop65 66loop:67  %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]68  %arrayidx = getelementptr inbounds i32, ptr %a, i64 %iv69  %0 = load i32, ptr %arrayidx, align 470  %arrayidx2 = getelementptr inbounds i32, ptr %b, i64 %iv71  %1 = load i32, ptr %arrayidx2, align 472  %sdiv = sdiv i32 %1, %073  %2 = add nuw nsw i64 %iv, 874  %arrayidx5 = getelementptr inbounds i32, ptr %a, i64 %275  store i32 %sdiv, ptr %arrayidx5, align 476  %iv.next = add nuw nsw i64 %iv, 177  %exitcond.not = icmp eq i64 %iv.next, 102478  br i1 %exitcond.not, label %exit, label %loop, !llvm.loop !079 80exit:81  ret void82 83}84 85attributes #0 = { "target-features"="+sve" }86 87!0 = distinct !{!0, !1, !2, !3, !4}88!1 = !{!"llvm.loop.vectorize.width", i32 4}89!2 = !{!"llvm.loop.vectorize.scalable.enable", i1 true}90!3 = !{!"llvm.loop.interleave.count", i32 1}91!4 = !{!"llvm.loop.vectorize.enable", i1 true}92