[m-rev.] diff: minor MLDS code generation improvement

Fergus Henderson fjh at cs.mu.OZ.AU
Thu Oct 25 17:01:59 AEST 2001


Branches: main
Estimated hours taken: 0.5

Fix a minor bug that led to us generating unnecessarily complicated C code.

compiler/ml_unify_gen.m:
	For semidet deconstructions, generate code of the form
		succeeded = <expr>
		if (succeeded) { ... }
	rather than
		succeeded = <tag test expr>
		if (<tag test expr>) { ... }

Workspace: /home/earth/fjh/ws-earth3/mercury
Index: compiler/ml_unify_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ml_unify_gen.m,v
retrieving revision 1.43
diff -u -d -r1.43 ml_unify_gen.m
--- compiler/ml_unify_gen.m	24 Oct 2001 13:34:27 -0000	1.43
+++ compiler/ml_unify_gen.m	25 Oct 2001 06:26:48 -0000
@@ -1807,6 +1807,7 @@
 	ml_gen_tag_test(Var, ConsId, TagTestDecls, TagTestStatements,
 		TagTestExpression),
 	ml_gen_set_success(TagTestExpression, Context, SetTagTestResult),
+	ml_gen_test_success(SucceededExpression),
 	ml_gen_det_deconstruct(Var, ConsId, Args, ArgModes, Context,
 		GetArgsDecls, GetArgsStatements),
 	{ GetArgsDecls = [], GetArgsStatements = [] ->
@@ -1816,7 +1817,7 @@
 	;
 		GetArgs = ml_gen_block(GetArgsDecls, GetArgsStatements,
 			Context),
-		IfStmt = if_then_else(TagTestExpression, GetArgs, no),
+		IfStmt = if_then_else(SucceededExpression, GetArgs, no),
 		IfStatement = mlds__statement(IfStmt,
 			mlds__make_context(Context)),
 		MLDS_Decls = TagTestDecls,

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  | "... it seems to me that 15 years of
The University of Melbourne         | email is plenty for one lifetime."
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- Prof. Donald E. Knuth
--------------------------------------------------------------------------
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