delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2001/09/18/09:33:36

Date: Tue, 18 Sep 2001 16:15:37 +0300 (WET)
From: Andris Pavenis <pavenis AT lanet DOT lv>
X-Sender: pavenis AT ieva06
To: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
Cc: djgpp-workers AT delorie DOT com
Subject: Re: GCC 2.9x and 3.x produces larger code
In-Reply-To: <2561-Tue18Sep2001144320+0300-eliz@is.elta.co.il>
Message-ID: <Pine.A41.4.05.10109181612001.13924-100000@ieva06>
MIME-Version: 1.0
Reply-To: djgpp-workers AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com


On Tue, 18 Sep 2001, Eli Zaretskii wrote:

> > Date: Tue, 18 Sep 2001 11:24:42 +0300 (WET)
> > From: Andris Pavenis <pavenis AT lanet DOT lv>
> > 
> > I think one of the reasons is code and data alignment. For example 
> > gcc-3.0.1 Linux to DJGPP cross-compiler generates:
> > 	'.p2align 4' before procedure code
> > 	'.p2align 4,,7' in some other places inside procedure (like
> > 		before then begin of loop)
> 
> I don't think so: in two object files I compared (after "objdump -d"),
> I counted only 269 nop instructions, which is 269 bytes.  That object
> file was 1.5KB larger when compiled with GCC 3.0.1.

GAS uses not only NOP for alignment, so counting nop instructions doesn't
show real size increase. Here is an example output from 
'i586-pc-msdosdjgpp-gcc -c -O2 -Wa,-a ...':

  20 0010 8B4D0C                movl    12(%ebp), %ecx
  21 0013 8B7508                movl    8(%ebp), %esi
  22 0016 85C9                  testl   %ecx, %ecx
  23 0018 7421                  je      L30
  24 001a 8DB60000              .p2align 4,,7
  24      0000
  25                    L27:
  26 0020 89F0                  movl    %esi, %eax
  27 0022 C1FE04                sarl    $4, %esi
  28 0025 83E00F                andl    $15, %eax
  29 0028 83F809                cmpl    $9, %eax

Also alignment in data sections is done by filling with zeros.

> 
> > These alignment instructions are generated also by gcc-2.95.3, so I think
> > it would be more correct to compare with that version when compiler 
> > options for optimizing size are being used.
> 
> Comparison with 2.95.3 yields similar results; that is, 2.95.3 also
> produces larger code.
> 

Andris


- Raw text -


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