https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98138

--- Comment #23 from rguenther at suse dot de <rguenther at suse dot de> ---
On Fri, 13 Feb 2026, chenzhongyao.hit at gmail dot com wrote:

> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98138
> 
> --- Comment #22 from Zhongyao Chen <chenzhongyao.hit at gmail dot com> ---
> (In reply to Zhongyao Chen from comment #21)
> > Created attachment 63661 [details]
> > some_experiment log
> 
> Hi Richard,
> 
> I noticed that current SLP vectorization groups statements by operator. For
> interleaved computation patterns (e.g., Hadamard-like transforms), this leads
> to:
> 1. Redundant computations due to stmt duplication
> 2. Extra VEC_PERM_EXPR nodes
> 
> https://godbolt.org/z/Mjj6f41MP
> 
> Test case and SLP tree dumps attached. See trunk_slp_tree.log for the current
> tree structure.
> 
> I wonder if we can detect such patterns and keep single-lane nodes instead of
> operator-based grouping?
> 
> The my_personal_expected_slp_tree.log shows my local experiment with lane
> permutation { 0[0] 1[0] 2[0] 3[0] } and single-lane children. This would of
> course need additional changes to support, such as perm lowering.
> 
> What you think?

It's all heuristics.  If there are multiple ways to build a SLP graph
we pick the first one that "works", and which one this is depends on
which one we try first which is, again, heuristically driven.

There is plans to experiment with a different way of building the SLP
graph for loop vectorization, starting from an all-single-lane SLP
graph and then performing node merging instead of the current greedy
discovery.  But that's all plans only at the moment.  I do hope to
work on the first thing - have a all-single-lane SLP graph, if only
as the "fallback" graph and to trivially capture all stmts, for next
stage1.  If you are curious, I plan to build this graph where we
currently analyze which stmts are relevant, in 
vect_mark_stmts_to_be_vectorized.  I currently do not plan to touch
BB SLP graph build, so both would be somewhat separated in the
future; some refactoring needs to be done to be able to share
validation building blocks.

Reply via email to