This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: fold: &a[i1] + c * i2 -> &a[i1 + i2] messing up types
- From: Richard Guenther <rguenth at tat dot physik dot uni-tuebingen dot de>
- To: Zdenek Dvorak <rakdver at atrey dot karlin dot mff dot cuni dot cz>
- Cc: gcc at gcc dot gnu dot org
- Date: Wed, 9 Feb 2005 14:54:09 +0100 (CET)
- Subject: Re: fold: &a[i1] + c * i2 -> &a[i1 + i2] messing up types
On Wed, 9 Feb 2005, Zdenek Dvorak wrote:
> Hello,
>
> > > > If you prefer removing the type argument that would be fine, too.
> > >
> > > this might be a good idea, yes.
> >
> > Actually, in
> >
> > step = array_ref_element_size (ref);
> >
> > if (TREE_CODE (step) != INTEGER_CST)
> > continue;
> >
> > itype = TREE_TYPE (step);
> >
> > /* If the type sizes do not match, we might run into problems
> > when one of them would overflow. */
> > if (TYPE_PRECISION (itype) != TYPE_PRECISION (type))
> > continue;
> >
> > if (!operand_equal_p (step, fold_convert (itype, s), 0))
> > continue;
> >
> > do you really mean to compare TYPE_PRECISION (itype) and TYPE_PRECISION
> > (type)? I think type should refer to TREE_TYPE (s) here, not to
> > TREE_TYPE (addr), no?
>
> they have the same size.
Are you sure? For a 64bit system it would be 64bit pointer and
probably 32bit element size. But I guess, as you are comparing
step and s, which are both checked to be INTEGER_CST, the check
for matching TYPE_PRECISION is pointless anyway, and you could
use tree_int_cst_equal instead of operand_equal_p.
Or maybe I'm missing something.
Richard.
--
Richard Guenther <richard dot guenther at uni-tuebingen dot de>
WWW: http://www.tat.physik.uni-tuebingen.de/~rguenth/