This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: [tree-ssa] Dce & infinite loops


> -----Original Message-----
> From: gcc-owner On Behalf Of Paolo Carlini
> Sent: 18 March 2004 13:18

> Zdenek Dvorak wrote:
> 
> >But you won't gain much by this in practice, since people usually do 
> >not write useless loops.  Also it is not clear whether people really 
> >want such loop to be optimized out (they might write it in order to 
> >make the program wait).
> >  
> >
> Exactly: these two observations I remember perfectly from 
> that discussion.
> 
> Paolo.

  AFAIUI, anyone who writes a loop to make a delay is writing
non-standards-compliant code.  If you have a loop like

  for (i = 0; i < very_big_number; i++)
    /* do nothing but delay */ ;

then surely under the "as-if rule", the compiler is completely within its
rights to just replace it with

  i = very_big_number;

and so anyone expecting to get a delay loop is making a false assumption,
isn't it so?

  It's been bad engineering practice for many years now to assume a fixed
relationship between machine cycles and real time; it was OK on the CBM64 to
assume that each instruction was 1us, maybe, but in a world where CPUs range
from 486 to K8 to ppc and SH and beyond, and clocks vary from 50MHz to 3GHz,
and memory subsystems include 1, 2 or even 3 levels of caching..... it's
just borked.

[  I was going to butt into the PCH thread as well and mention that the last
time I coded for a system where you could actually *rely* on loading data
back into memory at the same address you wrote it out from, it was also the
C64.... ]

    cheers, 
      DaveK
-- 
Can't think of a witty .sigline today....


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]