Date: Fri, 18 Sep 1998 11:16:14 +0300 (IDT) From: Eli Zaretskii To: "John S. Fine" cc: djgpp AT delorie DOT com Subject: Re: Optimizations In-Reply-To: <36015625.62D2@erols.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk 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.