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

--- Comment #2 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:3db0edb7331f01233dc3b4d1e32b094c7b4ba678

commit r17-5216-g3db0edb7331f01233dc3b4d1e32b094c7b4ba678
Author: Igor Shevlyakov <[email protected]>
Date:   Wed Oct 14 14:35:13 2026 -0700

    match.pd: Fix mode queries of VEC_PERM merge through view-convert
[PR127882]

    The pattern that merges c = VEC_PERM_EXPR <a, b> into
    d = VEC_PERM_EXPR <c, c> also matches when c is view-converted before d
    uses it.  It asks can_vec_perm_const_p about the new permute and about
    both original ones with d's mode as the result mode and a's mode as the
    input mode.  When the conversion changes the element type, e.g. from
    short to _Float16, that is a permute between two different modes, which
    the pattern never emits and no target supports.  All three queries then
    fail, "one of the original permutes can't be handled" holds, and the
    permutes are merged even when both are supported and the merged one is
    not.  Vector lowering then expands the result element by element: on
    x86_64 with SSE2 the testcase goes from 3 to 13 instructions.

    Query each permute with its own modes instead: the new one has a's
    type (it is view-converted to d's type afterwards), the inner one
    produces c from a and b, and the outer one produces d from the
    converted c.

    Assisted-by: Claude Opus 5.5

            PR middle-end/127882

    gcc/ChangeLog:

            * match.pd (vec_perm (view_convert? (vec_perm)) merge): Query
            each permute with its own modes.  Rename the modes and selectors
            and show the VIEW_CONVERT_EXPR in the comment.

    gcc/testsuite/ChangeLog:

            * gcc.target/i386/pr127882.c: New test.

    Signed-off-by: Igor Shevlyakov <[email protected]>

Reply via email to