[mercury-users] Request for comments on this code

Peter Schachte schachte at csse.unimelb.edu.au
Mon Jul 10 17:38:55 AEST 2006


On Mon, Jul 10, 2006 at 05:00:51PM +1000, Julien Fischer wrote:
> On Mon, 10 Jul 2006, Peter Schachte wrote:
> > compiler couldn't reorder across && even to mode the clause correctly?
> > If so, where are function calls in the clause head put, at the end of
> > the clause or at the beginning?
> 
> The compiler has to treat headvar unifications specially anyway.  Impure
> goals in the body of a procedure cause a similar problem to the one you
> have just described.
> 
> > Or should && specify minimal
> > reordering:  only enough reordering across && to get the code moded
> > correctly?
> 
> With the exception of reordering headvar unifications any other mode
> reordering should result mode error - in fact it seems very similar
> to how impure goals are handled now (minus the impure bit).

But the impure bit is the important point:  impure code doesn't have a
denotational semantics, so things like order of execution are part of
the meaning of the code.  With && you're saying the code is pure and
order doesn't matter, but just for operational reasons we want the
code before the && to complete before starting the code after it.  But
in that case, why is this so rigid?  Isn't && only advisory?  Why
prohibit the compiler, for all times, from reordering the code to
improve performance?  Eg, why forbid profiling-driven code improvement
from reordering?

And what about removing redundant computations?  Eg

	length(L, N) &&
	...
	length(L, Len),

do we really need to traverse the list twice?  And if I write

	goal1,
	(goal2 && goal3),
	goal4

can goal4 move before goal1?  These things are all clear for impurity
because there's a semantic reason for the restrictions.  Here it's
just for performance, so I would think that the compiler should be
free to do anything that would not hurt performance, including
ignoring the restriction altogether.  Like register declarations in C.

-- 
Peter Schachte              What we are looking at is good and evil, right
schachte at cs.mu.OZ.AU        and wrong. A new world order!
www.cs.mu.oz.au/~schachte/      -- George Bush 
Phone: +61 3 8344 1338      
--------------------------------------------------------------------------
mercury-users mailing list
post:  mercury-users at csse.unimelb.edu.au
administrative address: owner-mercury-users at csse.unimelb.edu.au
unsubscribe: Address: mercury-users-request at csse.unimelb.edu.au Message: unsubscribe
subscribe:   Address: mercury-users-request at csse.unimelb.edu.au Message: subscribe
--------------------------------------------------------------------------



More information about the users mailing list