skip to main content
article
Open access

Constant propagation with conditional branches

Published: 01 April 1991 Publication History

Abstract

Constant propagation is a well-known global flow analysis problem. The goal of constant propagation is to discover values that are constant on all possible executions of a program and to propagate these constant values as far foward through the program as possible. Expressions whose operands are all constants can be evaluated at compile time and the results propagated further. Using the algorithms presented in this paper can produce smaller and faster compiled programs. The same algorithms can be used for other kinds of analyses (e.g., type of determination). We present four algorithms in this paper, all conservitive in the sense that all constants may not be found, but each constant found is constant over all possible executions of the program. These algorithms are among the simplest, fastest, and most powerful global constant propagation algorithms known. We also present a new algorithm that performs a form of interprocedural data flow analysis in which aliasing information is gathered in conjunction with constant progagation. Several variants of this algorithm are considered.

References

[1]
ARo, A. V., SETm, R, AND ULLMAEN, J. D. Comp~lers: Principles, Techniques, and Tools. Addison-Wesley, Reading, Mass., 1986.
[2]
ALLEN, F. E. A catalogue of optimizing transformations. In Design and Optimizat~on of Compilers. R. Rustin, Ed., Prentice Hall, Englewood Cliffs, N.J, 1972, pp. 1-30.
[3]
ALLEN, F.E. Interprocedural data fiow analysis. Inf. Proc. 74 (1974), 398-402.
[4]
ALLEN, F. E., CARTER, J. L., FABRI, J., FERRANTE, J., HARRISON, W. H., LOEWNER, P. G., AND TREVmLYAN, L. H. The experimental compiling system. IBM J. Res. Dev. 24, 6 (Nov. 1980), 695-715.
[5]
ALPERN, B., WEGMAN, M. N., AND ZADECK, F.K. Detecting equality of values in programs. In Conference Recordings of the Fifteenth ACM Symposium on Principles of Programming Languages. (Jan. 1988), pp. 1-11.
[6]
ArrEL, A. W., AND &M, T. Continuation-passing, closure-passing style. In Conference Recordings of the Sixteenth ACM Symposium on Principles of Programming Languages. (Jan. 1989), pp. 293-302.
[7]
BALL, J.E. Predicting the effects of optimization on a procedure body. In Proceedings of the SIGPLAN'79 Symposium on Compiler Construction. (Aug. 1979), pp. 214-220. Published as SIGPLAN Not. 14, 8.
[8]
BANNING, J.B. An efficient way to find the side effects of procedure calls and the aliases of variables. In Conference Recordings of the Sixth ACM Symposium on Principles of Programming Languages. (Jan. 1979), pp. 29-41.
[9]
BARTH, J.M. An interprocedural data fiow analysis algorithm. In Conference Recordings of the Fourth ACM Symposium on Principles of Programming Languages. (Jan. 1977), pp. 119-131.
[10]
BURKE, M. An interval approach toward interprocedural analysis. Tech. Rep. RC 10640 47724, IBM, July 1984.
[11]
BURKE, M., AND CYTRON, R. Interprocedural dependence analysis and parallelization. In Proceedings of the SIGPLAN'86 Symposium on Compiler Construction. (June 1986), pp. 162-175. Published as SIGPLAN Not. 21, 7.
[12]
CALLAHAN, D., COOPER, K. D., KENNEDY, K. W., AND TORCZON, L. M. Interprocedural constant propagation. In Proceedings of the SIGPLAN'86 Symposium on Compiler Construction. (June 1986), pp. 152-161. Published as SIGPLAN Not. 21, 7.
[13]
CHOW, F. C. A portable machine-independent global optimizer--Design and measurements. Tech. Rep. 83-254 (Ph.D. thesis), Computer Systems Laboratory, Stanford Univ., Palo Alto, Calif., Dec. 1983.
[14]
COCKE, J. AND SCHWARTZ, T. Programming Languages and The~r Compilers: Prelimmary Notes. Courant Institute of Mathematical Sciences, New York Univ., April 1970.
[15]
CoorER, K. D. Interprocedural data fiow analysis in a programming environment. Ph.D. thesis, Dept. of Mathematical Sciences, Rice Univ., 1983.
[16]
CYTRON, R., FERRANTE, J., ROSEN, B. K., WEGMAN, M. N., AND ZADECK, F.K. Efficiently computing statie single assignment form and the control dependence graph. Tech. Rep. RC 14756, IBM, revised Mar. 1991.
[17]
ELLIS, J.R. Bulldog: A compiler for VLIW architectures. Ph.D. thesis, Dept. of Computer Science, Yale Unir., New Haven, Conn., Feb. 1985.
[18]
ERSHOV, A. P. On the essence of compilation. In IFIP Working Conference on Formal Description of Programming Concepts. (Aug. 1977).
[19]
FERRANTE, J. AND OTTENSTEIN, K. J. A program form based on data dependency in predicate regions. In Conference Recordings of the Tenth ACM Symposium on Principles of Programming Languages. (Jan. 1983).
[20]
FURTNEY, M. AND PRATT, T.W. Kernel-control tailoring of sequential programs for parallel execution. In Proceedings of the 1982 International Conference on Parallel Processing. (Aug. 1982), pp. 245-247.
[21]
GRAHAM, S. L. AND WEGMAN, M. N. A fast and usually linear algorithm for global fiow analysis. J. ACM23, i (Jan. 1976), 172-202.
[22]
HARRISON, W.H. Compiler analysis of the value ranges for variables. IEEE Trans. Softw. Eng. SE-3, 3 (May 1977), 243-250.
[23]
HOLLEY, L. H. AND ROSEN, B.K. Qualified data fiow problems. IEEE Trans. Softw. Eng. SE-7, I (Jan. 1981), 60-78.
[24]
JOHNgON, I4. Dataflow analygis for intraetable systems software. In Proeeedings of the SIGPLAN'86 Symposium on Compiler Construction. (June 1986), pp. 109-117. Published as SIGPLAN Not. 21, 7.
[25]
KAM, J. B. AND ULLMAN, J. D. Monotone data fiow analysis frameworks. Acta Inf. 7 (1977), 305-317.
[26]
KmnALL, G.A. A unified approach to global program optimization. In Conference Recordings of the First ACM Symposium on Princ~ples of Programming Languages. (Oct. 1973), pp. 194-206.
[27]
MOREL, E. AND RENVOISE, C. Global optimization by suppression of partial redundancies. Commun. ACM 22, 2 (Feb. 1979), 96-103~
[28]
MUCSMCK, S. S. AND JONES, N. D, Eds. Program Flow Analysis. Prentice~Hall, Englewood Cliffs, N.J., 1981.
[29]
MYERS, E.W. A precise interprocedural data fiow algorithm. In Conference Recordings of the Eighth ACM Symposium on Principles of Programming Languages. (Jan. 1981), pp. 219-230.
[30]
O~rENSTE~N, K. J. Data-fiow graphs as an intermediate form. Ph.D. thesis, Dept. of Computer Science, Purdue Univ., Aug. 1978.
[31]
PRATT, T. W. Program analysis and optimization through kernel-control decomposition. Acta Inf. 9 (1978), 195-216.
[32]
REIF, J. H. AND LEWm, H R Symbolic evaluation and the global value graph. In Conference Recordmgs of the Fourth ACM Symposium on Principles of Programming Languages. (Jan. 1977), pp. 104-118.
[33]
REIF, J. H. AND LEW~S, H. R. Efficient symbolic analysis of programs J. Comput. Syst. Sci. 32, 3 (June 1986), 280-313.
[34]
REIF, J. H. AND T~JAN, R.E. Symbolic program analysis in almost linear time. SIAM J. Comput. 11, I (Feb. 1982), 81-93.
[35]
RICSARDSON, S. AND GANAPATm, M. Interprocedural analysis vs. procedure integration. Inf. Process. Lett. 32, 3 (Aug. 1989), 137-142.
[36]
R~CHARDSON, S. AND GANAPATm, M. Code optimization across procedures. IEEE Comput. 22, 2 (Feb. 1989), 42-51.
[37]
ROSEN, B. K. Data fiow analysis for procedural languages. J. ACM 26, 2 (April 1979), 322-344.
[38]
ROSEN, B. K., WEGMAN, M. N., AND ZADECK, F. K. Global value numbers and redundant computations. In Conference Recordings of the Fifteenth ACM Symposium on Prmc~ples of Programming Languages. (Jan. 1988), pp. 12-27.
[39]
SCREIFLER, R. W. An analysis of inline substitution for a structured programming language. Commun. ACM 20, 9 (Sept. 1977), 647-654.
[40]
SsAPmo, R. M. AND SAI~T, H. The representat~on of algorithms. Tech. Rep. CA-7002-1432, Massachusetts Computer Associates, Feb. 1970.
[41]
TENENBAUM, A.M. Type determination for very high level languages. Ph.D. thesis, Courant Institute of Mathematical Sciences, New York Univ., Oct. 1974.
[42]
WEaSREIT, B. Property extraction in well-founded property sers IEEE Trans. Softw. Eng SE-l, 3 (Sept 1975), 270-285.
[43]
WEGMAN, M.N. General and efficient methods for global code improvement. Ph.D. thesis, Computer Science Dept., Univ. of California at Berkeley, Berkeley, 1981.
[44]
W~GMAN, M. N. AND ZADECK, F. K. Constant propagation with conditional branches. In Conference Record~ngs of the Twelfth ACM Symposium on Princ~ples of Programm~ng Languages. (Jan. 1985), pp. 291-299.

