[SLP] Try to match reductions before trying to vectorize a vector build sequence.
authorValery N Dmitriev <valery.n.dmitriev@intel.com>
Thu, 25 Aug 2022 23:58:56 +0000 (16:58 -0700)
committerValery N Dmitriev <valery.n.dmitriev@intel.com>
Mon, 29 Aug 2022 20:32:14 +0000 (13:32 -0700)
commit329b972d416a3dc23ab3eacb17b884ead03af8e5
tree40064c79ba0eb84d4643c7e6a7344eb0cbedd180
parentfffd966f0b0f6aff879e2fd60cfc75336beb226b
[SLP] Try to match reductions before trying to vectorize a vector build sequence.

This patch changes order of searching for reductions vs other vectorization possibilities.
The idea is if we do not match a reduction it won't be harmful for further attempts to
find vectorizable operations on a vector build sequences. But doing it in the opposite
order we have good chance to ruin opportunity to match a reduction later.
We also don't want to try vectorizing binary operations too early as 2-way vectorization
may effectively prohibit wider ones leading to producing less effective code.

Differential Revision: https://reviews.llvm.org/D132590
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
llvm/test/Transforms/SLPVectorizer/X86/redux-feed-buildvector.ll