tree-optimization/49955 - BB reduction with odd number of lanes
commitd9f3ea61fe36e2de3354b90b65ff8245099114c9
authorRichard Biener <rguenther@suse.de>
Mon, 7 Aug 2023 12:44:20 +0000 (7 14:44 +0200)
committerRichard Biener <rguenther@suse.de>
Tue, 8 Aug 2023 12:38:10 +0000 (8 14:38 +0200)
tree8907ce57966ceca77a774965c78cc2df4fd9b7be
parent02a015fa320229a057ef721eaf663f3eb22a8ace
tree-optimization/49955 - BB reduction with odd number of lanes

The following enhances BB reduction vectorization to support
vectorizing only a subset of the lanes, keeping the rest as
scalar ops.  For now we try to make the number of lanes even
by leaving alone the "last" lane.  That's because SLP discovery
with all lanes will fail too soon to get us any hint on which
lane to strip and likewise we don't know what vector modes the
target supports so restricting ourselves to power-of-two or
other cases isn't easy.

This is enough to get at the vectorization opportunity for the
testcase in the PR - albeit with the chosen lanes not optimal
but at least vectorizable.

PR tree-optimization/49955
* tree-vectorizer.h (_slp_instance::remain_stmts): New.
(SLP_INSTANCE_REMAIN_STMTS): Likewise.
* tree-vect-slp.cc (vect_free_slp_instance): Release
SLP_INSTANCE_REMAIN_STMTS.
(vect_build_slp_instance): Make the number of lanes of
a BB reduction even.
(vectorize_slp_instance_root_stmt): Handle unvectorized
defs of a BB reduction.

* gfortran.dg/vect/pr49955.f: New testcase.
gcc/testsuite/gfortran.dg/vect/pr49955.f [new file with mode: 0644]
gcc/tree-vect-slp.cc
gcc/tree-vectorizer.h