[mercury-users] accumulator introduction

Peter Ross petdr at cs.mu.OZ.AU
Wed Jul 12 18:37:15 AEST 2000


On Mon, Jul 10, 2000 at 08:06:28PM +1000, Michael Day wrote:
> 
> > > Is there any way for Mercury to automatically convert this predicate to
> > > use an accumulator, or is it condemned to overflow the detstack forever?
> > > 
> > It is now in the latest rotd, you need to pass --introduce-accumulators
> > and --intermodule-optimization (needed to get the declaration that + is
> > associative).
> 
> That's very nice, and the performance is comparable to a C for loop. Any
> chance of the MLDS optimising simple accumulating functions into an actual
> for loop in the future, or is this not how it will work?

Essentially tail recursive functions are implemented as for loops.

> Is gcc any better at optimising for loops than hand rolled goto loops?

No idea.

Pete
--------------------------------------------------------------------------
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