[m-rev.] diff: optimize constant string__append
Peter Ross
pro at missioncriticalit.com
Fri Dec 5 08:34:35 AEDT 2003
Hi,
===================================================================
Estimated hours taken: 1
Branches: main
compiler/const_prop.m:
Do constant propogation for string__append.
Index: compiler/const_prop.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/const_prop.m,v
retrieving revision 1.19
diff -u -r1.19 const_prop.m
--- compiler/const_prop.m 5 Nov 2003 03:17:35 -0000 1.19
+++ compiler/const_prop.m 4 Dec 2003 21:31:16 -0000
@@ -51,7 +51,7 @@
:- import_module parse_tree__inst.
:- import_module parse_tree__prog_data.
-:- import_module bool, list, int, float, map, require.
+:- import_module bool, list, int, float, map, require, string.
:- import_module std_util.
%------------------------------------------------------------------------------%
@@ -291,6 +291,20 @@
Y = _YVar - bound(_YUniq, [functor(float_const(YVal), [])]),
YVal \= 0.0,
ZVal = unchecked_quotient(XVal, YVal).
+
+ % This isn't actually a builtin.
+evaluate_builtin_tri("string", Name, _, X, Y, Z, Z, string_const(ZVal)) :-
+ ( Name = "++"
+ ; Name = "append"
+ ),
+ X = _XVar - bound(_XUniq, [functor(string_const(XVal), [])]),
+ Y = _YVar - bound(_YUniq, [functor(string_const(YVal), [])]),
+
+ % We can only do the append if Z is free (this allows
+ % us to ignore the mode number and pick up both the
+ % predicate and function versions of append)
+ Z = _ZVar - free,
+ ZVal = XVal ++ YVal.
%------------------------------------------------------------------------------%
--
Peter Ross
Software Engineer (Work) +32 2 757 10 15
Mission Critical (Mobile) +32 485 482 559
--------------------------------------------------------------------------
mercury-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list