[mercury-users] Field assignment optimisation

Michael Day mikeday at yeslogic.com
Mon May 9 16:20:38 AEST 2005


Hi,

Judging by simple timing tests, Mercury does not seem to collapse multiple
field assignments into a single assignment, leading to the creation of
many unneeded temporary structures.

For example, the following expression:

	X = ((X0 ^ field1 := F1) ^ field2 := F2) ^ field3 := F3

seems to be doing this:

	X1 = X0 ^ field1 := F1,
	X2 = X1 ^ field2 := F2,
	X = X2 ^ field3 := F3,

when it could just do this:

	X = x(... X0 ^ field1, X0 ^ field2, X0 ^ field3, ...)

and avoid many unnecessary allocations and copies.

Is there any way to convince the compiler to optimise multiple field
assignments in this way?

Cheers,

Michael

-- 
YesLogic Prince prints XML!
http://yeslogic.com
--------------------------------------------------------------------------
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