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]

Optimizer Questions


Hi,

I've been doing some experiments with the loop-optimization of egcs
and now have a couple of questions.

The exact version is "gcc version egcs-2.91.40 19980608 (gcc2 ss-980502
experimental)"  running on Solaris 2.6

The example I was using is called T.c and contains
------------------------------------------------------------
int p(int a) {
    int x, i;

    for (i = 0; i < 100; i ++) {
	x =  a * 12;
    }
    return x;
}
------------------------------------------------------------

[1] The flag -fmove-all-movables does not seem to have any effect:

    gcc -fmove-all-movables -S T.c
    gcc -S T.c

    produce the same assembler file (no moving in either case), as do

    gcc -O2 -fno-move-all-movables -S T.c
    gcc -O2 -S T.c

    (code is moved in both cases, same for -O1 and -O3)

[2] Code moving produces an empty loop, which is not removed.
    (See below for the output with -O2)

[3] If I'm not mistaken, the empty loop is executed 99 times and not 100
    times.  

Regards,

	Klaus

----------------------------------------------------------------------
Output of gcc -O2 -S T.c
............................................................
	.file	"T.c"
gcc2_compiled.:
.section	".text"
	.align 4
	.global p
	.type	 p,#function
	.proc	04
p:
	!#PROLOGUE# 0
	!#PROLOGUE# 1
	sll %o0,1,%g2
	add %g2,%o0,%g2
	sll %g2,2,%o0
	mov 99,%g3
	addcc %g3,-1,%g3
.LL7:
	bpos .LL7
	addcc %g3,-1,%g3
	retl
	nop
.LLfe1:
	.size	 p,.LLfe1-p
	.ident	"GCC: (GNU) egcs-2.91.40 19980608 (gcc2 ss-980502 experimental)"
----------------------------------------------------------------------


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