[m-dev.] [reuse] diff: repair vanishing conditions for reuse

Nancy Mazur Nancy.Mazur at cs.kuleuven.ac.be
Mon Oct 16 04:27:43 AEDT 2000


Hi,


===================================================================


Estimated hours taken: 5

A temporary fix of a problem which has a bit more of theoretical roots.
The problem was that some conditions, which should propagate, didn't
(i.e. became `always'). The reason for this is that when translating 
nodes which are being reused in the called predicate to the current
environment, it really looks at the full nodes and not at the subparts
of it. If the nodes itself are not related to a headvariable, then 
the condition becomes `always'. 
This must have been a bug which was always there but only showed up
now. 

sr_indirect.m:
	extra verbosity. 
	Bugfix: when updating a reuse_condition to the current environment, 
	make sure to normalize the aliases first (e.g.: the tail of 
	a list will be mapped unto list itself) so that you really 
	can check for how the nodes a call is reusing are related to 
	the headvariables. 
	This seems to me as a temporary fix and should be once checked 
	if more time is available.
	
sr_direct.m:
	extra verbosity. 


Index: sr_direct.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/Attic/sr_direct.m,v
retrieving revision 1.1.2.9
diff -u -r1.1.2.9 sr_direct.m
--- sr_direct.m	2000/10/15 11:26:17	1.1.2.9
+++ sr_direct.m	2000/10/15 17:06:48
@@ -26,7 +26,7 @@
 
 :- implementation.
 
-:- import_module map, list, set, std_util, int, bool.
+:- import_module map, list, set, std_util, int, bool, string.
 :- import_module assoc_list.
 :- import_module require.
 
@@ -65,7 +65,27 @@
 	maybe_write_string(VeryVerbose, "%\tchoice analysis..."),
 	{ sr_choice__process_goal(strategy(same_cons_id, random),
 			Goal1, Goal, MaybeReuseConditions) },
-	maybe_write_string(VeryVerbose, "done.\n"),
+	(
+		{ VeryVerbose = yes } 
+	->
+		(
+			{ MaybeReuseConditions = yes(Cs) }
+		->
+			{ list__length( Cs, LCs ) },
+			{ reuse_conditions_simplify( Cs, RCs ) }, 
+			{ list__length( RCs, LRCs ) }, 
+			{ string__int_to_string( LCs, LCS )}, 
+			{ string__int_to_string( LRCs, LRCS ) }, 
+			{ string__append_list([" done (", LCS, " / ", 
+					LRCS, ").\n"], Msg3) }, 
+			io__write_string( Msg3 )
+		; 
+			io__write_string( "done (no direct reuse).\n")
+		)
+	; 
+		[]
+	), 
+		
 	{ proc_info_set_reuse_information( ProcInfo2, MaybeReuseConditions, 
 			ProcInfo3 ) },
 	{ proc_info_set_goal( ProcInfo3, Goal, ProcInfo ) },
Index: sr_indirect.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/Attic/sr_indirect.m,v
retrieving revision 1.1.2.3
diff -u -r1.1.2.3 sr_indirect.m
--- sr_indirect.m	2000/10/15 11:26:17	1.1.2.3
+++ sr_indirect.m	2000/10/15 17:06:49
@@ -180,7 +180,8 @@
 		-> 
 			{ list__length(Conditions, Length) }, 
 			{ string__int_to_string(Length, LengthS ) }, 
-			{ string__append_list(["%\tNumber of conditions:\t",
+			{ string__append_list(
+					["%\tNumber of conditions (before):\t",
 					LengthS, "\n"], Msg2) } ,
 			maybe_write_string(VeryVerbose, Msg2)
 		; 
@@ -217,7 +218,27 @@
 		indirect_reuse_pool_get_memo_reuse( Pool, Memo ), 
 		sr_fixpoint_table_new_reuse( PredProcId,
 				Memo, Goal, FP1, FPout )
-	}.
+	},
+	(
+		{ VeryVerbose = no }
+	->
+		[]
+	;
+		{ sr_fixpoint_table_get_final_reuse(PredProcId,M1,_,FPout) }, 
+
+		( 
+			{ M1 = yes( Conditions1 ) }
+		-> 
+			{ list__length(Conditions1, Length1) }, 
+			{ string__int_to_string(Length1, LengthS1 ) }, 
+			{ string__append_list(
+					["%\tNumber of conditions (after):\t",
+					LengthS1, "\n"], Msg21) } ,
+			maybe_write_string(VeryVerbose, Msg21)
+		; 
+			maybe_write_string(VeryVerbose, "%\tNo reuse.\n")
+		)
+	).
 
 %-----------------------------------------------------------------------------%
 %-----------------------------------------------------------------------------%
@@ -269,7 +290,7 @@
 				PredId, ProcId, ActualVars, Alias0, 
 				Pool0, Pool,
 				Info0, Info, 
-				FP0, FP)
+				FP0, FP, _)
 		),
 		pa_run__extend_with_call_alias( HLDS, ProcInfo, 
 	    		PredId, ProcId, ActualVars, Alias0, Alias),
