www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/09/20/03:46:04

Date: Sun, 20 Sep 1998 10:44:11 +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: <3602E5B7.5A48@erols.com>
Message-ID: <Pine.SUN.3.91.980920103551.406H-100000@is>
MIME-Version: 1.0

On Fri, 18 Sep 1998, John S. Fine wrote:

>   What happened?  I really did have the "-O2".  I can make tiny
> changes in the above code and suddenly get decent output.  What
> about the above code makes the optimizer go insane?

I don't know, it's pretty tricky.  Unless you really need to understand
how the optimizer works, you should be fine just rearranging the source so
it emits a better code.

One thing that sometimes helps in C is to explicitly tell the compiler
that the functions called inside the loop have no side effects, by
declaring it with __attribute__((const)).  This is described in GCC docs,
and sometimes has a dramatic effect on code generated for loops that call
functions. 

- Raw text -


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