[Bug target/126787] [15/16/17 Regression] i386: target clone on FMA4 emits wrong fma instruction with egpr

"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=126787

--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-15 branch has been updated by Hongyu Wang
<[email protected]>:

https://gcc.gnu.org/g:68c97e6444b8478a45645348fcda43792448f4c2

commit r15-11495-g68c97e6444b8478a45645348fcda43792448f4c2
Author: Hongyu Wang <[email protected]>
Date:   Tue Aug 11 16:57:48 2026 +0800

    i386: Disallow APX EGPR in FMA4/XOP insns [PR target/126787]

    FMA4 and XOP instructions are VEX-only, so cannot be promoted to EVEX form.
    When enforcing -mapxf on such target clone, which is at --with-arch=native
    plus libgfortran bootstrap on Diamond Rapids or Nova Lake, the fma4 clone
    may generate unencodable vfmaddps with egpr in mem.

    Restrict all the FMA4/XOP patterns with replacing 'm' to 'jm' and add gpr16
    to the addr attribute to avoid egpr usage under high register pressure.

    gcc/ChangeLog:

            PR target/126787
            * config/i386/sse.md (*fma_fmadd_<mode>): Use the "jm" to replace
            "m" constraint and set addr attribute to "gpr16" for vex only
            alternatives.
            (*fma_fmsub_<mode>): Likewise.
            (*fma_fnmadd_<mode>): Likewise.
            (*fma_fnmsub_<mode>): Likewise.
            (*fma_fmaddsub_<mode>): Likewise.
            (*fma_fmsubadd_<mode>): Likewise.
            (xop_p<macs><ssemodesuffix><ssemodesuffix>): Likewise.
            (xop_p<macs>dql): Likewise.
            (xop_p<macs>dqh): Likewise.
            (xop_p<macs>wd): Likewise.
            (xop_p<madcs>wd): Likewise.
            (xop_pcmov_<mode><avxsizesuffix>): Likewise.
            (xop_phadd<u>bw): Likewise.
            (xop_phadd<u>bd): Likewise.
            (xop_phadd<u>bq): Likewise.
            (xop_phadd<u>wd): Likewise.
            (xop_phadd<u>wq): Likewise.
            (xop_phadd<u>dq): Likewise.
            (xop_phsubbw): Likewise.
            (xop_phsubwd): Likewise.
            (xop_phsubdq): Likewise.
            (xop_pperm): Likewise.
            (xop_pperm_pack_v2di_v4si): Likewise.
            (xop_pperm_pack_v4si_v8hi): Likewise.
            (xop_pperm_pack_v8hi_v16qi): Likewise.
            (xop_rotl<mode>3): Likewise.
            (xop_rotr<mode>3): Likewise.
            (xop_vrotl<mode>3): Likewise.
            (xop_sha<mode>3): Likewise.
            (xop_shl<mode>3): Likewise.
            (xop_frcz<mode>2): Likewise.
            (*xop_vmfrcz<mode>2): Likewise.
            (xop_maskcmp<mode>3): Likewise.
            (xop_maskcmp_uns<mode>3): Likewise.
            (xop_maskcmp_uns2<mode>3): Likewise.
            (xop_pcom_tf<mode>3): Likewise.
            (xop_vpermil2<mode>3): Likewise.

    gcc/testsuite/ChangeLog:

            PR target/126787
            * gcc.target/i386/pr126787.c: New test.

    (cherry picked from commit 475e9efffaf8de781d7e17b687faf1807e104b01)
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.