On Sat, 2007-09-08 at 12:59 +1000, skaller wrote: [] Parallel assignment is now implement for the case that looks like this:
a,b,c = e1, e2, e3 For example this: a,b,c=c,a,b; generates this C++ code: /*parallel assignment*/ { int _trp_5579 = PTF b; PTF b = PTF a; PTF a = PTF c; PTF c = _trp_5579; } however .. looking at the regression and tutorial test rock by I didn't see many instances optimised by this modification .. :) The optimisation is a hack, it actually seeks the pattern: x := e1, e2, e3 a = x.(0) b = x.(1) c = x.(2) (for variable number of components of course). The case where the RHS is like: x = e1, e2, e3; a,b,c = x; is not optimised, and this is right I think. That is, when the RHS is a tuple type, but not a tuple expression, there's no saying what common subexpressions are being optimised by the x = ... part, and so translating to a,b,c = x.(0), x.(1), x.(2) to get the right form for parallel optimisation might be counterproductive (i.e. if x is a complex expression, it would be calculated 3 times). But the contra case SHOULD be optimised: x = a,b,c should be expanded to x.(0) = a; x.(1) = b; x.(2) = c; if possible, because it saves constructing a temporary tuple on the RHS then assigning it (two writes and a temporary instead of one write). This is harder to handle because expression a may depend on x, but it may depend only on x.(0), b on x.(1) and c on x.(2) in which case the 3 mutations are independent and can be done in parallel. Still, even the crude dependency check would be better than nothing .. however the parallel assignment routine can't handle it at present (if none of a,b,c use x, we can do parallel assignment: if they do, we could still do it, possibly with extra temporaries). One idea is to cheat, and replace x.(0) with x1, x.(1) with x2, etc, then run the usual algorithm, then uncheat. This will work, provided x is not used 'as a whole', i.e. x eliminated entirely by the above transformation. -- John Skaller <skaller at users dot sf dot net> Felix, successor to C++: http://felix.sf.net ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ Felix-language mailing list Felix-language@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/felix-language