[Bug tree-optimization/93586] [10 Regression] wrong code at -O1 on x86_64-linux-gnu

cvs-commit at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Feb 21 14:37:00 GMT 2020


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

--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jan Hubicka <hubicka@gcc.gnu.org>:

https://gcc.gnu.org/g:91e50b2aa2dece9e22ae793d2a1a14b33bf3859d

commit r10-6781-g91e50b2aa2dece9e22ae793d2a1a14b33bf3859d
Author: Jan Hubicka <jh@suse.cz>
Date:   Fri Feb 21 15:36:00 2020 +0100

    tree-optimization: fix access path oracle on mismatched array refs
[PR93586]

    nonoverlapping_array_refs_p is not supposed to give meaningful results when
    bases of ref1 and ref2 are not same or completely disjoint and here it is
    called on c[0][j_2][0] and c[0][1] so bases in sence of this functions are
    "c[0][j_2]" and "c[0]" which do partially overlap. 
nonoverlapping_array_refs
    however walks pair of array references and in this case it misses to note
the
    fact that if it walked across first mismatched pair it is no longer safe to
    compare rest.

    The reason why it continues matching is because it hopes it will
    eventually get pair of COMPONENT_REFs from types of same size and use
    TBAA to conclude that their addresses must be either same or completely
    disjoint.

    This patch makes the loop to terminate early but popping all the
    remaining pairs so walking can continue.  We could re-synchronize on
    arrays of same size with TBAA but this is bit fishy (because we try to
    support some sort of partial array overlaps) and hard to implement
    (because of zero sized arrays and VLAs) so I think it is not worth the
    effort.

    In addition I notied that the function is not !flag_strict_aliasing safe
    and added early exits on places we set seen_unmatched_ref_p since later
    we do not check that in:

           /* If we skipped array refs on type of different sizes, we can
         no longer be sure that there are not partial overlaps.  */
           if (seen_unmatched_ref_p
          && !operand_equal_p (TYPE_SIZE (type1), TYPE_SIZE (type2), 0))
        {
          ++alias_stats
            .nonoverlapping_refs_since_match_p_may_alias;
        }

        PR tree-optimization/93586
        * tree-ssa-alias.c (nonoverlapping_array_refs_p): Finish array walk
        after mismatched array refs; do not sure type size information to
        recover from unmatched referneces with !flag_strict_aliasing_p.

        * gcc.dg/torture/pr93586.c: New testcase.


More information about the Gcc-bugs mailing list