Mail Archives: djgpp/2000/04/10/15:59:40
"Alexei A. Frounze":
> Why GCC output too much redundant code?
With which optimisation level do you mean that ?
> I mean, it always put values to the CPU registers, although it's possible to
> make the same operation w/o taking registers?
If you observed that with -O2, it is an optimisation strategy:
when the most data are loaded in registers, the program has more chances to
run at a speed that resembles the processor speed than at main board speed (roughly said...).
It means to have less data to communicate with RAM, which takes big time
resources. On Intel x86s there is not much to do - there are so few registers - but
anyway GCC is very smart at register mapping !
On processors with more recent design like Alpha or even the Motorola 68K, optimisers
try to exploit at best the 36 (16) registers and the result is beautiful.
> Also why GCC does type cast of byte/word <-> dword values so awful? It allocates
> some extra bytes on the stack, put values there and get them back...
On 32-bit x86 it is better to use only 8 of 32 bits than allocating and manipulating
1 byte... But maybe you just hit a weak typing problem (I mean GCC hesitates about
the precise types, the sizes and so on) ? You should try an equivalent test on a very
strong typed GCC front-end like GNAT...
HTH
______________________________________________________
Gautier -- http://members.xoom.com/gdemont/gsoft.htm
- Raw text -