www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/09/18/05:45:45

Date: Fri, 18 Sep 1998 11:16:14 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: "John S. Fine" <johnfine AT erols DOT com>
cc: djgpp AT delorie DOT com
Subject: Re: Optimizations
In-Reply-To: <36015625.62D2@erols.com>
Message-ID: <Pine.SUN.3.91.980918110932.17626E-100000@is>
MIME-Version: 1.0

On Thu, 17 Sep 1998, John S. Fine wrote:

>   While debugging I noticed many place where gcc has
> generated crude code that is both larger and slower
> than I would have expected.

Maybe it's a good idea to post code fragments, the code emitted by GCC, 
and what you'd expect it to emit.  Sometimes GCC is smarter than you 
might think.  In some rare cases it is indeed pretty dumb.  You've posted 
some details, but I think a specific example with specific machine code 
is better.

>   I am using -O2 and no other optimization switches.
> Are there other switches that are appropriate to this
> project?

Did you try the switches and the advice in section 14.2 of the DJGPP FAQ 
list (v2/faq211b.zip from the same place you get DJGPP).

>   GCC also adds NOPs to align many branch targets to
> dword boundaries.  In my project, that usually slows
> the code down, because the harm done by extra cache
> misses outweighs the benefits of aligning.  Can I
> individually turn off optimizations like that while
> generally optimizing for speed rather than space?

Yes, check out the "Optimization Options" section of the GCC on-line 
manual.

>   The most common form of bad code seems to be computing
> a value in one register and then moving it to the register
> where it is needed.  In all these cases, there was nothing
> preventing it from computing the value in the correct
> register to begin with.  Are there any options to make it
> spend more time during compilation thinking about register
> selection, so it won't get those wrong?

An example would help here.  GCC usually ``thinks'' about register 
allocation quite a bit.  Maybe -fno-strength-reduce will help (it's 
in the FAQ), but it's impossible to know without seeing actual code.

- Raw text -


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