[Bug tree-optimization/98255] [10/11 Regression] wrong code at -Os and above with -fPIC on x86_64-pc-linux-gnu
rguenth at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Jan 21 14:26:53 GMT 2021
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98255
--- Comment #11 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #9)
> (In reply to Jakub Jelinek from comment #8)
> > 503 poly_offset_int woffset
> > 504 = wi::sext (wi::to_poly_offset (index)
> > 505 - wi::to_poly_offset (low_bound),
> > 506 TYPE_PRECISION (TREE_TYPE (index)));
> > in get_ref_base_and_extent indeed looks incorrect to me, for precisions
> > smaller than precision of pointer (or is that sizetype) I think we need to
> > sign or zero extend based on whether index has signed or unsigned type.
> > For arrays with zero low_bound I think what get_inner_reference does is
> > right, in particular:
> > offset = size_binop (PLUS_EXPR, offset,
> > size_binop (MULT_EXPR,
> > fold_convert (sizetype, index),
> > unit_size));
> > For non-zero low_bound, it does:
> > if (! integer_zerop (low_bound))
> > index = fold_build2 (MINUS_EXPR, TREE_TYPE (index),
> > index, low_bound);
> > before that and I'm surprised that it assumes index and low_bound will be
> > compatible types. But perhaps they are in the languages that do support
> > non-zero low bounds.
>
> Note all the above "mess" is due to FEs behaving oddly, notably different
> from just interpreting the index as-is (appropriately sign or zero-extending
> it to sizetype for the sizetype offset compute). The odd sign-extension
> is from gb48e22b2bd02
Possibly wi::sext(..., TYPE_PRECISION (sizetype)) is what we want.
More information about the Gcc-bugs
mailing list