This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: -funsafe-loop-optimizations
- From: Richard Guenther <richard dot guenther at gmail dot com>
- To: Zdenek Dvorak <rakdver at atrey dot karlin dot mff dot cuni dot cz>
- Cc: Giovanni Bajo <giovannibajo at libero dot it>, gcc at gcc dot gnu dot org
- Date: Sat, 1 Jan 2005 22:35:50 +0100
- Subject: Re: -funsafe-loop-optimizations
- References: <20041231211409.GA22814@atrey.karlin.mff.cuni.cz> <035f01c4f044$623cf160$4e422597@bagio> <20050101211056.GA27013@atrey.karlin.mff.cuni.cz>
- Reply-to: Richard Guenther <richard dot guenther at gmail dot com>
On Sat, 1 Jan 2005 22:10:56 +0100, Zdenek Dvorak
<rakdver@atrey.karlin.mff.cuni.cz> wrote:
> Hello,
>
> > > several times some people sounded opinion that in addition to
> > > improving
> > > analyses in loop optimizer, we might also add a flag that would enable
> > > the compiler to assume that the compiled code does not contain loops
> > > behaving in "weird" way (loops whose control induction variables
> > > overflows, infinite loops with nontrivial exit conditions).
> > >
> > > I remember several people were against this possibility. Therefore
> > > I send the proposal for the patch implementing this flag first here
> > > to the gcc list, to give the chance to discuss about it before I try
> > > to test and submit it properly (or not).
> >
> > Another idea: why don't you generate both the safe and the unsafe code testing
> > at runtime for the condition (e.g. n==0)? This is also what we do in autovect
> > to test for aligned/unaligned access. We could use this new optimization flag
> > to disable generate of the safe version of the loop, but we would still be
> > generating decent loop with the default options.
>
> I have thought about this. But the runtime checks are not for free, and
> increase in code size also would not be insignificant.
You could do the transformation based on value-profiling and putting
the unlikely case in a cold section. How many times do loop transformations
trigger with -funsafe-loop-optimizations in gcc sources anyway compared
to current behavior? Are they always profitable? Which are the common
cases?
Richard