Loop unrolling

Mike Stump mrs@wrs.com
Wed Jun 10 16:35:00 GMT 1998

> Date: Wed, 10 Jun 1998 20:16:08 +0200 (MET DST)
> From: Gerald Pfeifer <pfeifer@dbai.tuwien.ac.at>

> I'm the one who started this monster thread, and actually I believe that
> John Carr <jfc@mit.edu>,

His example was mistaken.  He had no ``empty'' ``loops''.

 struct x
          x() {}
          x x1[10];

I see no for, nor no while.  This should optimize down.

> Branko Cibej <branko.cibej@hermes.si>,

His example was mistaken.  He had no ``empty'' loops.

                for (size_t i = 0; i < size; ++i)
                    new (&objs[i]) T(init);

In this case, ``new (&objs[i]) T(init)'' != ``'', hence the loop is
not empty.

    for (size_t i = 0; i < size; ++i)

In this case, ``objs[i].~T()'' != ``'', hence the loop is not empty.

This case should optimize down.

> Martin von Loewis <martin@mira.isdn.cs.tu-berlin.de> have provided
> examples that empty loops _should_ get removed.

His example was also mistaken:

class A {
  int i;

int main() 
  A a[1000];

I see no loops.  This should be optimized down.

The definition of loop means the use of the keyword ``for'' or
``while''. The definition of empty (in C and C++) means that textually
in the users source program, the character ';' follows the ')' from
the loop syntax.

I know, somewhat arbitrary, but prefectly clear.  This was the result
of the conversation from eons ago that we had.  It is not currently
implemented this way, but as I said, that is a bug in the
implementation, that can be fixed, if someone cares.

> Jeff, what happened to my patch? You neither commented on it nor has
> it been installed. :-(

I don't think it should be.

More information about the Gcc-patches mailing list