[mercury-users] Newbie query about compiler optimisations
Fergus Henderson
fjh at cs.mu.OZ.AU
Sat Dec 2 11:43:44 AEDT 2000
On 01-Dec-2000, Sandy Harris <sandy at storm.ca> wrote:
> :- pred cipher( p, c, k1, k2).
> :- mode cipher( in, out, in, in) is det. % encryption
> :- mode cipher( out, in, in, in) is det. % decryption
>
> What I want to do, and haven't figured out, is to solve for one
> of the k's at a time, treating the other as a "don't care"
> variable.
>
> % solve directly for k1 treating k2 as don't care
> :- pred findleft(p, c, k1).
> :- mode findleft(in, in, out) is det.
Well, the code for that is trivial ;-)
findleft(P, C, K1) :-
cipher(P, C, K1, _K2).
The hard bit is getting the compiler to optimize that! Currently
the Mercury compiler doesn't optimize code with unused outputs like
that. We've considered doing it, but it doesn't seem to come up very
often in the benchmarks that we've looked at.
The Mercury compiler does do the converse optimization, eliminating
unused *input* arguments:
foo(A, B, C, _) :-
...
The code to do this optimization is in compiler/unused_args.m
in the source dstribution; it might also be described in
Simon Taylor's honours thesis, which is available from the
papers section of the Mercury web page.
But we haven't yet taught the Mercury compiler how to eliminate unused
output arguments. This would make a good project for someone.
Cheers,
Fergus.
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
| of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- 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