[m-dev.] Loop flattening and LCPS optimization

Fergus Henderson fjh at cs.mu.OZ.AU
Tue Apr 24 02:17:03 AEST 2001


On 23-Apr-2001, Ralph Becket <rbeck at microsoft.com> wrote:
> What does mmc do with nested loops at the moment, anyway?

The front-end doesn't do anything special with them;
they're just tail-recursive procedures which contain
(non-tail) calls to other tail-recursive procedures.

For questions like this, it depends which back-end you're using.
The answer is likely to be different for the MLDS back-end than
it is for the LLDS back-end.

For the MLDS back-end, we'll generate a separate C function
for each tail-recursive procedure.  If you're lucky, and
you pass the right options, the C compiler may be able to
inline the non-tail call, so you end up with nested C loops,
and the C compiler can apply it's usual optimizations.

(We could do this ourselves, using an MLDS-to-MLDS inlining pass,
but currently that isn't implemented.)

For the LLDS back-end, I think the compiler won't inline the
non-tail call.


In general, currently we don't do a great job of loop optimization in
the Mercury compiler.  Another optimization which might pay quite well,
at least for some programs, is hoisting out loop-invariant computations.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
                                    |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list