Mail Archives: djgpp/1998/09/21/15:00:45
Eli Zaretskii wrote:
>
> 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.
The code I posted could be fixed by almost any rearrange. In fact
it took me a long time to find that short a piece of code that
confused the optimizer that way.
The point is that the code I started with causes the same
optimizer failure and there is no obvious way to rearrange
that code to ovoid it. If I knew why the simple code confuses
the optimizer, I might know how to deal with real code. (Or
I might have a bug report for whoever takes those. The
optimizer gets so confused in this case, it is hard to
believe it is not a bug).
> 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.
All of my routines in the entire project have side effects.
--
http://www.erols.com/johnfine/
http://www.geocities.com/SiliconValley/Peaks/8600/
- Raw text -