[m-dev.] diff: fix bug with intermodule inlining heuristic

Fergus Henderson fjh at cs.mu.OZ.AU
Fri Oct 22 14:03:34 AEST 1999


Estimated hours taken: 1

compiler/intermod.m:
	When deciding whether to put a predicate in the `.opt' file for
	intermodule inlining, add the predicate's arity to the goal size
	thresholds.  This accounts for the headvar unifications, which
	have not been optimized away at this point.  Without this change,
	the compiler was failing to do intermodule inlining for many
	simple predicates.

Workspace: /home/mercury0/fjh/mercury
Index: compiler/intermod.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/intermod.m,v
retrieving revision 1.70
diff -u -d -r1.70 intermod.m
--- intermod.m	1999/10/14 03:40:05	1.70
+++ intermod.m	1999/10/22 02:52:37
@@ -249,6 +249,12 @@
 		pred_info_procedures(PredInfo, Procs),
 		map__lookup(Procs, ProcId, ProcInfo),
 
+		% At this point, the goal size includes some dummy unifications
+		% HeadVar1 = X, HeadVar2 = Y, etc. which will be optimized away
+		% later.  To counter for this, we add the arity to the
+		% size thresholds.
+		pred_info_arity(PredInfo, Arity),
+
 		% Don't export builtins since they will be
 		% recreated in the importing module anyway.
 		\+ code_util__compiler_generated(PredInfo),
@@ -259,7 +265,7 @@
 
 		(
 			inlining__is_simple_clause_list(Clauses,
-				InlineThreshold),
+				InlineThreshold + Arity),
 			pred_info_get_markers(PredInfo, Markers),
 			\+ check_marker(Markers, no_inline),
 			proc_info_eval_method(ProcInfo, eval_normal)
@@ -268,7 +274,7 @@
 		;
 			has_ho_input(ModuleInfo, ProcInfo),
 			clause_list_size(Clauses, GoalSize),
-			GoalSize =< HigherOrderSizeLimit
+			GoalSize =< HigherOrderSizeLimit + Arity
 		;
 			Deforestation = yes,
 			% Double the inline-threshold since
@@ -279,7 +285,7 @@
 			% hence the `+1'.
 			DeforestThreshold is InlineThreshold * 2 + 1,
 			inlining__is_simple_clause_list(Clauses,
-				DeforestThreshold),
+				DeforestThreshold + Arity),
 			clause_list_is_deforestable(PredId, Clauses)
 		)
 	;

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