[LV] Keep track of cost-based ScalarAfterVec in VPWidenPointerInd.
authorFlorian Hahn <flo@fhahn.com>
Mon, 19 Sep 2022 17:14:34 +0000 (18:14 +0100)
committerTobias Hieta <tobias@hieta.se>
Tue, 20 Sep 2022 06:05:50 +0000 (08:05 +0200)
commitb73d2c8c720a8c8e6e73b11be4e27afa6cb75bdf
tree5dae2a4815c55c2da1c80b36d5276bb1844c01ae
parent38b5fa73d58576df84852c6bbf6d8219de69428b
[LV] Keep track of cost-based ScalarAfterVec in VPWidenPointerInd.

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.
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
llvm/lib/Transforms/Vectorize/VPlan.cpp
llvm/lib/Transforms/Vectorize/VPlan.h
llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
llvm/test/Transforms/LoopVectorize/AArch64/epilog-vectorization-widen-inductions.ll
llvm/test/Transforms/LoopVectorize/AArch64/sve-live-out-pointer-induction.ll
llvm/test/Transforms/LoopVectorize/AArch64/sve-widen-gep.ll
llvm/test/Transforms/LoopVectorize/AArch64/sve-widen-phi.ll
llvm/test/Transforms/LoopVectorize/X86/interleave-opaque-pointers.ll
llvm/test/Transforms/LoopVectorize/opaque-ptr.ll