Optimization
Piotr Wyderski
piotr.wyderski@hoga.pl
Fri May 2 12:05:00 GMT 2003
Hello,
I've just looked at the binary code produced by the GCC 3.2
C++ compiler and don't understand your new optimizer's
behaviour. Why don't you optimize the "jump to ret" construction?
I mean this:
if (b)
C;
else
D;
produces:
cmp/test b
je L2
C
L1: ret
L2: D
jmp L1
instead of:
cmp/test b
je L2
C
ret
L2: D
ret
I see that there's also a greedy stack frame allocator instead
of a lazy one. Using the previous example
if (b)
C;
else
D;
when C is short and can be computed using only the scratch
registers, i.e. eax, edx and ecx, and D is complex and needs
to save/restore the remaining GP registers, GCC generates:
push max_register_usage(C,D);
test b
je L2
C
L1: pop max_register_usage(C,D);
ret
L2: D
jmp L1,
but it could do this:
test b
je L2
C
ret
L2: push register_usage(D);
D
pop register_usage(D);
ret
Best regards
Piotr Wyderski
Zobacz nasz nowy serwis - wczasy za granicą - http://hoga.travelplanet.pl/
------------------------------------------------------------
Wiosną wirusy rosną bez pamięci!dlatego do pakietów wielostanowiskowych
mks_vir dokładamy Mobile Disks. Sprawdź:
http://www.mks.com.pl/promocja-mobile.html
More information about the Gcc
mailing list