[m-dev.] fix for simplify.m
Simon TAYLOR
stayl at students.cs.mu.oz.au
Thu Mar 20 19:51:32 AEDT 1997
Hi Fergus
>
> > ; Disjuncts0 = [SingleGoal0] ->
> > % a singleton disjunction is equivalent to the goal itself
> > - simplify__goal(SingleGoal0, Goal - _, Info0, Info)
> > + simplify__goal(SingleGoal0, Goal - GoalInfo, Info0, Info)
>
> This change is not described in your log message.
> Here you are changing the goal_info used when simplifying a
> singleton disjunction; previously the outer goal_info was used,
> now the inner one is used. Are you sure that this will not
> cause any problems?
I think it could if the determinisms are different, as with inlining
of erroneous procedures. Here's an updated diff.
Simon
Index: simplify.m
===================================================================
@@ -248,14 +246,32 @@
)
).
-simplify__goal_2(disj(Disjuncts0, SM), GoalInfo,
+simplify__goal_2(disj(Disjuncts0, SM), GoalInfo0,
Goal, GoalInfo, Info0, Info) :-
( Disjuncts0 = [] ->
Goal = disj([], SM),
+ GoalInfo = GoalInfo0,
Info = Info0
; Disjuncts0 = [SingleGoal0] ->
% a singleton disjunction is equivalent to the goal itself
- simplify__goal(SingleGoal0, Goal - _, Info0, Info)
+ simplify__goal(SingleGoal0, Goal1 - GoalInfo1, Info0, Info),
+ (
+ % If the determinisms are not the same, we really
+ % need to rerun determinism analysis on the
+ % procedure. I think this is a similar situation
+ % to inlining of erroneous goals. The safe thing
+ % to do is to disable the optimisation if the
+ % inner and outer determinisms are not the same.
+ % It probably won't happen that often.
+ goal_info_get_determinism(GoalInfo0, Det),
+ goal_info_get_determinism(GoalInfo1, Det)
+ ->
+ Goal = Goal1,
+ GoalInfo = GoalInfo1
+ ;
+ Goal = disj([Goal1 - GoalInfo1], SM),
+ GoalInfo = GoalInfo0
+ )
;
simplify__disj(Disjuncts0, Disjuncts, [], InstMaps,
Info0, Info0, Info1),
More information about the developers
mailing list