A compiler alternative to expression templates
MetadataShow full item record
Container classes in object-oriented languages often suffer from the problem of compiler-generated temporaries. Storage is allocated for each intermediate result in each expression, introducing huge penalties to performance. Loop fusion and array contraction, the most closely related compiler optimizations to this problem, are not powerful enough to optimize the container classes. The current workaround is to perform a manual optimization called Expression Templates (ETs), which utilizes C++ templates to perform arbitrary code generation, but is a very messy and inefficient way of doing things. We present a compiler alternative to ETs that uses programmer annotations to eliminate temporaries through expression fusion. Our solution is much better for programmer productivity than ETs, and also achieves results that are slightly better.