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: -funsafe-loop-optimizations


On Sat, Jan 01, 2005 at 05:53:47PM +0100, Zdenek Dvorak wrote:
> Hello,
> 
> > > > 	While we discuss whether this should be the default or enabled at
> > > > any optimization level, can we agree that users should be able to assert
> > > > with a commandline option that they want less strict induction variable
> > > > semantics?
> > > 
> > > And/or a -W option that warns for these sorts of loops so that
> > > (a) we can see how often this happens, really, (b) so that users
> > > can fix the presumed mistake.
> > 
> > If you could detect them and warn for them, you could not optimize
> > them in the first place (and that's what happens when the boundaries
> > are constants).  They're detectable only at runtime and even en not
> > necessarily easily.
> 
> I think Richard means issuing warning in case where
> -funsafe-loop-optimizations causes us to ignore some conditions
> for optimizations we were not able to prove.  Which definitely is
> a good idea.

If I've been following this thread correctly, we would warn for this
loop:

void foo (unsigned int n)
{
  for (i = 0; i <= n; i++)
    bar ();
}

(because it is infinite if n is ~0).  So they aren't a "presumed
mistake".  I think the warning would only be useful for people who were
considering turning on the matching optimization.

-- 
Daniel Jacobowitz


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