possible gcse failure: not able to eliminate redundant loads
Jan Hubicka
jh@suse.cz
Mon Dec 16 15:38:00 GMT 2002
> Toon Moene wrote:
>
> >Richard Henderson wrote:
> >
> >>On Mon, Dec 16, 2002 at 10:04:01PM +0100, Toon Moene wrote:
> >>
> >>>BTW, I wasn't aware it's legal to dereference NULL C pointers.
>
> >>It isn't, of course. But that's the whole point. You've
> >>got code that says
> >>
> >> x = (condition ? *p : 0);
> >>
> >>i.e. the dereference is protected by a conditional.
>
> Oh, wait, I see what you mean:
>
> x = (p ? *p : 0);
>
> Yes, that's impossible to express in Fortran (90/95/F2K), hence we don't
> have to worry about it.
I think you can write the for loop.
The loop computes pointer past the array boundary that is invisible to
fortran but happens in generated code.
GCC beleiving that the memory refrence does not trap would move the load
ahead in unrolled version of the loop causing program to read past the
end.
Honza
>
> [ The way to do this in Fortran is to write:
>
> IF (ASSOCIATED(P)) THEN
> .... USE P
> ELSE
> .... BETTER KEEP YOUR PAWS OFF ....
> ENDIF
> ]
>
> --
> Toon Moene - mailto:toon@moene.indiv.nluug.nl - phoneto: +31 346 214290
> Saturnushof 14, 3738 XG Maartensdijk, The Netherlands
> Maintainer, GNU Fortran 77: http://gcc.gnu.org/onlinedocs/g77_news.html
> Join GNU Fortran 95: http://g95.sourceforge.net/ (under construction)
More information about the Gcc
mailing list