[m-rev.] for review: trace goals being optimised away

Peter Wang novalazy at gmail.com
Mon Jul 26 15:08:41 AEST 2010


On 2010-07-26, Zoltan Somogyi <zs at csse.unimelb.edu.au> wrote:
> On 26-Jul-2010, Peter Wang <novalazy at gmail.com> wrote:
> > -        ( Purity = purity_pure ; Purity = purity_semipure ),
> > +        ( Purity = purity_pure
> > +        ; Purity = purity_semipure
> > +        ),
> > +        goal_contains_trace(Goal0, _, contains_no_trace_goal),
> 
> The rest of the diff looks good, but this call to goal_contains_trace
> may lead to substantially worse than linear complexity.

Committed with the following changes.

Might it be better to replace feature_contains_trace by a new kind of
purity, purity_trace, or a parameterised purity_impure(trace_only)?

Peter

diff --git a/compiler/simplify.m b/compiler/simplify.m
index 0db26cd..fffae16 100644
--- a/compiler/simplify.m
+++ b/compiler/simplify.m
@@ -726,9 +726,10 @@ simplify_goal(Goal0, hlds_goal(GoalExpr, GoalInfo), !Info) :-
         true
     ),
     ( goal_info_has_feature(GoalInfo0, feature_contains_trace) ->
-        simplify_info_set_found_contains_trace(yes, !Info)
+        simplify_info_set_found_contains_trace(yes, !Info),
+        Goal0ContainsTrace = contains_trace_goal
     ;
-        true
+        Goal0ContainsTrace = contains_no_trace_goal
     ),
     Detism = goal_info_get_determinism(GoalInfo0),
     simplify_info_get_det_info(!.Info, DetInfo),
@@ -745,7 +746,7 @@ simplify_goal(Goal0, hlds_goal(GoalExpr, GoalInfo), !Info) :-
         ( Purity = purity_pure
         ; Purity = purity_semipure
         ),
-        goal_contains_trace(Goal0, _, contains_no_trace_goal),
+        Goal0ContainsTrace = contains_no_trace_goal,
         ( det_info_get_fully_strict(DetInfo, no)
         ; Goal0CanLoopOrThrow = cannot_loop_or_throw
         )
@@ -807,7 +808,7 @@ simplify_goal(Goal0, hlds_goal(GoalExpr, GoalInfo), !Info) :-
         ( Purity = purity_pure
         ; Purity = purity_semipure
         ),
-        goal_contains_trace(Goal0, _, contains_no_trace_goal),
+        Goal0ContainsTrace = contains_no_trace_goal,
         ( det_info_get_fully_strict(DetInfo, no)
         ; Goal0CanLoopOrThrow = cannot_loop_or_throw
         )

--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list