Cited By

View all
  • (2024)Lazy Sparse Conditional Constant Propagation in the Sea of NodesProceedings of the 21st ACM SIGPLAN International Conference on Managed Programming Languages and Runtimes10.1145/3679007.3685059(2-13)Online publication date: 13-Sep-2024
  • (2024)Compiling with Abstract InterpretationProceedings of the ACM on Programming Languages10.1145/36563928:PLDI(368-393)Online publication date: 20-Jun-2024
  • (2024)PfComp: A Verified Compiler for Packet Filtering Leveraging Binary Decision DiagramsProceedings of the 13th ACM SIGPLAN International Conference on Certified Programs and Proofs10.1145/3636501.3636954(89-102)Online publication date: 9-Jan-2024
  • Show More Cited By

Recommendations

Reviews

Anne De Niel

Constant propagation is a way to discover which values in a program remain constant over all possible program executions. The purpose of constant propagation is optimization. The authors discuss several existing algorithms by relating them to each other within a single framework, and deal with implementational aspects . The authors present a new algorithm for constant propagation that takes conditional branches into consideration and detects unreachable code. The algorithm can be combined with both procedure integration and interprocedural analysis requiring aliasing information. The paper is self-contained and written in a clear, informal, somewhat verbose style. Research results are presented, but a large part of the text is devoted to identifying their relationship with other work. Alternative algorithms for constant propagation are pointed out. The work mentioned is mainly oriented toward classical imperative languages. The imperative language features covered are quite basic. The paper contains few references to research concerning functional, object-oriented, or logic programming languages. The authors succeed in their effort to present their work on constant propagation to a large readership. The application domain of their algorithms seems to be fairly limited, however.

