[Bug target/99293] Built-in vec_splat generates sub-optimal code for -mcpu=power10

"cvs-commit at gcc dot gnu.org via Gcc-bugs" <[email protected]>
Newsgroups gmane.comp.gcc.bugs
Message-ID <[email protected]/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99293

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

https://gcc.gnu.org/g:5c9e3073ea912bb799adcb1ce7785a233ee337be

commit r17-3050-g5c9e3073ea912bb799adcb1ce7785a233ee337be
Author: Michael Meissner <[email protected]>
Date:   Fri Aug 7 01:15:08 2026 -0400

    PR target/99293: Optimize splat of a V2DF/V2DI extract with constant
element

    We had optimizations for splat of a vector extract for the other vector
    types, but we missed having one for V2DI and V2DF.  This patch adds a
    combiner insn to do this optimization.

    In looking at the source, we had similar optimizations for V4SI and V4SF
    extract and splats, but we missed doing V2DI/V2DF.

    Without the patch for the code:

            vector long long splat_dup_l_0 (vector long long v)
            {
              return __builtin_vec_splats (__builtin_vec_extract (v, 0));
            }

    the compiler generates (on a little endian power9):

            splat_dup_l_0:
                    mfvsrld 9,34
                    mtvsrdd 34,9,9
                    blr

    Now it generates:

            splat_dup_l_0:
                    xxpermdi 34,34,34,3
                    blr

    2026-08-07  Michael Meissner  <[email protected]>

    gcc/

            PR target/99293
            * config/rs6000/vsx.md (vsx_splat_extract_<mode>): New insn.

    gcc/testsuite/

            PR target/99293
            * gcc.target/powerpc/pr99293.c: New test.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.