[m-rev.] for review: Opt-export version_array lookup and set.
Peter Wang
novalazy at gmail.com
Thu Dec 1 17:32:11 AEDT 2022
This allows the compiler to eliminate the construction of typeinfo
arguments for calls to version_array.lookup and version_array.set,
when compiling with intermodule optimisation and --optimize-unused-args.
In particular, version_hash_table would previously dynamically construct
typeinfos in order lookup or update hash table buckets.
This change improves the run time of a do-nothing build of Prince using
mmc --make on my machine from 1.6 s to 1.43 s.
library/version_array.m:
Add pragma inlines for version_array.lookup and version_array.set.
library/Mercury.options:
Always compile version_hash_table with --optimize-unused-args.
diff --git a/library/Mercury.options b/library/Mercury.options
index 0e828c1a9..6a621788a 100644
--- a/library/Mercury.options
+++ b/library/Mercury.options
@@ -21,6 +21,8 @@ MCFLAGS-lexer += --optimize-constructor-last-call
MCFLAGS-sparse_bitset += --use-atomic-cells --optimize-constant-propagation
MCFLAGS-tree_bitset += --use-atomic-cells --optimize-constant-propagation
+MCFLAGS-version_hash_table += --optimize-unused-args
+
# Speed up structure sharing analysis.
MCFLAGS-set_ctree234 += --structure-sharing-widening 1
MCFLAGS-set_tree234 += --structure-sharing-widening 1
diff --git a/library/version_array.m b/library/version_array.m
index 463bf89e8..0e2d36955 100644
--- a/library/version_array.m
+++ b/library/version_array.m
@@ -461,6 +461,7 @@ from_reverse_list_loop(I, [X | Xs], !VA) :-
lookup(VA, I) = X :-
lookup(VA, I, X).
+:- pragma inline(pred(version_array.lookup/3)).
lookup(VA, I, X) :-
( if get_if_in_range(VA, I, X0) then
X = X0
@@ -474,6 +475,7 @@ VA ^ elem(I) = X :-
%---------------------------------------------------------------------------%
+:- pragma inline(pred(version_array.set/4)).
set(I, X, !VA) :-
( if set_if_in_range(I, X, !VA) then
true
--
2.38.0
More information about the reviews
mailing list