[mercury-users] Loop optimisation and predicate specialisation and stuff.
Warwick HARVEY
warwick at cs.mu.oz.au
Tue Dec 23 23:46:39 AEDT 1997
Fergus Henderson <fjh at cs.mu.OZ.AU> writes:
> Also, if the loop had used an if-then-else rather than a switch,
> then the optimization would not be allowed (the reference manual
> is a bit vague on this point, but our intent has always been that
> an implementation must evaluate the condition of an if-then-elses
> before evaluating the `then' or the `else' branches).
Indeed. I'd be rather put out if a predicate from the `else' branch aborted
when the condition I was testing for held...
Reminds me of one of the "optimisations" CLP(R) used to do. I had an
if-then-else test to see whether Y was zero, and in the else clause had the
expression Z = X / Y. This got rearranged to X = Y * Z and moved before the
test. The result was that if Y was zero, CLP(R) deduced that X was zero,
and the predicate failed mysteriously. Argh!
Warwick
----------------------------------------------------------------------------
Warwick Harvey email: warwick at cs.mu.OZ.AU
Department of Computer Science phone: +61-3-9344-9171
University of Melbourne fax: +61-3-9348-1184
Parkville, Victoria, AUSTRALIA 3052 web: http://www.cs.mu.OZ.AU/~warwick
More information about the users
mailing list