skip to main content
article
Free Access

The Generation of Optimal Code for Arithmetic Expressions

Authors Info & Claims
Published:01 October 1970Publication History
Skip Abstract Section

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.

References

  1. 1 NAKATA, IKUO. On compiling algorithms for arithmetic expressions. Comm. ACM 10, 8 (Aug. 1967), 492-494. Google ScholarGoogle Scholar
  2. 2 MEYERS, W .J . Optimization of computer code. Unpublished memorandum, G. E. Research Center, Schenectady, N. Y., 1965 (12 pp.).Google ScholarGoogle Scholar
  3. 3 REDZIEJOWSKI, R .R . On arithmetic expressions and trees. Comm. ACM 12, 2 (Feb. 1969), 81-84. Google ScholarGoogle Scholar
  4. 4 FLOYD, R.W. An algorithm for coding efficient arithmetic operations. Comm. ACM , 1 (Jan. 1961), 42-51. Google ScholarGoogle Scholar
  5. 5 ANDERSON, J .P . A note on some compiling algorithms. Comm. ACM 7, 3 (March 1964), 149-150. Google ScholarGoogle Scholar

Index Terms

  1. The Generation of Optimal Code for Arithmetic Expressions

        Recommendations

        Comments

        Login options

        Check if you have access through your login credentials or your institution to get full access on this article.

        Sign in

        Full Access

        • Published in

          cover image Journal of the ACM
          Journal of the ACM  Volume 17, Issue 4
          Oct. 1970
          169 pages
          ISSN:0004-5411
          EISSN:1557-735X
          DOI:10.1145/321607
          Issue’s Table of Contents

          Copyright © 1970 ACM

          Publisher

          Association for Computing Machinery

          New York, NY, United States

          Publication History

          • Published: 1 October 1970
          Published in jacm Volume 17, Issue 4

          Permissions

          Request permissions about this article.

          Request Permissions

          Check for updates

          Qualifiers

          • article

        PDF Format

        View or Download as a PDF file.

        PDF

        eReader

        View online with eReader.

        eReader