Skip to content

Commit cacf91b

Browse files
committed
!fixup addres comments, thanks!
1 parent 31cee3e commit cacf91b

File tree

2 files changed

+16
-17
lines changed

2 files changed

+16
-17
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2444,19 +2444,20 @@ void InnerLoopVectorizer::emitIterationCountCheck(BasicBlock *Bypass) {
24442444
ScalarEvolution &SE = *PSE.getSE();
24452445
// TODO: Emit unconditional branch to vector preheader instead of
24462446
// conditional branch with known condition.
2447-
const SCEV *TripCountSCEV = SE.getSCEV(Count);
2447+
const SCEV *TripCountSCEV = SE.applyLoopGuards(SE.getSCEV(Count), OrigLoop);
24482448
// Check if the trip count is < the step.
2449-
if (SE.isKnownPredicate(P, SE.applyLoopGuards(TripCountSCEV, OrigLoop),
2450-
SE.getSCEV(Step))) {
2451-
// TODO: Should not attempt to vectorize when the vector loop is known to
2452-
// never execute.
2449+
if (SE.isKnownPredicate(P, TripCountSCEV, SE.getSCEV(Step))) {
2450+
// TODO: Ensure step is at most the trip count when determining max VF and
2451+
// UF, w/o tail folding.
24532452
CheckMinIters = Builder.getTrue();
24542453
} else if (!SE.isKnownPredicate(CmpInst::getInversePredicate(P),
2455-
SE.applyLoopGuards(TripCountSCEV, OrigLoop),
2456-
SE.getSCEV(Step))) {
2457-
// Only generate the minimum iteration check only if we cannot prove the
2458-
// check is known to be false.
2454+
TripCountSCEV, SE.getSCEV(Step))) {
2455+
// Generate the minimum iteration check only if we cannot prove the
2456+
// check is known to be true, or known to be false
24592457
CheckMinIters = Builder.CreateICmp(P, Count, Step, "min.iters.check");
2458+
2459+
// else step is known to be smaller than trip count, use CheckMinIters
2460+
// preset to false.
24602461
}
24612462
} else if (VF.isScalable() &&
24622463
!isIndvarOverflowCheckKnownFalse(Cost, VF, UF) &&
@@ -2473,12 +2474,11 @@ void InnerLoopVectorizer::emitIterationCountCheck(BasicBlock *Bypass) {
24732474
Value *Step = CreateStep();
24742475
ScalarEvolution &SE = *PSE.getSE();
24752476
// Check if we can prove that the trip count is >= the step.
2476-
// TODO: Emit unconditional branch to vector preheader instead of
2477-
// conditional branch with known condition.
2478-
const SCEV *TripCountSCEV = SE.getSCEV(LHS);
2479-
assert(!SE.isKnownPredicate(CmpInst::getInversePredicate(ICmpInst::ICMP_ULT),
2480-
SE.applyLoopGuards(TripCountSCEV, OrigLoop),
2481-
SE.getSCEV(Step)) && "SCEV unexpectedly proved overflow check to be known);
2477+
const SCEV *TripCountSCEV = SE.applyLoopGuards(SE.getSCEV(LHS), OrigLoop);
2478+
assert(
2479+
!SE.isKnownPredicate(CmpInst::getInversePredicate(ICmpInst::ICMP_ULT),
2480+
TripCountSCEV, SE.getSCEV(Step)) &&
2481+
"SCEV unexpectedly proved overflow check to be known");
24822482
// Don't execute the vector loop if (UMax - n) < (VF * UF).
24832483
CheckMinIters = Builder.CreateICmp(ICmpInst::ICMP_ULT, LHS, Step);
24842484
}

llvm/test/Transforms/LoopVectorize/version-stride-with-integer-casts.ll

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -488,8 +488,7 @@ define void @sext_of_i1_stride(i1 %g, ptr %dst) mustprogress {
488488
; CHECK-NEXT: [[TMP0:%.*]] = add i64 [[UMAX]], -1
489489
; CHECK-NEXT: [[TMP1:%.*]] = udiv i64 [[TMP0]], [[G_64]]
490490
; CHECK-NEXT: [[TMP2:%.*]] = add nuw nsw i64 [[TMP1]], 1
491-
; CHECK-NEXT: [[MIN_ITERS_CHECK:%.*]] = icmp ult i64 [[TMP2]], 4
492-
; CHECK-NEXT: br i1 [[MIN_ITERS_CHECK]], label [[SCALAR_PH:%.*]], label [[VECTOR_SCEVCHECK:%.*]]
491+
; CHECK-NEXT: br i1 true, label [[SCALAR_PH:%.*]], label [[VECTOR_SCEVCHECK:%.*]]
493492
; CHECK: vector.scevcheck:
494493
; CHECK-NEXT: [[IDENT_CHECK:%.*]] = icmp ne i1 [[G]], true
495494
; CHECK-NEXT: br i1 [[IDENT_CHECK]], label [[SCALAR_PH]], label [[VECTOR_PH:%.*]]

0 commit comments

Comments
 (0)