for review: deforestation [4/4]

Fergus Henderson fjh at cs.mu.OZ.AU
Wed Mar 18 22:28:53 AEDT 1998


On 19-Feb-1998, Simon Taylor <stayl at cs.mu.OZ.AU> wrote:
> :- module pd_util.
...
> :- pred pd_util__inst_list_size(module_info::in, list(inst)::in,
> 		set(inst_name)::in, int::in, int::out) is det.
> 
> :- pred pd_util__inst_size(module_info::in, (inst)::in, int::out) is det.

These two predicates should be documented.
E.g. what exactly is the size of a recursive inst?
What's the set(inst_name) argument for?  What's the int::in argument for?

> 	% pd_util__can_reorder_goals(ModuleInfo, FullyStrict, Goal1, Goal2).
> 	%
> 	% Goals can be reordered if
> 	% - the goals are independent
> 	% - the goals are pure
> 	% - any possible change in termination behaviour is allowed
> 	% 	according to the semantics options.
> :- pred pd_util__can_reorder_goals(module_info::in, bool::in, hlds_goal::in,
> 		hlds_goal::in) is semidet.

You could also use the termination info computed by termination
analysis, couldn't you?  Any reason why you don't do that?

> pd_util__get_branch_vars_proc(PredProcId, ProcInfo, 
> 		Info0, Info, ModuleInfo0, ModuleInfo) :-

It's probably worth duplicating the comment

        % Find out which arguments of the procedure are interesting
	% for deforestation.

from the declaration here.

> pd_util__can_reorder_goals(ModuleInfo, FullyStrict, EarlierGoal, LaterGoal) :-
> 	EarlierGoal = _ - EarlierGoalInfo,
> 	LaterGoal = _ - LaterGoalInfo,
> 
> 		% Impure goals cannot be reordered.
> 	goal_info_is_pure(EarlierGoalInfo),
> 	goal_info_is_pure(LaterGoalInfo),

This is more strict that you need: it should be OK to reorder semipure goals.

Otherwise it all looks OK.

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



More information about the developers mailing list