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

--- Comment #4 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:6c1a23f4bfe2403c12439c299064af557b317737

commit r17-2395-g6c1a23f4bfe2403c12439c299064af557b317737
Author: Cem Akgok <[email protected]>
Date:   Mon Jul 13 17:21:46 2026 +0300

    vect: Fix wrong code with SLP IV reuse [PR126225]

    vectorizable_induction reduces the number of generated SLP induction
    IVs when group_size is evenly divisible by const_nunits. Existing
    code did this without checking that the vector chunks being folded have
    the same scalar initial values and steps with their counterparts.
    If either differed, reusing an earlier IV produced wrong code.

    Compute the unreduced IV count first and use the reduced count only when
    each folded chunk has initial values and steps equal to its corresponding
    earlier chunk.

    Added tests for mismatched initial values, mismatched steps, and a valid
    multi-IV reuse pattern.

    gcc/ChangeLog:

            PR tree-optimization/126225
            * tree-vect-loop.cc (vect_slp_induction_reuse_p): New function.
            (vectorizable_induction): Validate SLP induction IV reuse.  Reuse
            generated IVs cyclically when filling the SLP group.

    gcc/testsuite/ChangeLog:

            PR tree-optimization/126225
            * gcc.dg/vect/vect-iv-12.c: New test.
            * gcc.dg/vect/vect-iv-13.c: New test.
            * gcc.dg/vect/vect-iv-14.c: New test.

    Signed-off-by: Cem Akgok <[email protected]>

Reply via email to