On Fri, 3 Jul 2026, Zhongyao Chen wrote:

> > Hmm, but then why does not swapping help?  We can't build either
> > operand as internal without swapping, so swapping cannot make things
> > worse?
> 
> "swapping" makes things worse here because it we end up with
> ```
> Building vector operands from scalars
> Building parent vector operands from scalars instead
> ```
> 
> if without that swap retry, the parent node can still remain an
> internal SLP node.

Ah, OK.  So the issue is that without swapping we can build
the operand from scalars because we "late" fail here, but
after swapping we fail early during vect_build_slp_tree_1
and in that case we never build the operand from scalars.
Instead we now build the swapped parent operand from scalars.

It seems that we might instead want change the original patch
so that we preserve the build from scalars when we build
operand zero but, if we could have swapped and the just
built child is external (aka built from scalars), we make
sure matches[] is still correctly populated so we can
try vect_build_slp_tree_1 on the swapped stmt set to see
if we'd wreck and only when not discard the extern promoted
child and try with swapping?

That would basically implement the original change in a different,
more local way.

Richard.

Reply via email to