Generic flow-sensitive optimizing transformations in C++ with concepts

  • Authors:
  • Xiaolong Tang;Jaakko Järvi

  • Affiliations:
  • Texas A&M University, TX;Texas A&M University, TX

  • Venue:
  • Proceedings of the 2010 ACM Symposium on Applied Computing
  • Year:
  • 2010

Quantified Score

Hi-index 0.01

Visualization

Abstract

Compilers are typically hardwired to attempt optimizations only on expressions involving particular built-in types. Ideally, an optimizing compiler can recognize a rewrite opportunity whenever the operands in an expression satisfy the (algebraic) properties that justify the rewrite. This paper applies the principles and techniques of generic programming and the planned "concepts" language feature of C++ to approximate this ideal. Concretely, a concept defines the signature and algebraic laws of a class of types. We attach rewrite rules to a concept, so that the rules apply to all types in the class defined by a concept. The annotation burden to a programmer is thus small---the declaration that a type models a particular concept is simultaneously taken as an annotation that enables optimizations. To increase the applicability of generic rewrite rules, we instantiate them to type-specific rules, enabling the use of data-flow information from the compiler's existing analyses, and interleave the application of rewrite rules with function inlining. Our prototype is implemented as an extension of the ConceptGCC compiler; our experiments show the approach is effective in eliminating abstraction penalties.