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

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #2)
> Ah, no.  This is ipa-prop.c special code (bah).
> 
> Index: gcc/ipa-prop.c
> ===================================================================
> --- gcc/ipa-prop.c      (revision 249245)
> +++ gcc/ipa-prop.c      (working copy)
> @@ -3030,7 +3030,10 @@ find_constructor_constant_at_offset (tre
>  
>           if (index)
>             {
> -             off = wi::to_offset (index);
> +            if (TREE_CODE (index) == RANGE_EXPR)
> +              off = wi::to_offset (TREE_OPERAND (index, 0));
> +            else
> +              off = wi::to_offset (index);
>               if (TYPE_DOMAIN (type) && TYPE_MIN_VALUE (TYPE_DOMAIN (type)))
>                 {
>                   tree low_bound = TYPE_MIN_VALUE (TYPE_DOMAIN (type));
> @@ -3039,6 +3042,9 @@ find_constructor_constant_at_offset (tre
>                                   TYPE_PRECISION (TREE_TYPE (index)));
>                 }
>               off *= wi::to_offset (unit_size);
> +            if (TREE_CODE (index) == RANGE_EXPR)
> +              off *= wi::sub (wi::to_offset (TREE_OPERAND (index, 1)),
> +                              wi::to_offset (TREE_OPERAND (index, 0)));
>             }
>           else
>             off = wi::to_offset (unit_size) * ix;
> 
> Fixes this.

Actually the 2nd hunk is bogus, and w/o it we'll simply handle RANGE_EXPR
conservatively (only matching with the very first index in it).  I'm
testing that.

Enhancements can be done on trunk.

Reply via email to