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

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

https://gcc.gnu.org/g:40d6dbf0f8dd91db5e4c13187fc341cdef40b054

commit r16-4537-g40d6dbf0f8dd91db5e4c13187fc341cdef40b054
Author: Richard Biener <[email protected]>
Date:   Mon Oct 20 14:44:27 2025 +0200

    tree-optimization/120687 - reduction chain with UB on signed overflow

    The following adds the ability to discover a reduction chain on a
    series of statements that invoke undefined behavior on integer overflow.
    This inhibits the reassoc pass from associating stmts in the way
    naturally leading to a reduction chain.  The common mistake on the
    source side is to rely on the += operator to sum multiple inputs.

    After the refactoring of how we handle reduction chains we can
    easily use vect_slp_linearize_chain to do this our selves and
    rely on the vectorizer punning operations to unsigned given reduction
    vectorization always associates.

            PR tree-optimization/120687
            * tree-vect-slp.cc (vect_analyze_slp_reduc_chain): When
            there's no natural reduction chain see if vect_slp_linearize_chain
            can recover one and built the SLP instance manually in that
            case.
            (vect_schedule_slp): Deal with NULL lanes when looking for
            stores to remove.
            * tree-vect-loop.cc (vect_transform_cycle_phi): Dump when we
            are successfully transforming a reduction chain.

            * gcc.dg/vect/vect-reduc-chain-4.c: New testcase.

Reply via email to