[m-dev.] diff: clear unnecessary relation references

Simon Taylor stayl at cs.mu.OZ.AU
Wed Jun 23 14:26:41 AEST 1999


Estimated hours taken: 0.5

compiler/rl_liveness.m:
	Don't keep unnecessary references to the relation
	updated by a `union_diff' or `insert' instruction.

Index: rl_liveness.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/compiler/rl_liveness.m,v
retrieving revision 1.2
diff -u -u -r1.2 rl_liveness.m
--- rl_liveness.m	1999/05/19 04:42:43	1.2
+++ rl_liveness.m	1999/06/16 05:35:49
@@ -426,7 +426,7 @@
 		set__difference(OutputSet, LiveRels0, StillBornRels),
 		set__union(KilledRels0, StillBornRels, KilledRels1),
 		set__to_sorted_list(KilledRels1, KilledRels),
-		list__map(rl_liveness__drop_rel, KilledRels, PostInstrs),
+		list__map(rl_liveness__drop_rel, KilledRels, PostInstrs0),
 
 		(
 			% Attach to the call the set of relations which
@@ -437,6 +437,7 @@
 			set__list_to_set(Inputs, InputSet),
 			set__intersect(LiveRels1, InputSet, LiveInputs),
 			PreInstrs = [],
+			PostInstrs1 = [],
 			Instr = call(ProcInputs, CallInputs, CallOutputs,
 					LiveInputs) - Comment
 		;
@@ -452,7 +453,8 @@
 			),
 			CopyRel = output_rel(CopyRelation, _),
 			Instr = union_diff(UoOutput, CopyRelation,
-				Input, Diff, Index, no) - Comment
+				Input, Diff, Index, no) - Comment,
+			PostInstrs1 = [unset(CopyRelation) - ""]
 		;
 			% Make sure there is only one reference to the
 			% destructively updated input to an insert.
@@ -466,15 +468,24 @@
 			),
 			CopyRel = output_rel(CopyRelation, _),
 			Instr = insert(UoOutput, CopyRelation,
-				Input, InsertType, no) - Comment
+				Input, InsertType, no) - Comment,
+			PostInstrs1 = [unset(CopyRelation) - ""]
 		;
 			Instr = Instr0,
-			PreInstrs = []
+			PreInstrs = [],
+			PostInstrs1 = []
 		),
 
 		% Add the instructions to unset the newly dead 
 		% relation variables after the instruction.
-		list__condense([PreInstrs, [Instr | PostInstrs], Instrs0],
+		list__condense(
+			[
+			PreInstrs,
+			[Instr],
+			PostInstrs0,
+			PostInstrs1,
+			Instrs0
+			],
 			Instrs)
 	).
 
--------------------------------------------------------------------------
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