[m-rev.] diff: re-enable --optimize-duplicate-calls
Fergus Henderson
fjh at cs.mu.OZ.AU
Thu Dec 6 20:05:16 AEDT 2001
I'm just running a bootcheck... I'll go ahead and commit this if it passes.
Branches: main
Estimated hours taken: 1
compiler/options.m:
Enable the `--optimize-duplicate-calls' option at `-O2',
like we used to do, since the bug that required it to be
disabled has long since been fixed
(it was fixed since 1999/06/30, when we moved the
polymorphism.m pass to occur before mode analysis).
compiler/common.m:
Add a comment to clarify the interface.
tests/hard_coded/Mmakefile:
tests/hard_coded/dupcall_impurity.m:
tests/hard_coded/dupcall_impurity.exp:
Add a test case to test that duplicate call optimization
doesn't mis-optimize impure calls.
Workspace: /home/earth/fjh/ws-earth3/mercury
Index: compiler/common.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/common.m,v
retrieving revision 1.59
diff -u -d -r1.59 common.m
--- compiler/common.m 13 Oct 2000 13:55:16 -0000 1.59
+++ compiler/common.m 6 Dec 2001 07:40:33 -0000
@@ -48,8 +48,9 @@
% Check whether this call has been seen before and is replaceable, if
% so produce assignment unification for the non-local output variables,
% and give a warning.
- % A call is replaceable if it has no uniquely moded outputs and no
- % destructive inputs.
+ % A call is considered replaceable if it has no uniquely moded outputs
+ % and no destructive inputs.
+ % It is the caller's responsibility to check that the call is pure.
:- pred common__optimise_call(pred_id, proc_id, list(prog_var), hlds_goal_expr,
hlds_goal_info, hlds_goal_expr, simplify_info, simplify_info).
Index: compiler/options.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/options.m,v
retrieving revision 1.346
diff -u -d -r1.346 options.m
--- compiler/options.m 11 Nov 2001 10:13:10 -0000 1.346
+++ compiler/options.m 6 Dec 2001 07:20:20 -0000
@@ -1732,14 +1732,7 @@
common_struct - bool(yes),
user_guided_type_specialization
- bool(yes),
-/****
-% XXX optimize_duplicate_calls is broken --
-% it doesn't take type information into account.
-% See tests/hard_coded/dupcall_types_bug.m.
-% We should re-enable the optimization only
-% when we have fixed that bug.
optimize_duplicate_calls - bool(yes),
-****/
simple_neg - bool(yes),
optimize_rl - bool(yes),
Index: tests/hard_coded/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/hard_coded/Mmakefile,v
retrieving revision 1.135
diff -u -d -r1.135 Mmakefile
--- tests/hard_coded/Mmakefile 22 Nov 2001 11:37:17 -0000 1.135
+++ tests/hard_coded/Mmakefile 6 Dec 2001 07:34:03 -0000
@@ -37,6 +37,7 @@
det_in_semidet_cntxt \
division_test \
dupcall_types_bug \
+ dupcall_impurity_bug \
elim_special_pred \
eqv_type_bug \
erroneous_liveness \
Index: tests/hard_coded/dupcall_impurity.exp
===================================================================
RCS file: tests/hard_coded/dupcall_impurity.exp
diff -N tests/hard_coded/dupcall_impurity.exp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/hard_coded/dupcall_impurity.exp 6 Dec 2001 07:32:38 -0000
@@ -0,0 +1,4 @@
+0
+1
+2
+3
Index: tests/hard_coded/dupcall_impurity.m
===================================================================
RCS file: tests/hard_coded/dupcall_impurity.m
diff -N tests/hard_coded/dupcall_impurity.m
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/hard_coded/dupcall_impurity.m 6 Dec 2001 09:00:21 -0000
@@ -0,0 +1,43 @@
+% This is a test case to test that duplicate call elimination
+% takes purity into account.
+
+:- module dupcall_impurity_bug.
+:- interface.
+:- import_module io.
+
+:- impure pred main(io__state::di, io__state::uo) is det.
+
+:- implementation.
+:- import_module string.
+
+:- impure pred test1(io__state::di, io__state::uo) is det.
+:- impure pred test2(io__state::di, io__state::uo) is det.
+
+main -->
+ impure test1,
+ impure test2.
+
+test1 -->
+ { impure next_x(X0) },
+ { impure next_x(X1) },
+ print(X0), nl,
+ print(X1), nl.
+
+test2 -->
+ { semipure get_x(X0) },
+ { impure incr_x },
+ { semipure get_x(X1) },
+ print(X0), nl,
+ print(X1), nl.
+
+:- semipure pred get_x(int::out) is det.
+:- impure pred next_x(int::out) is det.
+:- impure pred incr_x is det.
+
+:- pragma c_header_code("extern int my_global;").
+:- pragma c_code("int my_global;").
+
+:- pragma c_code(get_x(X::out), "X = my_global;").
+:- pragma c_code(next_x(X::out), "X = my_global++;").
+:- pragma c_code(incr_x, "my_global++;").
+
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
The University of Melbourne | of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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