* Optimizer Questions
@ 1998-06-24 10:10 Klaus Didrich
1998-06-24 18:13 ` Jeffrey A Law
0 siblings, 1 reply; 2+ messages in thread
From: Klaus Didrich @ 1998-06-24 10:10 UTC (permalink / raw)
To: egcs
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)"
----------------------------------------------------------------------
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Optimizer Questions
1998-06-24 10:10 Optimizer Questions Klaus Didrich
@ 1998-06-24 18:13 ` Jeffrey A Law
0 siblings, 0 replies; 2+ messages in thread
From: Jeffrey A Law @ 1998-06-24 18:13 UTC (permalink / raw)
To: Klaus Didrich; +Cc: egcs
In message < 13712.56819.874875.486735@polyxena >you write:
>
> [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
Probably because there are no additional moveables in your code.
In larger loops, the compiler's heuristics may indicate that a particular
movable isn't profitable to move. This flag tells the compiler to move
it anyway.
> [2] Code moving produces an empty loop, which is not removed.
> (See below for the output with -O2)
This is a "feature" and the documented behavior of the compiler. That
may change (there's a recent long thread on this topic that I need to
review).
jeff
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~1998-06-24 18:13 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-06-24 10:10 Optimizer Questions Klaus Didrich
1998-06-24 18:13 ` Jeffrey A Law
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).