[mercury-users] accumulator introduction

Fergus Henderson fjh at cs.mu.OZ.AU
Mon Jul 17 17:07:46 AEST 2000


On 17-Jul-2000, Zoltan Somogyi <zs at cs.mu.OZ.AU> wrote:
> On 10-Jul-2000, Michael Day <mcda at students.cs.mu.oz.au> wrote:
> > Is gcc any better at optimising for loops than hand rolled goto loops?
> 
> Most current compilers will treat a hand rolled goto loop the same way as
> they will a while loop, i.e. the two should generate the same code if the
> labels involved in the hand-written loop are local. I would be very surprised
> if gcc were different.

As I understand it, from reading the gcc source code,
GNU C emits "loop begin" and "loop end" notes in the
generated RTL code for loops written with `do', `while',
or `for', but not for loops written with `goto'.
These "loop begin" and "loop end" notes are then used
to compute loop nesting depth counts, which are then
used in the heuristics for various optimizations,
for example as weights on the variable usage counts
to decide which variables to store in registers.

So I think gcc will, at least in some cases, do a better job of
optimizing loops written with looping constructs than those written
using `goto'.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3        |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-users mailing list
post:  mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the users mailing list