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: Jakub Jelinek <jakub at redhat dot com>
- Cc: Zdenek Dvorak <rakdver at atrey dot karlin dot mff dot cuni dot cz>,<gcc at gcc dot gnu dot org>
- Date: Wed, 9 Feb 2005 14:21:36 +0100 (CET)
- Subject: Re: fold: &a[i1] + c * i2 -> &a[i1 + i2] messing up types
On Wed, 9 Feb 2005, Jakub Jelinek wrote:
> On Wed, Feb 09, 2005 at 02:06:18PM +0100, Zdenek Dvorak wrote:
> > however the cast should be done using fold_convert:
> >
> > tem = try_move_mult_to_index (TREE_TYPE (arg0), PLUS_EXPR, arg0, arg1);
> > if (tem)
> > return fold (fold_convert (type, tem));
>
> Actually, shouldn't that be
> return fold_convert (type, fold (tem));
> instead?
> Calling fold on fold_convert result is pointless, as it is already folded.
Hmm, fold is only called in fold_convert if we're really changing the
type. So fold_convert (type, fold (tem)) is maybe a duplicate call of
fold, fold (fold_convert (type, tem)), too - so I don't see the
difference here.
> But if the arg passed to fold_convert is not already folded, we might miss
> some simplifications.
It would be better for fold_convert to either always call fold on the
argument or never, maybe.
Richard.
--
Richard Guenther <richard dot guenther at uni-tuebingen dot de>
WWW: http://www.tat.physik.uni-tuebingen.de/~rguenth/