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

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

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

commit r17-4002-gc44d962721818ba4eaef0e344ca4e123eea8cbb8
Author: Zhongyao Chen <[email protected]>
Date:   Tue Sep 8 09:10:52 2026 -0600

    [PATCH] RISC-V: Rewrite vector FMA patterns using fma rtxes [PR126932].

    The vector FMA patterns currently match multiply/add trees, which lets
    combine fuse operations into FMA instructions even with -ffp-contract=off.

    Rewrite these patterns using fma rtxes:
      - fma/fnma/fms/fnms in autovec.md.
      - *dual_widen_*, *single_widen_* in autovec-opt.md.
      - .vf patterns in autovec-opt.md:
        *vfmacc_vf, *vfmsac_vf,
        *vfwmacc_vf_v_f, *vfwmsac_vf_v_f,
        *vfwnmacc_vf_neg_v_f, *vfwnmsac_vf_neg_v_f.

    Unlike the old (plus (mult ...)) form, fma folds neg and sub into its
operands.
    Operands with or without neg create different RTL shapes for vector-scalar
    pairs.  Cover these by adding:
      - *vfnmsac_vf_neg_f_v, *vfnmsac_vf_neg_v_f.
      - *vfnmacc_vf_neg_f_v, *vfnmacc_vf_neg_v_f.
      - *vfwmacc_vf_f_v, *vfwmsac_vf_f_v.
      - *vfwnmacc_vf_neg_f_v, *vfwnmsac_vf_neg_f_v.

    Also, testing showed vf-3-f32.c regressed.  That's because a scalar is
    reused across multiple loop statements and shares a single widening
broadcast.
    Combine failed to match the inlined broadcast and fell back to vfnmsac.vv.
    Add to fix it:
      - *vfnmsac_vf_extend_f.
    And add the remaining three extend_f variants as well:
      - *vfnmacc_vf_extend_f, *vfmacc_vf_extend_f, *vfmsac_vf_extend_f.

            PR target/126932

    gcc/ChangeLog:

            * config/riscv/autovec.md: Rewrite vector FMA patterns.
            * config/riscv/autovec-opt.md: Likewise and add new patterns.

    gcc/testsuite/ChangeLog:

            * gcc.target/riscv/rvv/autovec/ternop/pr126932.c: New test.

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

Reply via email to