Access critical reviews of Computing literature here

Become a reviewer for Computing Reviews.

Comments

Information & Contributors

Information

Published In

cover image ACM Transactions on Programming Languages and Systems
ACM Transactions on Programming Languages and Systems  Volume 13, Issue 2
April 1991
114 pages
ISSN:0164-0925
EISSN:1558-4593
DOI:10.1145/103135
Issue’s Table of Contents
Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 01 April 1991
Published in TOPLAS Volume 13, Issue 2

Permissions

Request permissions for this article.

Check for updates

Author Tags

  1. abstract interpretation
  2. code optimization
  3. constant propagation
  4. control flow graph
  5. interprocedural analysis
  6. procedure integration
  7. static single assignment form
  8. type determination

Qualifiers

  • Article

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)870
  • Downloads (Last 6 weeks)116
Reflects downloads up to 16 Dec 2024

Other Metrics

Citations

Cited By

View all
  • (2024)Lazy Sparse Conditional Constant Propagation in the Sea of NodesProceedings of the 21st ACM SIGPLAN International Conference on Managed Programming Languages and Runtimes10.1145/3679007.3685059(2-13)Online publication date: 13-Sep-2024
  • (2024)Compiling with Abstract InterpretationProceedings of the ACM on Programming Languages10.1145/36563928:PLDI(368-393)Online publication date: 20-Jun-2024
  • (2024)PfComp: A Verified Compiler for Packet Filtering Leveraging Binary Decision DiagramsProceedings of the 13th ACM SIGPLAN International Conference on Certified Programs and Proofs10.1145/3636501.3636954(89-102)Online publication date: 9-Jan-2024
  • (2024)Merlin: Multi-tier Optimization of eBPF Code for Performance and CompactnessProceedings of the 29th ACM International Conference on Architectural Support for Programming Languages and Operating Systems, Volume 310.1145/3620666.3651387(639-653)Online publication date: 27-Apr-2024
  • (2024)Hypertesting of Programs: Theoretical Foundation and Automated Test GenerationProceedings of the IEEE/ACM 46th International Conference on Software Engineering10.1145/3597503.3640323(1-12)Online publication date: 20-May-2024
  • (2024)Precise Sparse Abstract Execution via Cross-Domain InteractionProceedings of the IEEE/ACM 46th International Conference on Software Engineering10.1145/3597503.3639220(1-12)Online publication date: 20-May-2024
  • (2024)A Framework For Inferring Properties of User-Defined FunctionsProceedings of the IEEE/ACM 46th International Conference on Software Engineering10.1145/3597503.3639147(1-11)Online publication date: 20-May-2024
  • (2024)Fast and Precise Static Null Exception Analysis With Synergistic PreprocessingIEEE Transactions on Software Engineering10.1109/TSE.2024.346655150:11(3022-3036)Online publication date: Nov-2024
  • (2024)Leveraging Datapath Propagation in IC3 for Hardware Model CheckingIEEE Transactions on Computer-Aided Design of Integrated Circuits and Systems10.1109/TCAD.2024.336002243:7(2215-2228)Online publication date: 31-Jan-2024
  • (2024)EAtuner: Comparative Study of Evolutionary Algorithms for Compiler Auto-tuning2024 27th International Conference on Computer Supported Cooperative Work in Design (CSCWD)10.1109/CSCWD61410.2024.10580120(419-426)Online publication date: 8-May-2024
  • Show More Cited By

View Options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Login options

Full Access

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media