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

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

https://gcc.gnu.org/g:09c66632baa6ebf1bf18abc1b99b8f78dce16256

commit r17-5773-g09c66632baa6ebf1bf18abc1b99b8f78dce16256
Author: Rohith Kapelli <[email protected]>
Date:   Fri Oct 16 00:58:40 2026 +0530

    tree-optimization/115869 - give up on self dependences without distance
vectors

    add_multivariate_self_dist and add_other_self_distances detect a self
    dependence that distance vectors cannot describe, with more than two
    varying loops or an initial value or step that is not constant, but they
    only clear DDR_AFFINE_P.  The relation stays dependent with the zero
    vector saved before, and the users of the vectors take it as exact, so
    for example the outer-loop vectorizer can miscompile.  Mark such a
    relation as unknown and release its vectors.  Also release them at the
    existing early-out for several subscripts, as unroll-and-jam reads the
    vectors of a relation without checking for chrec_dont_know.

            PR tree-optimization/115869

    gcc/ChangeLog:

            * tree-data-ref.cc (add_multivariate_self_dist): Set
            DDR_ARE_DEPENDENT to chrec_dont_know and release the distance
            vectors when the dependence cannot be represented.
            (add_other_self_distances): Likewise.  Release the distance
            vectors when giving up on several subscripts.

    gcc/testsuite/ChangeLog:

            * gcc.dg/torture/pr115869-4.c: New test.

    Signed-off-by: Rohith Kapelli <[email protected]>

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

https://gcc.gnu.org/g:99126c684223cabab03e41e806616160b4058f73

commit r17-5774-g99126c684223cabab03e41e806616160b4058f73
Author: Rohith Kapelli <[email protected]>
Date:   Fri Oct 16 00:58:52 2026 +0530

    tree-optimization/115869 - complete or drop the distance vectors of free
loops

    Call a loop of the nest free when it contains both references and no
    compared access function evolves in it: the dependence can then have any
    distance in that loop.  build_classic_dist_vector gives a free loop a
    distance of its own only when it is the only one and lies outside the
    loops the subscripts constrain; otherwise its distance is taken as zero,
    which misses the distances of opposite signs.  Interchange and
    unroll-and-jam then reverse dependences that exist, as for structure
    accesses through objects that move in the nest (PR115869, PR105771) and
    for plain arrays (PR120254, PR109184).

    When the vectors agree up to sign in the constrained loops, add every
    lexicographically positive vector with -1, 0 or 1 in each free loop and
    the first vector's distances, or their opposite, in the other loops.
    For correctness the users need only the signs and the smallest distance
    in such a loop.  Give up instead when the bases differ and the objects
    move in the nest, when the vectors disagree (as the vectors of
    add_multivariate_self_dist do, whose outer distances go one way only),
    when more than three loops are free, or when more than 32 vectors would
    be needed.

            PR tree-optimization/115869
            PR tree-optimization/105771
            PR tree-optimization/120254
            PR tree-optimization/109184

    gcc/ChangeLog:

            * tree-data-ref.cc (dist_vectors_agree_p): New function.
            (mark_evolving_loops): Likewise.
            (enum free_loop_distances): New.
            (check_free_loop_distances): New function.
            (add_free_loop_distances): Likewise.
            (subscript_dependence_tester): Complete the distance vectors of
            free loops, or give up.

    gcc/testsuite/ChangeLog:

            * gcc.dg/torture/pr105771.c: New test.
            * gcc.dg/torture/pr109184.c: New test.
            * gcc.dg/torture/pr115869.c: New test.
            * gcc.dg/torture/pr115869-2.c: New test.
            * gcc.dg/torture/pr115869-3.c: New test.
            * gcc.dg/torture/pr115869-5.c: New test.
            * gcc.dg/torture/pr120254.c: New test.

    Signed-off-by: Rohith Kapelli <[email protected]>

Reply via email to