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]

Re: Default constructors & arrays


On Tue, 19 May 1998, Igor Durdanovic wrote:
> Joern Rennecke writes:
>> This is basically a loop unroll problem.  If you completely unroll an
>> empty loop, it goes away.
> It seems not to be that simple. It is true, it works in case of 
> for ( int i = 0; i < 10; ++i );

Hmm, are you sure? On i386-unknown-freebsd2.2.6 with egcs-2.91.29 19980517
I get the following for 

  void f() {
      for ( int i = 0; i < 10; ++i );
      }

compiled with gcc -c -S -O3

  	pushl %ebp
  	movl %esp,%ebp
	movl $9,%eax
	.align 2,0x90
  L4:
	decl %eax
	jns L4
	leave
	ret

Ah, wait a moment! With  gcc -c -S -O1 -funroll-loops (note this works
even with -O1) indeed I get:

        pushl %ebp
        movl %esp,%ebp
        leave
        ret


It seems that actually gcc.info is not completely correct, as -- with
proper options -- egcs will indeed delete "empty" loops. 

  * Deleting "empty" loops.

     GNU CC does not delete "empty" loops because the most likely reason
     you would put one in a program is to have a delay.  Deleting them
     will not make real programs run any faster, so it would be
     pointless.

     It would be different if optimization of a nonempty loop could
     produce an empty one.  But this generally can't happen.

Would you be willing to accept a patch that 
 a) removes this paragraph
or
 b) adds a remark about -funroll-loops?

Gerald
-- 
Gerald Pfeifer (Jerry)      Vienna University of Technology
pfeifer@dbai.tuwien.ac.at   http://www.dbai.tuwien.ac.at/~pfeifer/



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