Message-ID: <3600B3C4.9CCDAEF3@mailexcite.com> Date: Thu, 17 Sep 1998 03:01:25 -0400 From: Doug Gale MIME-Version: 1.0 Newsgroups: comp.os.msdos.djgpp Subject: Re: djgpp and optimizations References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: oshawappp11.idirect.com Organization: "Usenet User" Lines: 33 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Eli Zaretskii wrote: > On Tue, 15 Sep 1998, Arthur wrote: > > > What does -fstrength-reduce do, exactly, and why do some people report such > > a huge speed increase when using it? > > -fstrength-reduce replaces expensive instruction by less expensive > ones. For example, multiplication is replaced with additions or bit > shifts, etc. > > The problem is that this usually needs extra registers, and x86 has a > few of them to spare. If a function doesn't use too many registers, > then -fstrength-reduce can be a big win; but if they are all used, > -fstrength-reduce in a loop can mean a significant slowdown, since GCC > will have to constantly reload some of the regsiters. Oh, -fstrength-reduce does that too? I read somewhere that -fstrength-reduce it is more of a loop optimization that does stuff like converting for (i = 0; i < 100; i++) into for (temp = 100, i = 0; --temp; i++) saving a cycle or two at the end of each iteration, and a few bytes of code per loop.