Skip to content

Commit d4351da

Browse files
committed
Switch to an assert
1 parent 1162704 commit d4351da

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2434,20 +2434,14 @@ Value *InnerLoopVectorizer::createIterationCountCheck(ElementCount VF,
24342434
// check is known to be true, or known to be false.
24352435
CheckMinIters = Builder.CreateICmp(P, Count, Step, "min.iters.check");
24362436
} // else step known to be < trip count, use CheckMinIters preset to false.
2437-
} else if (VF.isScalable() && !TTI->isVScaleKnownToBeAPowerOfTwo() &&
2438-
!isIndvarOverflowCheckKnownFalse(Cost, VF, UF) &&
2439-
Style != TailFoldingStyle::DataAndControlFlowWithoutRuntimeCheck) {
2440-
// vscale is not necessarily a power-of-2, which means we cannot guarantee
2441-
// an overflow to zero when updating induction variables and so an
2442-
// additional overflow check is required before entering the vector loop.
2443-
2444-
// Get the maximum unsigned value for the type.
2445-
Value *MaxUIntTripCount =
2446-
ConstantInt::get(CountTy, cast<IntegerType>(CountTy)->getMask());
2447-
Value *LHS = Builder.CreateSub(MaxUIntTripCount, Count);
2448-
2449-
// Don't execute the vector loop if (UMax - n) < (VF * UF).
2450-
CheckMinIters = Builder.CreateICmp(ICmpInst::ICMP_ULT, LHS, CreateStep());
2437+
} else {
2438+
// If we're tail folding, then as long as our VF is a factor of two
2439+
// we'll wrap to zero and don't need an explicit iterations check.
2440+
// Per the LangRef, vscale is not necessarily a power-of-2, but all
2441+
// in tree targets are
2442+
assert(VF.isKnownMultipleOf(2) ||
2443+
(!VF.isScalable() && 1 == VF.getKnownMinValue()) ||
2444+
(VF.isScalable() && TTI->isVScaleKnownToBeAPowerOfTwo()));
24512445
}
24522446
return CheckMinIters;
24532447
}

0 commit comments

Comments
 (0)