[m-rev.] diff: implement concat_string_list for .NET

Fergus Henderson fjh at cs.mu.OZ.AU
Tue Feb 18 12:08:55 AEDT 2003


On 18-Feb-2003, Ralph Becket <rafe at cs.mu.OZ.AU> wrote:
> There is a much more serious problem which is not related to the C/OS
> interface.  Neither the Mercury compiler or GCC seems able to optimize
> away redundant calls to string.length in a loop iterating over the chars
> in a string.

It's not too surprising that GCC can't optimize this, because GCC can't
tell that the string won't get modified by function calls within the loop.
Note that the `const' in `const char *' doesn't help, since there might
be global variables that contain other pointers to the same string
and which are not const-qualified.  Furthermore, since `const char *'
is allowed to alias with any other type in C, any store via a pointer
might modify the string.

So if we want to optimize this, we'd better do it ourself.
Now in fact this should not be too difficult, since the Mercury compiler
already does loop invariant hoisting.  However, there are two problems
which prevent it from applying the optimization in this case.

The first problem is that loop invariant hoisting currently occurs
*before* inlining.  Is there any reason for that?

Second, even if we were able to inline all the Mercury code,
that wouldn't help, since the call to strlen() is hidden inside C code.

I'm currently testing a patch which fixes both of these problems.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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