diff options
| author | Florian Hahn <flo@fhahn.com> | 2022-09-19 18:14:34 +0100 |
|---|---|---|
| committer | Tobias Hieta <tobias@hieta.se> | 2022-09-20 08:05:50 +0200 |
| commit | b73d2c8c720a8c8e6e73b11be4e27afa6cb75bdf (patch) | |
| tree | 5dae2a4815c55c2da1c80b36d5276bb1844c01ae /llvm/lib/Transforms/Vectorize/LoopVectorize.cpp | |
| parent | 38b5fa73d58576df84852c6bbf6d8219de69428b (diff) | |
[LV] Keep track of cost-based ScalarAfterVec in VPWidenPointerInd.llvmorg-15.0.1
Epilogue vectorization uses isScalarAfterVectorization to check if
widened versions for inductions need to be generated and bails out in
those cases.
At the moment, there are scenarios where isScalarAfterVectorization
returns true but VPWidenPointerInduction::onlyScalarsGenerated would
return false, causing widening.
This can lead to widened phis with incorrect start values being created
in the epilogue vector body.
This patch addresses the issue by storing the cost-model decision in
VPWidenPointerInductionRecipe and restoring the behavior before 151c144.
This effectively reverts 151c144, but the long-term fix is to properly
support widened inductions during epilogue vectorization
Fixes #57712.
Diffstat (limited to 'llvm/lib/Transforms/Vectorize/LoopVectorize.cpp')
| -rw-r--r-- | llvm/lib/Transforms/Vectorize/LoopVectorize.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp index 91bc7dbad1d0..2cdae028ec7d 100644 --- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp +++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp @@ -8149,9 +8149,15 @@ VPRecipeBase *VPRecipeBuilder::tryToOptimizeInductionPHI( *PSE.getSE(), *OrigLoop, Range); // Check if this is pointer induction. If so, build the recipe for it. - if (auto *II = Legal->getPointerInductionDescriptor(Phi)) - return new VPWidenPointerInductionRecipe(Phi, Operands[0], *II, - *PSE.getSE()); + if (auto *II = Legal->getPointerInductionDescriptor(Phi)) { + return new VPWidenPointerInductionRecipe( + Phi, Operands[0], *II, *PSE.getSE(), + LoopVectorizationPlanner::getDecisionAndClampRange( + [&](ElementCount VF) { + return !VF.isScalable() && CM.isScalarAfterVectorization(Phi, VF); + }, + Range)); + } return nullptr; } @@ -9332,7 +9338,7 @@ void VPWidenPointerInductionRecipe::execute(VPTransformState &State) { auto *IVR = getParent()->getPlan()->getCanonicalIV(); PHINode *CanonicalIV = cast<PHINode>(State.get(IVR, 0)); - if (onlyScalarsGenerated(State.VF)) { + if (onlyScalarsGenerated()) { // This is the normalized GEP that starts counting at zero. Value *PtrInd = State.Builder.CreateSExtOrTrunc( CanonicalIV, IndDesc.getStep()->getType()); |
