[mercury-users] Why isn't deforestation working here?
Fergus Henderson
fjh at cs.mu.OZ.AU
Sun Oct 17 22:01:16 AEST 1999
On 16-Oct-1999, Ralph Becket <rbeck at microsoft.com> wrote:
> The basic format of the code is something like this:
>
> io__read_byte(Result, IO_in, IO_out),
> ( Result = ok(Byte), ...
> ; Result = eof, ...
> ; Result = error(ErrCode), ...
> )
>
> and I was under the impression that compiling with
>
> MCFLAGS = -O 6 --intermodule-optimization
>
> should deforest (vb?) this code. Any help would be greatly appreciated!
The basic problem is that the compiler decides that io__read_byte
is too complicated to be worth trying intermodule inlining.
That looks like a bad decision; probably we need to tweak the
compiler's inlining heuristics. But in the mean time, the following
patch will probably give you some improvement.
This patch just adds some `pragma inline' declarations.
Index: io.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/library/io.m,v
retrieving revision 1.185
diff -u -u -r1.185 io.m
--- io.m 1999/10/03 10:40:50 1.185
+++ io.m 1999/10/17 11:53:29
@@ -1149,6 +1149,9 @@
% input predicates
+:- pragma inline(io__read_char/3).
+:- pragma inline(io__read_char/4).
+
io__read_char(Result) -->
io__input_stream(Stream),
io__read_char(Stream, Result).
@@ -1168,6 +1171,9 @@
{ Result = error(io_error(Msg)) }
).
+:- pragma inline(io__read_byte/3).
+:- pragma inline(io__read_byte/4).
+
io__read_byte(Result) -->
io__binary_input_stream(Stream),
io__read_byte(Stream, Result).
@@ -2800,6 +2806,8 @@
").
/* input predicates */
+
+:- pragma inline(io__read_char_code/4).
:- pragma c_code(io__read_char_code(File::in, CharCode::out, IO0::di, IO::uo),
will_not_call_mercury, "
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh> | of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3 | -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-users mailing list
post: mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the users
mailing list