@@ -419,15 +440,16 @@
 			list(prog_var), alias_as, 
 			indirect_reuse_pool, indirect_reuse_pool, 
 			hlds_goal_info , hlds_goal_info, 
-			sr_fixpoint_table__table, sr_fixpoint_table__table).
+			sr_fixpoint_table__table, sr_fixpoint_table__table, 
+			bool).
 :- mode call_verify_reuse( in, in, in, in, in, in, 
 				in, out, 
 				in, out,
-				in, out) is det.
+				in, out, out) is det.
 
 call_verify_reuse( ProcInfo, HLDS, PredId0, ProcId0, ActualVars, Alias0, 
 					Pool0, Pool, 
-					Info0, Info, FP0, FP ) :- 
+					Info0, Info, FP0, FP, YesNo ) :- 
 
 	module_info_structure_reuse_info(HLDS, ReuseInfo),
 	ReuseInfo = structure_reuse_info(ReuseMap),
@@ -450,7 +472,8 @@
 		memo_reuse_top(FormalMemo)
 	->
 		Pool = Pool0,
-		Info = Info0
+		Info = Info0, 
+		YesNo = no
 	;
 		memo_reuse_rename( ProcInfo0, ActualVars, FormalMemo, 
 					Memo ), 
@@ -478,10 +501,12 @@
 			indirect_reuse_pool_add( HLDS, ProcInfo,
 				Memo, LFUi, LBUi, 
 				Alias0, Pool0, Pool),
-			goal_info_set_reuse(Info0, reuse(reuse_call), Info)
+			goal_info_set_reuse(Info0, reuse(reuse_call), Info),
+			YesNo = yes
 		;
 			Pool = Pool0,
-			Info = Info0
+			Info = Info0,
+			YesNo = no
 		)
 	).
 	
@@ -557,6 +582,8 @@
 		require__error("(sr_indirect) indirect_reuse_pool_least_upper_bound_disjunction: list is empty")
 	).
 
+:- import_module instmap.
+
 indirect_reuse_pool_least_upper_bound( Pool1, Pool2, Pool ):-
 	Pool1 = pool( HVS, Memo1 ), 
 	Pool2 = pool( _, Memo2 ), 
@@ -564,11 +591,17 @@
 	Pool = pool(HVS, Memo). 
 
 indirect_reuse_pool_add( HLDS, ProcInfo, MemoReuse, 	
-		LFUi, LBUi, Alias, Pool0, Pool) :- 
+		LFUi, LBUi, Alias0, Pool0, Pool) :- 
 
 	(
 		MemoReuse = yes(OldConditions)
 	->
+			% XXX instmap here simply initialized, as currently
+			% it's not used in the normalization anyway.. 	
+		instmap__init_reachable(InstMap0), 
+		pa_alias_as__normalize( ProcInfo, HLDS, InstMap0, 
+				Alias0, Alias), 
+		
 		Pool0 = pool( HVS, ExistingMemo), 
 		list__map(
 			reuse_condition_update(ProcInfo, HLDS, 

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