The Generation of Optimal Code for Arithmetic Expressions

Ravi Sethi, J. D. Ullman

Research output: Contribution to journalArticle

158 Citations (Scopus)

Abstract

The problem of evaluating arithmetic expressions on a machine with N ≥ 1 general purpose registers is considered. It is initially assumed that no algebraic laws apply to the operators and operands in the expression. An algorithm for evaluation of expressions under this assumption is proposed, and it is shown to take the shortest possible number of instructions. It is then assumed that certain operators are commutative or both commutative and associative. In this case a procedure is given for finding an expression equivalent to a given one and having the shortest possible evaluation sequence. It is then shown that the algorithms presented here also minimize the number of storage references in the evaluation.

Original languageEnglish (US)
Pages (from-to)715-728
Number of pages14
JournalJournal of the ACM (JACM)
Volume17
Issue number4
DOIs
StatePublished - Oct 1 1970
Externally publishedYes

Fingerprint

Mathematical operators

ASJC Scopus subject areas

  • Control and Systems Engineering
  • Software
  • Information Systems
  • Hardware and Architecture
  • Artificial Intelligence

Cite this

The Generation of Optimal Code for Arithmetic Expressions. / Sethi, Ravi; Ullman, J. D.

In: Journal of the ACM (JACM), Vol. 17, No. 4, 01.10.1970, p. 715-728.

Research output: Contribution to journalArticle

Sethi, Ravi ; Ullman, J. D. / The Generation of Optimal Code for Arithmetic Expressions. In: Journal of the ACM (JACM). 1970 ; Vol. 17, No. 4. pp. 715-728.
@article{ade5b1bc3ab24abf98e4313854a9fb69,
title = "The Generation of Optimal Code for Arithmetic Expressions",
abstract = "The problem of evaluating arithmetic expressions on a machine with N ≥ 1 general purpose registers is considered. It is initially assumed that no algebraic laws apply to the operators and operands in the expression. An algorithm for evaluation of expressions under this assumption is proposed, and it is shown to take the shortest possible number of instructions. It is then assumed that certain operators are commutative or both commutative and associative. In this case a procedure is given for finding an expression equivalent to a given one and having the shortest possible evaluation sequence. It is then shown that the algorithms presented here also minimize the number of storage references in the evaluation.",
author = "Ravi Sethi and Ullman, {J. D.}",
year = "1970",
month = "10",
day = "1",
doi = "10.1145/321607.321620",
language = "English (US)",
volume = "17",
pages = "715--728",
journal = "Journal of the ACM",
issn = "0004-5411",
publisher = "Association for Computing Machinery (ACM)",
number = "4",

}

TY - JOUR

T1 - The Generation of Optimal Code for Arithmetic Expressions

AU - Sethi, Ravi

AU - Ullman, J. D.

PY - 1970/10/1

Y1 - 1970/10/1

N2 - The problem of evaluating arithmetic expressions on a machine with N ≥ 1 general purpose registers is considered. It is initially assumed that no algebraic laws apply to the operators and operands in the expression. An algorithm for evaluation of expressions under this assumption is proposed, and it is shown to take the shortest possible number of instructions. It is then assumed that certain operators are commutative or both commutative and associative. In this case a procedure is given for finding an expression equivalent to a given one and having the shortest possible evaluation sequence. It is then shown that the algorithms presented here also minimize the number of storage references in the evaluation.

AB - The problem of evaluating arithmetic expressions on a machine with N ≥ 1 general purpose registers is considered. It is initially assumed that no algebraic laws apply to the operators and operands in the expression. An algorithm for evaluation of expressions under this assumption is proposed, and it is shown to take the shortest possible number of instructions. It is then assumed that certain operators are commutative or both commutative and associative. In this case a procedure is given for finding an expression equivalent to a given one and having the shortest possible evaluation sequence. It is then shown that the algorithms presented here also minimize the number of storage references in the evaluation.

UR - http://www.scopus.com/inward/record.url?scp=0014855855&partnerID=8YFLogxK

UR - http://www.scopus.com/inward/citedby.url?scp=0014855855&partnerID=8YFLogxK

U2 - 10.1145/321607.321620

DO - 10.1145/321607.321620

M3 - Article

AN - SCOPUS:0014855855

VL - 17

SP - 715

EP - 728

JO - Journal of the ACM

JF - Journal of the ACM

SN - 0004-5411

IS - 4

ER -