[m-dev.] Fix loop-invariant hoisting bug

Ralph Becket rafe at cs.mu.OZ.AU
Thu Jan 27 17:19:35 AEDT 2005


Estimated hours taken: 3
Branches: main

Fix a bug in loop-invariant hoisting.

compiler/common.m:
	Fix common__generate_assign/7 to recognise equivalent
	types for type_infos and type_class_infos.

compiler/loop_inv.m:
	Fixed a bug where goals taking (partly) unique arguments were
	incorrectly being considered for hoisting.

Index: compiler/common.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/common.m,v
retrieving revision 1.73
diff -u -r1.73 common.m
--- compiler/common.m	14 Jun 2004 04:15:58 -0000	1.73
+++ compiler/common.m	25 Jan 2005 04:29:04 -0000
@@ -643,7 +643,13 @@
 
 	set__list_to_set([ToVar, FromVar], NonLocals),
 	UniMode = ((_ - ToVarInst0) -> (_ - ToVarInst)),
-	( common__types_match_exactly(ToVarType, FromVarType) ->
+	(
+		(
+			ToVarType = FromVarType
+		;
+			common__types_match_exactly(ToVarType, FromVarType)
+		)
+	->
 		UnifyMode = (ToVarInst0 -> ToVarInst) -
 			(ToVarInst -> ToVarInst),
 		UnifyContext = unify_context(explicit, []),
Index: compiler/loop_inv.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/loop_inv.m,v
retrieving revision 1.14
diff -u -r1.14 loop_inv.m
--- compiler/loop_inv.m	19 Jan 2005 03:10:39 -0000	1.14
+++ compiler/loop_inv.m	27 Jan 2005 04:56:20 -0000
@@ -565,7 +565,7 @@
 inv_goals_vars_2(MI, UUVs, Goal, IGs0, IGs, IVs0, IVs) :-
     ( if
         not invariant_goal(IGs0, Goal),
-        input_args_are_invariant(MI, Goal, IVs0)
+        input_args_are_invariant(MI, UUVs, Goal, IVs0)
       then
         IGs = [Goal | IGs0],
         IVs = add_outputs(MI, UUVs, Goal, IVs0)
@@ -585,13 +585,19 @@
 
 %------------------------------------------------------------------------------%
 
-:- pred input_args_are_invariant(module_info, hlds_goal, prog_vars).
-:- mode input_args_are_invariant(in, in, in) is semidet.
+:- pred input_args_are_invariant(module_info, prog_vars, hlds_goal, prog_vars).
+:- mode input_args_are_invariant(in, in, in, in) is semidet.
 
-input_args_are_invariant(ModuleInfo, Goal, InvVars) :-
+input_args_are_invariant(ModuleInfo, UniquelyUsedVars, Goal, InvVars) :-
     Inputs = goal_inputs(ModuleInfo, Goal),
-    all [V]
-        ( list__member(V, Inputs) => list__member(V, InvVars) ).
+    all [V] (
+        list__member(V, Inputs)
+    =>
+        (
+            list__member(V, InvVars),
+            not list__member(V, UniquelyUsedVars)
+        )
+    ).
 
 %------------------------------------------------------------------------------%
 
--------------------------------------------------------------------------
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