[clean-list] Macro facility able to encode program transformation?
John van Groningen
johnvg at cs.ru.nl
Tue Oct 9 17:08:24 MEST 2007
David Norris wrote:
>The following code demonstrates a program transformation that converts a concise implementation of convolution to a highly efficient one (as fast as GCC-compiled C). This transformation, applicable generally to folds over comprehensions, looks like a good candidate for automation. Is Clean's macro facility powerful enough to encode a transformation of this nature within a Clean program? Or would automating this transformation require preprocessing the Clean program text?
The macro facility will optimize the foldl in:
> foldl (+) zero [ a.[i-k] * b.[k] \\ k <- [start..end] ]
However, this will not eliminate the list generated by the list comprehension.
The compiler can do this using fusion. This can be enabled in the module options
dialog using check box "Fusion (Experimental)".
In that case the following code is generated for the inner loop (for {#Real}):
l_2:
movl %ebx,%ebp
subl %eax,%ebp
fldl 12(%ecx,%ebp,8)
fmull 12(%edx,%eax,8)
faddp %st(0),%st(1)
addl $1,%eax
cmpl (%esp),%eax
jle l_2
Kind regards,
John van Groningen
More information about the clean-list
mailing list