[m-rev.] diff: [CTGC] further memoising in ctgc.selector.m

Peter Wang novalazy at gmail.com
Tue Aug 12 16:18:42 AEST 2008


Branches: main

compiler/ctgc.selector.m:
	Add further memoising to speed up the CTGC analyses.

diff --git a/compiler/ctgc.selector.m b/compiler/ctgc.selector.m
index c432ab4..6f9f988 100644
--- a/compiler/ctgc.selector.m
+++ b/compiler/ctgc.selector.m
@@ -298,14 +298,7 @@ type_contains_subtype_2(ModuleInfo, ToType, !Queue, !SeenTypes, Contains) :-
                 Contains)
         ;
             svset.insert(FromType, !SeenTypes),
-            solutions(
-                (pred(ConsIdArgTypes::out) is nondet :-
-                    cons_id_arg_types(ModuleInfo, FromType, _ConsId,
-                        ConsIdArgTypes),
-                    ConsIdArgTypes = [_ | _]
-                ),
-                ArgTypesLists),
-            list.condense(ArgTypesLists, ArgTypes),
+            type_arg_types(ModuleInfo, FromType, ArgTypes),
             ( list.member(ToType, ArgTypes) ->
                 Contains = yes
             ;
@@ -318,6 +311,19 @@ type_contains_subtype_2(ModuleInfo, ToType, !Queue, !SeenTypes, Contains) :-
         Contains = no
     ).
 
+:- pred type_arg_types(module_info::in, mer_type::in, list(mer_type)::out)
+    is det.
+
+:- pragma memo(type_arg_types/3,
+    [allow_reset, specified([promise_implied, value, output])]).
+
+type_arg_types(ModuleInfo, Type, ArgTypes) :-
+    solutions(
+        (pred(ConsIdArgTypes::out) is nondet :-
+            cons_id_arg_types(ModuleInfo, Type, _ConsId, ConsIdArgTypes)
+        ), ArgTypesLists),
+    list.condense(ArgTypesLists, ArgTypes).
+
 type_of_node(ModuleInfo, StartType, Selector, SubType) :-
     (
         Selector = [UnitSelector | RestSelector],
@@ -371,6 +377,9 @@ select_subtype(ModuleInfo, Type, ConsID, Position, SubType) :-
             "select_subtype: type is both existential and non-existential")
     ).
 
+:- pragma memo(normalize_selector_with_type_information/4,
+    [allow_reset, specified([promise_implied, value, value, output])]).
+
 normalize_selector_with_type_information(ModuleInfo, Type, !Selector) :-
     ( is_introduced_type_info_type(Type) ->
         true
@@ -500,7 +509,9 @@ branch_map_search([Type - Sel | TypeSels], KeyType, ValueSel):-
 %-----------------------------------------------------------------------------%
 
 reset_tables(!IO) :-
-    table_reset_for_type_contains_subtype_1_4(!IO).
+    table_reset_for_type_contains_subtype_1_4(!IO),
+    table_reset_for_type_arg_types_3(!IO).
+    table_reset_for_normalize_selector_with_type_information_4(!IO).
 
 %-----------------------------------------------------------------------------%
 


--------------------------------------------------------------------------
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