for review: deforestation [3/4]

Fergus Henderson fjh at cs.mu.OZ.AU
Fri Feb 27 18:47:52 AEDT 1998


On 19-Feb-1998, Simon Taylor <stayl at cs.mu.OZ.AU> wrote:
> deforestation(ModuleInfo0, ModuleInfo, IO0, IO) :-
> 	proc_arg_info_init(ProcArgInfo0),
> 	type_to_univ(ProcArgInfo0, UnivProcArgInfo0),
> 	Task0 = update_module_cookie(deforest__get_branch_vars_proc,
> 			UnivProcArgInfo0),
> 	process_all_nonimported_procs(Task0, Task, 
> 		ModuleInfo0, ModuleInfo1, IO0, IO1),
> 	(
> 		Task = update_module_cookie(_, UnivProcArgInfo),
> 		univ_to_type(UnivProcArgInfo, ProcArgInfo1)
> 	->	
> 		ProcArgInfo = ProcArgInfo1
> 	;
> 		error("deforestation: passes_aux stuffed up")
> 	),
> 	module_info_ensure_dependency_info(ModuleInfo1, ModuleInfo2),
> 	module_info_dependency_info(ModuleInfo2, DepInfo),
> 	hlds_dependency_info_get_dependency_ordering(DepInfo, DepOrdering),
> 	list__condense(DepOrdering, DepList),
> 	pd_info_init(ModuleInfo2, ProcArgInfo, IO1, PdInfo0),

More documentation here would be helpful.

> deforest__proc(proc(PredId, ProcId), CostDelta, SizeDelta) -->
> 	pd_info_get_module_info(ModuleInfo0),
> 	pd_info_get_io_state(IO0),
> 	{ write_proc_progress_message("% Deforesting ", 
> 		PredId, ProcId, ModuleInfo0, IO0, IO1) },
> 	pd_info_set_io_state(IO1),
> 	{ module_info_pred_proc_info(ModuleInfo0, PredId, ProcId, 
> 		PredInfo0, ProcInfo0) },
> 	pd_info_init_unfold_info(proc(PredId, ProcId), PredInfo0, ProcInfo0),
> 	{ proc_info_goal(ProcInfo0, Goal0) },
> 	deforest__goal(Goal0, Goal1),
> 	pd_info_get_proc_info(ProcInfo1),
> 	{ proc_info_set_goal(ProcInfo1, Goal1, ProcInfo2) },
> 	pd_info_get_changed(Changed),
> 
> 	( { Changed = yes } ->
> 		pd_info_get_module_info(ModuleInfo2),
> 		{ requantify_proc(ProcInfo2, ProcInfo3) },
> 		{ proc_info_goal(ProcInfo3, Goal3) },
> 		{ proc_info_get_initial_instmap(ProcInfo3,
> 			ModuleInfo2, InstMap0) },
> 		{ recompute_instmap_delta(yes, Goal3, Goal, 
> 			InstMap0, ModuleInfo2, ModuleInfo3) },
> 		pd_info_set_module_info(ModuleInfo3),
> 
> 		pd_info_get_pred_info(PredInfo),
> 		{ proc_info_set_goal(ProcInfo3, Goal, ProcInfo) },
> 		{ module_info_set_pred_proc_info(ModuleInfo3, PredId, ProcId,
> 			PredInfo, ProcInfo, ModuleInfo4) },
> 
> 		% If the determinism of some sub-goals has changed,
> 		% then we re-run determinism analysis. As with inlining.m,
> 		% this avoids problems with inlining erroneous procedures.
> 		pd_info_get_io_state(IO10),
> 		{ globals__io_get_globals(Globals, IO10, IO11) },
> 		pd_info_set_io_state(IO11),
> 		{ det_infer_proc(PredId, ProcId, ModuleInfo4, ModuleInfo5,
> 			Globals, _, _, _) },

The code doesn't quite match the comment.
Determinism analysis seems to be rerun unconditionally,
or rather if anything at all has changed.

> :- type deforest_info
> 	---> deforest_info(
> 		hlds_goal,		% earlier goal in conjunction
> 		pd_branch_info(var),	% branch_info for earlier goal
> 		list(hlds_goal),	% goals in between
> 		hlds_goal,		% later goal in conjunction
> 		pd_branch_info(var),	% branch_info for later goal
> 		set(int)		% branches for which there is
> 					% extra information about the second
> 					% goal

Do the branch numbers start at 0 or 1?

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