delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/04/10/15:59:40

Message-ID: <38F2250B.1DC270D5@maths.unine.ch>
Date: Mon, 10 Apr 2000 21:01:30 +0200
From: Gautier <gautier DOT demontmollin AT maths DOT unine DOT ch>
Organization: Maths - Uni =?iso-8859-1?Q?Neuch=E2tel?=
X-Mailer: Mozilla 4.72 (Macintosh; I; PPC)
X-Accept-Language: en
MIME-Version: 1.0
Newsgroups: comp.os.msdos.djgpp
Subject: Re: inefficiency of GCC output code & -O problem
References: <38F20E7A DOT 3330E9A4 AT mtu-net DOT ru>
NNTP-Posting-Host: mac13-32.unine.ch
X-Trace: 10 Apr 2000 21:01:31 +0100, mac13-32.unine.ch
Lines: 29
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

"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 -


  webmaster     delorie software   privacy  
  Copyright 2019   by DJ Delorie     Updated Jul 2019