[m-dev.] for review: get value numbering working with LCO

David Overton dmo at cs.mu.OZ.AU
Fri Jun 4 01:26:10 AEST 1999


Hi,

Zoltan, would you please review this.  The changes seemed to be a lot
simpler than I was expecting -- I hope I haven't missed something.

With this change and the other two I'm about to post, the alias branch
now bootchecks with -O6 --optimize-constructor-lastcall.
As earlier noted, three test cases in the hardcoded directory
(type_spec, ho_order and ho_order2) still fail.

Estimated hours taken: 10

Get value numbering working with mem_ref lvals and mem_addr rvals.

compiler/vn_block.m:
	Ensure that assignments to mem_refs are never removed by value
	numbering.

compiler/vn_verify.m:
	Include clauses for mem_ref and mem_addr in some predicates
	from which they were missing.

Index: vn_block.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/vn_block.m,v
retrieving revision 1.49.2.6
diff -u -r1.49.2.6 vn_block.m
--- 1.49.2.6	1998/09/25 01:09:13
+++ vn_block.m	1999/05/28 02:14:54
@@ -227,10 +227,16 @@
 		% redo() or fail() operation. We compensate here by ensuring
 		% that assignments to stack variables are not removed by
 		% value numbering.
+		% 
+		% We also ensure that assignments to mem_refs are not
+		% removed.
 		%
 		% The condition of this test subsumes the condition that used
 		% to be here, which is therefore commented out above.
-		( Lval = stackvar(_) ; Lval = framevar(_) )
+		( Lval = stackvar(_) 
+		; Lval = framevar(_)
+		; Lval = mem_ref(_)
+		)
 	->
 		Specials = [Vnlval | LeftSpecials]
 	;
@@ -812,6 +818,7 @@
 		; Vnlval = vn_curfr
 		; Vnlval = vn_maxfr
 		; Vnlval = vn_succip
+		; Vnlval = vn_mem_ref(_)
 		)
 	->
 		map__set(FlushEntry0, Vnlval, Vn, FlushEntry1),
Index: vn_verify.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/vn_verify.m,v
retrieving revision 1.13.2.4
diff -u -r1.13.2.4 vn_verify.m
--- 1.13.2.4	1999/05/05 01:25:52
+++ vn_verify.m	1999/05/26 02:25:50
@@ -220,6 +220,7 @@
 vn_verify__subst_access_vns(vn_sp, [], sp).
 vn_verify__subst_access_vns(vn_field(T, _, _), [R1, R2], field(T, R1, R2)).
 vn_verify__subst_access_vns(vn_temp(T, N), [], temp(T, N)).
+vn_verify__subst_access_vns(vn_mem_ref(_), [R], mem_ref(R)).
 
 :- pred vn_verify__subst_sub_vns(vnrval, list(rval), vn_tables, rval).
 :- mode vn_verify__subst_sub_vns(in, in, in, out) is semidet.
@@ -231,6 +232,8 @@
 vn_verify__subst_sub_vns(vn_create(T,A,AT,U,L,M), [], _, create(T,A,AT,U,L,M)).
 vn_verify__subst_sub_vns(vn_unop(Op, _), [R], _, unop(Op, R)).
 vn_verify__subst_sub_vns(vn_binop(Op, _, _), [R1, R2], _, binop(Op, R1, R2)).
+vn_verify__subst_sub_vns(vn_heap_addr(_, Tag, Field), [R], _,
+		mem_addr(heap_ref(R, Tag, Field))).
 
 %-----------------------------------------------------------------------------%
 %-----------------------------------------------------------------------------%
@@ -402,6 +405,8 @@
 vn_verify__tags_lval(lvar(_), _) :-
 	error("found lvar in vn_verify__tags_lval").
 vn_verify__tags_lval(temp(_, _), _).
+vn_verify__tags_lval(mem_ref(Rval), NoDeref) :-
+	vn_verify__tags_rval(Rval, NoDeref).
 
 :- pred vn_verify__tags_rval(rval, set(rval)).
 :- mode vn_verify__tags_rval(in, in) is semidet.
@@ -419,6 +424,17 @@
 vn_verify__tags_rval(binop(_, Rval1, Rval2), NoDeref) :-
 	vn_verify__tags_rval(Rval1, NoDeref),
 	vn_verify__tags_rval(Rval2, NoDeref).
+vn_verify__tags_rval(mem_addr(MemRef), NoDeref) :-
+	vn_verify__tags_mem_ref(MemRef, NoDeref).
+
+:- pred vn_verify__tags_mem_ref(mem_ref, set(rval)).
+:- mode vn_verify__tags_mem_ref(in, in) is semidet.
+
+vn_verify__tags_mem_ref(stackvar_ref(_), _).
+vn_verify__tags_mem_ref(framevar_ref(_), _).
+vn_verify__tags_mem_ref(heap_ref(Rval, _, _), NoDeref) :-
+	vn_verify__tags_rval(Rval, NoDeref).
+
 
 	% If the tag of an rval is tested in the condition of an if_val,
 	% that rval should not be dereferenced in previous statements.
-- 
David Overton       Department of Computer Science & Software Engineering
MEngSc Student      The University of Melbourne, Australia
+61 3 9344 9159     http://www.cs.mu.oz.au/~dmo
--------------------------------------------------------------------------
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