FYI, this approach, in general and completely automated, is taken by the Spiral Project DSP generator: http://spiral.net/index.html
DSP transformations are represented in a Scheme-like language. The optimizer performs operations on this language then compiles to C code.
I worked on the Spiral project on things tangental to the DSP generator, but wrote my own optimizing DSP compiler based on Spiral technology for class in university.