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

--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Richard Sandiford <rsand...@gcc.gnu.org>:

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

commit r11-7935-gb5c7accfb56a7347008f629be4c7344dd849b1b1
Author: Richard Sandiford <richard.sandif...@arm.com>
Date:   Wed Mar 31 19:34:01 2021 +0100

    data-ref: Tighten index-based alias checks [PR99726]

    create_intersect_range_checks_index tries to create a runtime
    alias check based on index comparisons.  It looks through the
    access functions for the two DRs to find a SCEV for the loop
    that is being versioned and converts a DR_STEP-based check
    into an index-based check.

    However, there isn't any reliable sign information in the types,
    so the code expects the value of the IV step (when interpreted as
    signed) to be negative iff the DR_STEP (when interpreted as signed)
    is negative.

    r10-4762 added another assert related to this assumption and the
    assert fired for the testcase in the PR.  The sign of the IV step
    didn't match the sign of the DR_STEP.

    I think this is actually showing what was previously a wrong-code bug.
    The signs didn't match because the DRs contained *two* access function
    SCEVs for the loop being versioned.  It doesn't look like the code
    is set up to deal with this, since it checks each access function
    independently and treats it as the sole source of DR_STEP.

    The patch therefore moves the main condition out of the loop.
    This also has the advantage of not building a tree for one access
    function only to throw it away if we find an inner function that
    makes the comparison invalid.

    gcc/
            PR tree-optimization/99726
            * tree-data-ref.c (create_intersect_range_checks_index): Bail
            out if there is more than one access function SCEV for the loop
            being versioned.

    gcc/testsuite/
            PR tree-optimization/99726
            * gcc.target/i386/pr99726.c: New test.

Reply via email to