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

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

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

commit r16-7353-gbd67b5a8c90194f7499981bbbc247fd45f8de6b9
Author: Robin Dapp <[email protected]>
Date:   Tue Feb 3 21:24:33 2026 +0100

    math-opts: Only build FMA when use is in addends. [PR123940]

    When looking for an FMA opportunity we can find a multiplication use in an
    else operand:

      vect_pretmp_50.23_121 = MEM <vector(2) charD.2> [(charD.2 *)&dD.2916 +
14B];
      vect__28.25_123 = vect_pretmp_50.23_121 * { 2, 2 };
      vect_patt_99.26_124 = .COND_ADD ({ -1, -1 }, vect_pretmp_50.23_121, { 14,
15 }, vect__28.25_123);

    and build it:
      vect_pretmp_50.23_121 = MEM <vector(2) charD.2> [(charD.2 *)&dD.2916 +
14B];
      vect_patt_99.26_124 = .FMA (vect_pretmp_50.23_121, { 2, 2 },
vect_pretmp_50.23_121);

    This patch checks if the use is in one of the addends.

            PR tree-optimization/123940

    gcc/ChangeLog:

            * tree-ssa-math-opts.cc (convert_mult_to_fma): Check
            multiplication result is an addend.

    gcc/testsuite/ChangeLog:

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

    Signed-off-by: Robin Dapp <[email protected]>

Reply via email to