[LoopVectorize] Support conditional in-loop vector reductions
authorKerry McLaughlin <kerry.mclaughlin@arm.com>
Tue, 22 Feb 2022 10:49:34 +0000 (10:49 +0000)
committerKerry McLaughlin <kerry.mclaughlin@arm.com>
Tue, 22 Feb 2022 12:04:35 +0000 (12:04 +0000)
commit12fb133eba819cac8c14ac1888ea1e460e45d17a
treec7c9e6e8d2e247d7e608bd96ef122457ab54a385
parenta2c267e0c9d9b9963f4022caf455327a7d96dfbf
[LoopVectorize] Support conditional in-loop vector reductions

Extends getReductionOpChain to look through Phis which may be part of
the reduction chain. adjustRecipesForReductions will now also create a
CondOp for VPReductionRecipe if the block is predicated and not only if
foldTailByMasking is true.

Changes were required in tryToBlend to ensure that we don't attempt
to convert the reduction Phi into a select by returning a VPBlendRecipe.
The VPReductionRecipe will create a select between the Phi and the reduction.

Reviewed By: david-arm

Differential Revision: https://reviews.llvm.org/D117580
llvm/lib/Analysis/IVDescriptors.cpp
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
llvm/test/Transforms/LoopVectorize/AArch64/scalable-reduction-inloop-cond.ll [new file with mode: 0644]
llvm/test/Transforms/LoopVectorize/AArch64/sve-tail-folding.ll
llvm/test/Transforms/LoopVectorize/reduction-inloop-cond.ll [new file with mode: 0644]
llvm/test/Transforms/LoopVectorize/reduction-inloop-uf4.ll