1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 20:51:52 +01:00

[VPlan] Reject loops without computable backedge taken counts

getOrCreateTripCount is used to generate code for the outer loop, but it
requires a computable backedge taken counts. Check that in the VPlan
native path.

Reviewers: Ayal, gilr, rengolin, sguggill

Reviewed By: sguggill

Differential Revision: https://reviews.llvm.org/D81088
This commit is contained in:
Florian Hahn 2020-06-12 10:16:03 +01:00
parent 45f938d43a
commit 90af54585b
2 changed files with 51 additions and 0 deletions

View File

@ -7640,6 +7640,10 @@ static bool processLoopInVPlanNativePath(
OptimizationRemarkEmitter *ORE, BlockFrequencyInfo *BFI,
ProfileSummaryInfo *PSI, LoopVectorizeHints &Hints) {
if (PSE.getBackedgeTakenCount() == PSE.getSE()->getCouldNotCompute()) {
LLVM_DEBUG(dbgs() << "LV: cannot compute the outer-loop trip count\n");
return false;
}
assert(EnableVPlanNativePath && "VPlan-native path is disabled.");
Function *F = L->getHeader()->getParent();
InterleavedAccessInfo IAI(PSE, L, DT, LI, LVL->getLAI());

View File

@ -0,0 +1,47 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -loop-vectorize -enable-vplan-native-path -S %s | FileCheck %s
declare i1 @cond()
; Make sure we do not vectorize (or crash) on outer loops with uncomputable
; trip-counts.
define void @test() {
; CHECK-LABEL: @test(
; CHECK-NEXT: entry:
; CHECK-NEXT: br label [[FOR1_HEADER:%.*]]
; CHECK: for1.header:
; CHECK-NEXT: br label [[FOR2_HEADER:%.*]]
; CHECK: for2.header:
; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ 0, [[FOR1_HEADER]] ], [ [[INDVARS_IV_NEXT:%.*]], [[FOR2_HEADER]] ]
; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nuw nsw i64 [[INDVARS_IV]], 1
; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i64 [[INDVARS_IV_NEXT]], 0
; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR1_LATCH:%.*]], label [[FOR2_HEADER]]
; CHECK: for1.latch:
; CHECK-NEXT: [[C:%.*]] = call i1 @cond()
; CHECK-NEXT: br i1 [[C]], label [[EXIT:%.*]], label [[FOR1_HEADER]], !llvm.loop !0
; CHECK: exit:
; CHECK-NEXT: ret void
;
entry:
br label %for1.header
for1.header: ; preds = %for.cond.cleanup3, %for.cond1.preheader.lr.ph
br label %for2.header
for2.header: ; preds = %for.body10, %for.body10.preheader
%indvars.iv = phi i64 [ 0, %for1.header ], [ %indvars.iv.next, %for2.header ]
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
%exitcond = icmp eq i64 %indvars.iv.next, 0
br i1 %exitcond, label %for1.latch, label %for2.header
for1.latch: ; preds = %for.cond.cleanup9
%c = call i1 @cond()
br i1 %c, label %exit, label %for1.header, !llvm.loop !0
exit: ; preds = %for.cond.cleanup3, %entry
ret void
}
!0 = distinct !{!0, !1}
!1 = !{!"llvm.loop.vectorize.enable", i1 true}