For review: special pred elimination test case

Tyson Richard DOWD trd at students.cs.mu.oz.au
Thu Feb 20 10:31:20 AEDT 1997


Ummmm.... DJ, can you please review this one?

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

Estimated hours taken: 0.3

tests/hard_coded/elim_special_pred.m:
tests/hard_coded/elim_special_pred.exp:
	Test case to make sure that special preds aren't eliminated
	too agressively - arg/3 makes use of the special preds possible
	in new ways - the old analysis in dead_proc_elim didn't get this
	right, so was modified to use a more conservative algorithm.
	This test is to make sure that future changes to that algorithm
	are not too agressive.

tests/hard_coded/Mmake:
tests/hard_coded/.cvsignore:
	Turn the test on, we pass it at the moment.

New File: elim_special_pred.m:
===================================================================
% Test case for elimination of special predicates in base_type_infos.
%
% We can use arg/3 and det_arg/3 to retrieve arguments of types, and 
% unify them. Analysis procedures may incorrectly conclude that
% we cannot call the unification procedure (or other procedures), and
% so eliminate it.
%
% The Mercury compiler of February 13th, 1997 failed this test - the
% test ended with a runtime error indicating that an unused predicate 
% had been called.
% 
% Author: trd

:- module elim_special_pred.
:- interface.
:- import_module io.

:- pred main(io__state::di, io__state::uo) is det.

:- implementation.

:- import_module list, int, std_util, term, map, string.

:- type enum	--->	one	;	two	;	three.

:- type fruit	--->	banana(enum).

main -->
	{ X = banana(three) },
	{ Y = banana(two) },
	{ det_arg(X, 1, XArg) },
	{ det_arg(Y, 1, YArg) },
	( 
		{ XArg = YArg }
	->
		io__write_string("same\n")
	;
		io__write_string("different\n")
	).
	

New File: elim_special_pred.exp:
===================================================================
different

Index: .cvsignore
===================================================================
RCS file: /home/staff/zs/imp/tests/hard_coded/.cvsignore,v
retrieving revision 1.9
diff -u -r1.9 .cvsignore
--- .cvsignore	1997/02/04 01:25:20	1.9
+++ .cvsignore	1997/02/19 23:13:03
@@ -31,3 +31,4 @@
 ho_solns
 write_reg1
 ho_univ_to_type
+elim_special_pred
Index: Mmake
===================================================================
RCS file: /home/staff/zs/imp/tests/hard_coded/Mmake,v
retrieving revision 1.32
diff -u -r1.32 Mmake
--- Mmake	1997/02/04 01:25:21	1.32
+++ Mmake	1997/02/19 23:09:26
@@ -13,7 +13,7 @@
 	cc_nondet_disj bidirectional address_of_builtins \
 	reverse_arith curry curry2 higher_order_syntax \
 	ho_func_reg float_reg write expand ho_solns write_reg1 \
-	ho_univ_to_type
+	ho_univ_to_type elim_special_pred
 
 #-----------------------------------------------------------------------------#
 



More information about the developers mailing list