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

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

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

commit r16-6893-gd718835414482b7b2b9d622ddb64ac66fbeafb19
Author: Jakub Jelinek <[email protected]>
Date:   Mon Jan 19 09:46:36 2026 +0100

    vect-generic: Fix up expand_vector_mult [PR123656]

    The alg_sub_factor handling in expand_vector_mult had the arguments
    reversed.
    As documented in expmed.h, the algorithms should be
       These are the operations:
       alg_zero             total := 0;
       alg_m                total := multiplicand;
       alg_shift            total := total * coeff
       alg_add_t_m2         total := total + multiplicand * coeff;
       alg_sub_t_m2         total := total - multiplicand * coeff;
       alg_add_factor       total := total * coeff + total;
       alg_sub_factor       total := total * coeff - total;
       alg_add_t2_m         total := total * coeff + multiplicand;
       alg_sub_t2_m         total := total * coeff - multiplicand;

       The first operand must be either alg_zero or alg_m.  */
    So, alg_sub_factor should be identical to alg_sub_t2_m with the
    difference that one subtracts accumulator and the other subtracts
    op0.  I went through all the other ones and they seem to match
    the description except for alg_sub_factor and tree-vect-patterns.cc
    seems to be fully correct.  expand_vector_mult at times has
    pretty random order of PLUS_EXPR arguments, but that is a commutative
    operation, so makes no difference.

    Furthermore, I saw weird formatting in the alg_add_t_m2 case, so fixed
    that too.

    2026-01-19  Jakub Jelinek  <[email protected]>

            PR tree-optimization/123656
            * tree-vect-generic.cc (expand_vector_mult): Fix up alg_sub_factor
            handling.  Fix up formatting in alg_add_t_m2 handling.

            * gcc.dg/pr123656.c: New test.

Reply via email to