[llvm] [LV]Fix/improve max safe distance analysis (PR #121156)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 6 12:10:44 PST 2025
================
@@ -4016,11 +4032,15 @@ FixedScalableVFPair LoopVectorizationCostModel::computeFeasibleMaxVF(
// It is computed by MaxVF * sizeOf(type) * 8, where type is taken from
// the memory accesses that is most restrictive (involved in the smallest
// dependence distance).
- unsigned MaxSafeElements =
- llvm::bit_floor(Legal->getMaxSafeVectorWidthInBits() / WidestType);
+ unsigned MaxSafeElements = Legal->getMaxSafeVectorWidthInBits() / WidestType;
+ if (Legal->isSafeForAnyVectorWidth())
+ MaxSafeElements = bit_ceil(MaxSafeElements);
+ unsigned MaxSafeElementsPowerOf2 = bit_floor(std::gcd(
+ MaxSafeElements, Legal->getMaxStoreLoadForwardSafeVFPowerOf2().value_or(
+ 1ULL << countr_zero(MaxSafeElements))));
+ auto MaxSafeFixedVF = ElementCount::getFixed(MaxSafeElementsPowerOf2);
+ auto MaxSafeScalableVF = getMaxLegalScalableVF(MaxSafeElementsPowerOf2);
----------------
fhahn wrote:
Is this the main functional change here? Would it be possible to split this off from the various renaming that are also included in the patch?
The other parts of the patch dealing with `TailFoldPowOf2` are needed for EVL? Should there be some EVL test cases with changes?
https://github.com/llvm/llvm-project/pull/121156
More information about the llvm-commits
mailing list