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

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

https://gcc.gnu.org/g:ece83c6a5aa7ac1cc68d3941797a25601293f310

commit r16-6578-gece83c6a5aa7ac1cc68d3941797a25601293f310
Author: Richard Sandiford <[email protected]>
Date:   Fri Dec 12 17:40:54 2025 +0000

    vect: Generalise vect_add_slp_permutation [PR122793]

    The problem seems to be with a packing permutation:

        op0[4] op0[5] op0[6] op0[7]

    and with the identity_offset parameter to vect_add_slp_permutation.

    Both the repeating_p and !repeating_p paths correctly realise that this
    permutation reduces to an identity.  But the !repeating_p path ends up with
    first_node and second_node both set to the second VEC_PERM_EXPR operand
    (since that path works elementwise, and since no elements are taken from
    the first input).  Therefore, the call:

          vect_add_slp_permutation (vinfo, gsi, node, first_def,
                                    second_def, mask_vec, mask[0]);

    works regardless of whether vect_add_slp_permutation picks first_def or
    second_def.  In that sense, the parameters to vect_add_slp_permutation are
    already âcanonicalâ.

    The repeating_p path instead passes vector 2N as first_def and vector 2N+1
    as second_def, with mask[0] indicating the position of the identity within
    the concatenation of first_def and second_def.  However,
    vect_add_slp_permutation doesn't expect this and instead ignores the
    identity_offset parameter.

            PR tree-optimization/122793
            * tree-vect-slp.cc (vect_add_slp_permutation): Document the
existing
            identity_offset parameter.  Handle identities that take from the
            second input rather than the first.

            * gcc.dg/vect/vect-pr122793.c: New testcase.

    Co-authored-by: Richard Biener <[email protected]>

Reply via email to