From: "John S. Fine" Newsgroups: comp.os.msdos.djgpp Subject: Re: Optimizations Date: Mon, 21 Sep 1998 13:47:55 -0400 Lines: 34 Message-ID: <3606914B.62A6@erols.com> References: Reply-To: johnfine AT erols DOT com NNTP-Posting-Host: 207-172-243-172.s45.as9.bsd.erols.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk 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/