[m-rev.] [reuse] diff: bug fixes

Peter Ross peter.ross at miscrit.be
Wed Mar 14 03:07:25 AEDT 2001


Hi,


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


Estimated hours taken: 2
Branches: reuse

Various bug fixes.

compiler/options.m:
    There is no constraint called within_n_cells, change it to
    within_n_cells_difference.

compiler/sr_choice.m:
    Both apply constraint and select reuses where being initialised with
    the wrong state at the start of an else branch.
    Remove duplicates from the list of possible cons_ids before storage,
    as this simplifies debugging and as well as saving space.


Index: options.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/options.m,v
retrieving revision 1.288.2.9
diff -u -r1.288.2.9 options.m
--- options.m	2001/03/13 12:10:55	1.288.2.9
+++ options.m	2001/03/13 16:02:54
@@ -708,7 +708,7 @@
 	termination_path_limit	-	int(256),
 	split_c_files		-	bool(no),
 
-	structure_reuse_constraint -	string("within_n_cells"),
+	structure_reuse_constraint - 	string("within_n_cells_difference"),
 	structure_reuse_constraint_arg - int(0),
 	structure_reuse_selection -	string("lifo")
 ]).
Index: sr_choice.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/Attic/sr_choice.m,v
retrieving revision 1.1.2.15
diff -u -r1.1.2.15 sr_choice.m
--- sr_choice.m	2001/03/13 12:10:59	1.1.2.15
+++ sr_choice.m	2001/03/13 16:02:56
@@ -106,10 +106,11 @@
 
 apply_constraint(Constraint, Goal0 - GoalInfo, Goal - GoalInfo) -->
 	{ Goal0 = if_then_else(Vars, If0, Then0, Else0, SM) },
+	=(BeforeIfInfo),
 	apply_constraint(Constraint, If0, If),
 	=(IfInfo),
 	{ apply_constraint(Constraint, Then0, Then, IfInfo, ThenInfo) },
-	{ apply_constraint(Constraint, Else0, Else, IfInfo, ElseInfo) },
+	{ apply_constraint(Constraint, Else0, Else, BeforeIfInfo, ElseInfo) },
 	merge(ThenInfo),
 	merge(ElseInfo),
 	{ Goal = if_then_else(Vars, If, Then, Else, SM) }.
@@ -200,7 +201,7 @@
 			CandidateVar = Candidate0 ^ var,
 			multi_map__search(Map, CandidateVar, ConsIds),
 			list__remove_dups(ConsIds, [ConsId]),
-			Candidate = Candidate0 ^ cons_ids := yes(ConsIds)
+			Candidate = Candidate0 ^ cons_ids := yes([ConsId])
 		)}
 	;
 		{ Constraint = within_n_cells_difference(Difference) },
@@ -213,7 +214,8 @@
 		{ P = (pred(Candidate::out) is nondet :- 
 			list__member(Candidate0, PossibleCandidates),
 			CandidateVar = Candidate0 ^ var,
-			multi_map__search(Map, CandidateVar, ConsIds),
+			multi_map__search(Map, CandidateVar, ConsIds0),
+			list__remove_dups(ConsIds0, ConsIds),
 			cons_id_arity(ConsId, Arity),
 			all [ReuseConsId] (
 				list__member(ReuseConsId, ConsIds)
@@ -313,12 +315,12 @@
 
 select_reuses(Selection, Goal0 - GoalInfo, Goal - GoalInfo) -->
 	{ Goal0 = if_then_else(Vars, If0, Then0, Else0, SM) },
-	select_reuses(Selection, If0, If),
 	selection_start_branch,
-	=(IfInfo),
+	=(BeforeIfInfo),
+	{ select_reuses(Selection, If0, If, BeforeIfInfo, IfInfo) },
 	{ select_reuses(Selection, Then0, Then, IfInfo, ThenInfo) },
-	{ select_reuses(Selection, Else0, Else, IfInfo, ElseInfo) },
 	selection_merge(ThenInfo),
+	{ select_reuses(Selection, Else0, Else, BeforeIfInfo, ElseInfo) },
 	selection_merge(ElseInfo),
 	selection_end_branch,
 	{ Goal = if_then_else(Vars, If, Then, Else, SM) }.

--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list