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

--- Comment #32 from alalaw01 at gcc dot gnu.org ---
(In reply to rguent...@suse.de from comment #31)
>
> Thus a "fix" for the case where treating a[i] as a[0] is the issue
> would be
> 
> Index: gcc/tree-dfa.c
> ===================================================================
> --- gcc/tree-dfa.c      (revision 233172)
> +++ gcc/tree-dfa.c      (working copy)
> @@ -617,7 +617,11 @@ get_ref_base_and_extent (tree exp, HOST_
>        if (maxsize == -1
>           && DECL_SIZE (exp)
>           && TREE_CODE (DECL_SIZE (exp)) == INTEGER_CST)
> -       maxsize = wi::to_offset (DECL_SIZE (exp)) - bit_offset;
> +       {
> +         maxsize = wi::to_offset (DECL_SIZE (exp)) - bit_offset;
> +         if (maxsize == size)
> +           maxsize = -1;
> +       }
>      }
>    else if (CONSTANT_CLASS_P (exp))
>      {

Maybe if we only did that for DECL_COMMONs if -std=legacy was in force?

Tho as you say:

> but that wouldn't fix the aggressive-loop optimization issue as that is
> _not_ looking at DECL_SIZE but at the array types domain.

I wonder if we can't get both places looking at the same thing (DECL_SIZE or
array type domain), but I haven't looked into that at all.

Reply via email to