# Code Generation for Expressions with Common Subexpressions

@article{Aho1977CodeGF, title={Code Generation for Expressions with Common Subexpressions}, author={Alfred V. Aho and Stephen C. Johnson and Jeffrey D. Ullman}, journal={Journal of the ACM (JACM)}, year={1977}, volume={24}, pages={146 - 160} }

This paper shows the problem of generating optimal code for expressions containing common subexpressions is computationally difficult, even for simple expressions and simple machines. Some heuristics for code generation are given and their worst-case behavior is analyzed. For one register machines, an optimal code generation algorithm is given whose time complexity is linear in the size of an expression and exponential only in the amount of sharing.

#### 179 Citations

Further analysis of code generation for a single register machine

- Computer Science
- Acta Informatica
- 2004

A class of expressions with common subexpressions is introduced which can be optimally coded in quadratic time, and a new analysis of the exponential time bound is presented which more closely describes the complexity of the task of producing optimal code. Expand

Further Analysis of Code Generation for a Single Register Machine

- Computer Science
- 1982

A class of expressions with common subexpressions is introduced which can be optimally coded in quadratic time, and a new analysis of the exponential time bound is presented which more closely describes the complexity of the task of producing optimal code. Expand

Efficient Computation of Expressions with Common Subexpressions

- Computer Science
- JACM
- 1980

(b) if the authors wish to avoid redundant computation of common subexpressions then generation of optimal code becomes very difficult, even for quite simple machines [3,9], so any theoretical results can at best provide insight into the design of code generators. Expand

A practical method for code generation based on exhaustive search

- Computer Science
- SIGPLAN '82
- 1982

An original method for code generation has been developed in conjunction with the construction of a compiler for the C programming language on the DEC-10 computer, and is table-driven, with most machine-specific information isolated in the tables. Expand

Factoring and eliminating common subexpressions in polynomial expressions

- Computer Science
- IEEE/ACM International Conference on Computer Aided Design, 2004. ICCAD-2004.
- 2004

This work presents algorithms to reduce the number of operations to compute a set of polynomial expression by factoring and eliminating common subexpressions, based on the algebraic techniques for multi-level logic synthesis. Expand

Factoring and eliminating common subexpressions in polynomial expressions

- Computer Science
- ICCAD 2004
- 2004

This work presents algorithms to reduce the number of operations to compute a set of polynomial expression by factoring and eliminating common subexpressions, based on the algebraic techniques for multi-level logic synthesis. Expand

Optimizing Polynomial Expressions by Factoring and Eliminating Common Subexpressions

- 2004

Polynomial expressions are used to compute a wide variety of mathematical functions commonly found in signal processing and graphics applications, which provide good opportunities for optimization.… Expand

Optimized DSP assembly code generation starting from homogeneous atomic data flow graphs

- Computer Science
- 38th Midwest Symposium on Circuits and Systems. Proceedings
- 1995

By transforming graphs into constrained expression trees, global optimized instruction code can be produced based on tree algorithms based on O(n) algorithms. Expand

Code-generation for machines with multiregister operations

- Computer Science
- POPL
- 1977

A linear-time optimal code generation algorithm is derived for a register-pair machine in which all registers are interchangeable, based on showing that for this model there is an optimal evaluation sequence with limited oscillation between the sub-trees dominated by the children of a given node. Expand

Optimal chaining in expression trees

- Computer Science
- SIGPLAN '86
- 1986

This work presents a linear-time scheduling algorithm for finding an optimal order of evaluation for a machine with a bounded number of registers and optimally uses this feature to compute (vector) expression trees. Expand

#### References

SHOWING 1-10 OF 43 REFERENCES

Optimal code generation for expression trees

- Mathematics, Computer Science
- STOC
- 1975

A dynamic programming algorithm is presented which produces optimal code for any machine in the class; this algorithm runs in time which is linearly proportional to the number of vertices in an expression tree. Expand

The Generation of Optimal Code for Stack Machines

- Computer Science
- JACM
- 1975

Efficient algorithms are given for constructing optimal programs in the case where the expressions are trees, there are no data dependencies, and the arithmetic expressions have limited algebraic properties. Expand

Code Generation for a One-Register Machine

- Computer Science
- J. ACM
- 1976

The problem of generating minimal-length code for such machines is hard in a precise sense; specifically it is shown that the problem is NP-complete. Expand

The Generation of Optimal Code for Arithmetic Expressions

- Mathematics, Computer Science
- JACM
- 1970

It is shown that the algorithms presented here also minimize the number of storage references in the evaluation, and they are shown to take the shortest possible number of instructions. Expand

Generation of optimal code for expressions via factorization

- Mathematics, Computer Science
- CACM
- 1969

Methods are presented for increasing the efficiency of the object code produced by first factoring the expressions, i.e. finding a set of subexpressions each of which occurs in two or more other expressions or sub expressesions. Expand

Register Assignment Algorithm for Generation of Highly Optimized Object Code

- Computer Science
- IBM J. Res. Dev.
- 1974

A register assignment algorithm is described that, in contrast to traditional methods, permits a high level of optimization at both local and global levels, with global assignment intervening. Expand

The Design of an Optimizing Compiler

- Computer Science
- 1975

The design and implementation of a highly optimizing compiler for the BLISS language is described and a notational scheme is described in terms of which an overview of the compiler is presented. Expand

On the Sethi-Ullman algorithm

- Mathematics
- 1975

A directed acyclic graph (dag) can be used to represent an arithmetic expression consisting of sequences of binary operations on arguments. The Sethi-Ullman algorithm (Journal of the ACM, Vol. 17 No.… Expand

Complete Register Allocation Problems

- Computer Science
- SIAM J. Comput.
- 1975

The model used in this paper is a single processor with an arbitraril system that automates the very labor-intensive and therefore time-heavy and expensive process of register allocation. Expand

Register allocation via usage counts

- Computer Science
- CACM
- 1974

The paper compares register allocation based on usage counts to other commonly used register allocation techniques, and presents evidence which shows that the usage count technique is significantly better than these other techniques. Expand