Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] flow optimisation q
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-01-02 (16:14)
From: skaller <skaller@o...>
Subject: [Caml-list] flow optimisation q
Nothing to do with ocaml, but some people here
might know.. Suppose there is a set of
primitive procedures pr1 pr2 and a procedure constructor:

proc = proc list 

which defines a new procedure to be a list of calls
to other procedures, with mutual recursion allowed.

A special procedure is the empty 
procedure whose call list is empty.

Problem: remove all empty procedures
(and of course calls to them).

My current algorithm is functional:
make a new set of procedures which
(a) excludes empty procedures
(b) has calls to empty procedures elided

To make this solve the problem requires
repeated application until there are no
empty procedures left.

I get the feeling there should be a way to do it
a bit more efficiently :-)

A generalisation of this problem is: how to inline?
If a procedure is inlined on all uses, it can be 
discarded. However, one cannot just inline everything,
code gets too bloated. It would seem the length
of a candidate helps decide whether to inline it
or not. However the length isn't well specified,
since calls in *that* procedure might be inlined too.
For example:

proc a {b c d}
proc b {x y z}
proc c {x y z}
proc d {x y z}

If you inline into a first, you get

proc a {x y z x y z x y z}

which is too big to inline, but if you inline
a into another procedure first, you might then
inline b, c, and d, since each is small enough.
[Recursion introduces a similar problem]

Any ideas on how to think about a strategy for this?

[One idea is.. inline everything, and then remove
common code segments .. seems very general but
I don't see any easy way to recognize common
code segments]

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: