[llvm] [LV] Avoid low-trip-count vectorization for countable early exits (PR #225635)
David Sherwood via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 23 01:25:39 PDT 2026
================
@@ -3090,7 +3090,8 @@ LoopVectorizationCostModel::computeMaxVF(ElementCount UserVF, unsigned UserIC) {
unsigned MaxVFForTC = llvm::bit_floor(TC.getFixedValue());
if (TC.getFixedValue() - MaxVFForTC <= 1 && MaxVFForTC / EffectiveIC > 1 &&
MaxVFForTC <= (MaxFactors.FixedVF.getFixedValue() * EffectiveIC) &&
- !Config.OptForSize) {
+ !Config.OptForSize &&
+ TheLoop->getExitingBlock() == TheLoop->getLoopLatch()) {
----------------
david-arm wrote:
As mentioned separately, this needs to be a stricter test to handle loops where there is a single exiting block (the latch) with combined exit conditions, that is an early exit. It's better to query the LoopVectorizationLegality function `hasUncountableEarlyExit` for an accurate answer.
https://github.com/llvm/llvm-project/pull/225635
More information about the llvm-commits
mailing list