[m-dev.] for review: simplify.m bug fix
Fergus Henderson
fjh at cs.mu.OZ.AU
Mon Aug 31 14:13:01 AEST 1998
On 30-Aug-1998, Simon Taylor <stayl at cs.mu.OZ.AU> wrote:
> Clean up the handling of commits and goals which cannot succeed.
> This fixes problems with tests/hard_coded/cut_test.m.
...
> Index: compiler/deforest.m
> ===================================================================
> RCS file: /home/staff/zs/imp/mercury/compiler/deforest.m,v
> retrieving revision 1.4
> diff -u -t -u -r1.4 deforest.m
> --- deforest.m 1998/07/08 20:55:53 1.4
> +++ deforest.m 1998/08/11 06:31:39
> @@ -1585,14 +1585,16 @@
> pd_info_get_size_delta(SizeDelta0),
> pd_info_get_changed(Changed0),
>
> - { Goal0 = _ - GoalInfo0 },
> - { Goal1 = GoalExpr1 - GoalInfo1 },
> -
> - % Take the non-locals from the calling goal_info,
> - % everything else from the called goal_info.
> - { goal_info_get_nonlocals(GoalInfo0, NonLocals0) },
> - { goal_info_set_nonlocals(GoalInfo1, NonLocals0, GoalInfo2) },
> - { Goal2 = GoalExpr1 - GoalInfo2 },
> + % update the quantification if not all the output
> + % arguments are used.
> + { Goal1 = _ - GoalInfo1 },
> + { goal_info_get_nonlocals(GoalInfo1, NonLocals1) },
> + { set__list_to_set(Args, NonLocals) },
> + ( { NonLocals1 = NonLocals } ->
> + pd_util__requantify_goal(Goal1, NonLocals, Goal2)
> + ;
> + { Goal2 = Goal1 }
> + ),
Shouldn't that be `NonLocals1 \= NonLocals'?
Also, you should use `set__equal' rather than `=' to compare sets
for equality (although as it happens with the current representation
of sets this doesn't matter).
> +simplify__goal_2(conj(Goals0), GoalInfo0, Goal, GoalInfo, Info0, Info) :-
> simplify_info_get_instmap(Info0, InstMap0),
> simplify__conj(Goals0, [], Goals, GoalInfo0, Info0, Info1),
> - simplify_info_set_instmap(Info1, InstMap0, Info),
> - ( Goals = [SingleGoal] ->
> + simplify_info_set_instmap(Info1, InstMap0, Info2),
> + ( Goals = [] ->
> + goal_info_get_context(GoalInfo0, Context),
> + true_goal(Context, Goal - GoalInfo),
> + Info = Info2
> + ; Goals = [SingleGoal - SingleGoalInfo] ->
> % a singleton conjunction is equivalent to the goal itself
> - SingleGoal = Goal - _
> + simplify__maybe_wrap_goal(GoalInfo0, SingleGoalInfo,
> + SingleGoal, Goal, GoalInfo, Info2, Info)
...
> +simplify__goal_2(par_conj(Goals0, SM), GoalInfo0, Goal,
> + GoalInfo, Info0, Info) :-
> (
> Goals0 = []
> ->
> - Goal = conj([]),
> + goal_info_get_context(GoalInfo0, Context),
> + true_goal(Context, Goal - GoalInfo),
> Info = Info0
> ;
> Goals0 = [Goal0]
> ->
> + GoalInfo = GoalInfo0,
> simplify__goal(Goal0, Goal - _, Info0, Info)
> ;
Why aren't singleton parallel conjunctions handled in the same way
as singleton ordinary conjunctions?
Otherwise that change looks OK.
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh> | of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3 | -- the last words of T. S. Garp.
More information about the developers
mailing list