[patch] for PR 17531

Zdenek Dvorak rakdver@atrey.karlin.mff.cuni.cz
Tue Sep 28 09:30:00 GMT 2004


Hello,

> On Sep 27, 2004, at 8:44 PM, Zdenek Dvorak wrote:
> >short a[100];
> >short b;
> >
> >for (b = 0; b < 100; b++)
> >  a[b] = 2 * b;
> >
> >to
> >
> >short a[100];
> >short *p;
> >
> >for (p = &a; p < &a + 200B; p += 2B)
> >  *p = (short) (p - &a);
> >
> >is perfectly valid.
> 
> Yes but pointer - pointer = size_t so there is a cast to size_t
> first and then to short.

no, if you do not emit it.  And fold_convert does not consider it
necessary to do it (neither do I -- it seems to be just wasting
memory and making the program harder to optimize).

Zdenek



More information about the Gcc-patches mailing list