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

--- Comment #9 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Zhongyao Chen <[email protected]>:

https://gcc.gnu.org/g:9f8409f2e2c28f64bf6a584bc81afcae0f084785

commit r17-1485-g9f8409f2e2c28f64bf6a584bc81afcae0f084785
Author: Zhongyao Chen <[email protected]>
Date:   Wed Jun 3 20:44:59 2026 +0800

    vect: Avoid external fallback while operand swap retry is possible

    When building operand zero of a commutative BB SLP node, a failed child
    discovery may build operands from scalars right away.  That hides the
failure
    from the existing retry path, even when retrying with swapped operands
could
    still fix the current node.

    Track the distance from operand-zero subtree discovery to the nearest
upthread
    swap opportunity.  Skip scalar fallback only when that distance is exactly
one,
    so discovery reaches the retry path first.

    My local tests show no regression for vect.exp, only a few for rvv.exp,
    but those are reasonable, just need update test expectations.

            PR tree-optimization/125567

    gcc/
            * tree-vect-slp.cc (least_upthread_swappable_op_distance): New.
            (vect_build_slp_tree_2): Compute swap checks before building
operand
            zero.  Skip external fallback while swap retry is possible.  Reuse
the
            swap checks in the retry path.

    gcc/testsuite/
            * gcc.dg/vect/pr125567.c: New test.

    Signed-off-by: Zhongyao Chen <[email protected]>

Reply via email to