If there are any other ideas for optimizations you would like to see
in a compiler for Viff then now is the time to come forward.
--
Janus
Den 15/07/2008 kl. 16.49 skrev Martin Geisler:
Janus Dam Nielsen <[EMAIL PROTECTED]> writes:
Hi again,
Heres the fruit of half a days work :)
Analyzing the expression:
sint n = (a * y + (1 - a) * x);
Yields the following results:
Final result:
((a * y )+ ((1 - a )* x )) cost: 30
(((a * y )+ x )- (x * a )) cost: 30
(((a * y )+ x )- (a * x )) cost: 30
(((a * y )- (a * x ))+ x ) cost: 30
(((y * a )+ x )- (a * x )) cost: 30
(((y * a )+ x )- (x * a )) cost: 30
((a * y )+ (x - (x * a ))) cost: 30
(((y * a )- (a * x ))+ x ) cost: 30
(((y * a )- (x * a ))+ x ) cost: 30
(((a * y )- (x * a ))+ x ) cost: 30
((a * (y - x ))+ x ) cost: 20
And lo and behold the last line reveals that the expression
a * (y - x )+ x
has the lowest cost.
That is very cool! :-)
From the output above it seems that you have taught your analyzer
about the distributive law, that + and * are commutative.
What about a - a == 0, and that 0 * a == 0? I don't know if those
rules will help -- they might just blow up the search space... :-)
--
Martin Geisler
_______________________________________________
viff-devel mailing list (http://viff.dk/)
viff-devel@viff.dk
http://lists.viff.dk/listinfo.cgi/viff-devel-viff.dk
_______________________________________________
viff-devel mailing list (http://viff.dk/)
viff-devel@viff.dk
http://lists.viff.dk/listinfo.cgi/viff-devel-viff.dk