This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: loop optimized in 4.7.2, not in 4.8.1?
- From: Oleg Endo <oleg dot endo at t-online dot de>
- To: Oliver Kullmann <O dot Kullmann at swansea dot ac dot uk>
- Cc: Anthony Foiani <tkil at scrye dot com>, gcc-help at gcc dot gnu dot org
- Date: Sun, 11 Aug 2013 13:14:24 +0200
- Subject: Re: loop optimized in 4.7.2, not in 4.8.1?
- References: <geha1qef1 dot fsf at dworkin dot scrye dot com> <20130811005455 dot GK6427 at csltok dot swansea dot ac dot uk> <ga9kor625 dot fsf at dworkin dot scrye dot com> <20130811094218 dot GL6427 at csltok dot swansea dot ac dot uk>
On Sun, 2013-08-11 at 10:42 +0100, Oliver Kullmann wrote:
> Hi Anthony,
>
> > > On Sat, Aug 10, 2013 at 06:06:26PM -0600, Anthony Foiani wrote:
> > > > They noticed that their earlier compiler (4.6.3 -O3) successfully
> > > > reduced the loop, while 4.8.1 didn't.
> >
> > > For general enligthenment, could you quickly explain what "reduce
> > > the loop" means? One can of course just get rid off the loop,
> > > precomputing sum,
> >
> > That's exactly what I meant. Apologies for not knowing the correct
> > phrasing.
> >
>
> Aha, interesting, that gcc was at some point capable of doing such an
> optimisation.
>
> I have checked here versions 4.7.1 and 4.7.3, and for both the run-times
> are as shown (so the loop was not eliminated).
>
> > > which is, at least for me, an unexpected difference? (I would have
> > > assumed that, if there is a difference, then Index=UInt should be
> > > faster.)
> >
> > Seeing only a 15% difference, you probably want to run it multiple
> > times and average out the values.
> >
>
> What I've shown you was already the "typical case" (timing is very
> stable).
>
> > Intuitively, I agree that the unsigned loop variable should be faster,
> > but I have no idea what's actually going on behind the scenes there.
> >
>
> Could somebody shed light on this? 15% is a large difference.
Using some timing measurements to check whether a loop has been
evaluated and eliminated at compile time doesn't sound like a reliable
approach. There also doesn't seem to be any connection to whether the
loop variable is signed or unsigned.
Anyway, I've opened a PR for this:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58122
Let's take further discussions there.
Cheers,
Oleg