[m-dev.] diff: fix bug that broke cut_test

Fergus Henderson fjh at cs.mu.OZ.AU
Sun Feb 4 09:37:19 AEDT 2001


For both main and release branches.

----------

Estimated hours taken: 4

Fix a bug which caused an internal compiler error when compiling
tests/hard_coded/cut_test.m with `-O5 --high-level-code'.

compiler/simplify.m:
	Document that simplify does NOT ensure that conditions
	of if-then-elses don't have determinism `det' or `failure'.

compiler/ml_code_gen.m:
	Handle if-then-elses with `det' conditions.

Workspace: /home/hg/fjh/mercury
Index: compiler/ml_code_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ml_code_gen.m,v
retrieving revision 1.72.2.1
diff -u -d -r1.72.2.1 ml_code_gen.m
--- compiler/ml_code_gen.m	2001/01/23 06:03:12	1.72.2.1
+++ compiler/ml_code_gen.m	2001/02/03 22:36:16
@@ -544,6 +544,12 @@
 % Code for if-then-else
 %
 
+%	model_det Cond:
+%		<(Cond -> Then ; Else)>
+%	===>
+%		<Cond>
+%		<Then>
+
 %	model_semi Cond:
 %		<(Cond -> Then ; Else)>
 %	===>
@@ -2656,9 +2662,16 @@
 	{ Cond = _ - CondGoalInfo },
 	{ goal_info_get_code_model(CondGoalInfo, CondCodeModel) },
 	(
+		%	model_det Cond:
+		%		<(Cond -> Then ; Else)>
+		%	===>
+		%		<Cond>
+		%		<Then>
 		{ CondCodeModel = model_det },
-		% simplify.m should remove these
-		{ error("ml_gen_ite: det cond") }
+		ml_gen_goal(model_det, Cond, CondStatement),
+		ml_gen_goal(CodeModel, Then, ThenStatement),
+		{ MLDS_Decls = [] },
+		{ MLDS_Statements = [CondStatement, ThenStatement] }
 	;
 		%	model_semi cond:
 		%		<(Cond -> Then ; Else)>
Index: compiler/simplify.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/simplify.m,v
retrieving revision 1.92
diff -u -d -r1.92 simplify.m
--- compiler/simplify.m	2000/12/13 00:00:28	1.92
+++ compiler/simplify.m	2001/02/03 22:07:59
@@ -907,8 +907,15 @@
 	% cannot succeed, then we replace the if-then-else with the
 	% other disjunct. (We could also eliminate A, but we leave
 	% that to the recursive invocations.)
-	% Note that this simplification is required for the MLDS back-end,
-	% which assumes that conditions of if-then-elses are not model_det.
+	%
+	% Note however that rerunning determinism analysis, which
+	% we do at the end of simplification, may introduce more
+	% occurrences of these; since we don't iterate simplification
+	% and determinism anaysis until a fixpoint is reached,
+	% we don't guarantee to eliminate all such if-then-elses.
+	% Hence the code generator must be prepared to handle the
+	% case when the condition of an if-then-else has determinism
+	% `det' or `failure'.
 	%
 	% The conjunction operator in the remaining disjunct ought to be
 	% a sequential conjunction, because Mercury's if-then-else always

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
                                    |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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