Advertisement

Principled strength reduction

  • Yanhong A. Liu
Chapter
Part of the IFIP Advances in Information and Communication Technology book series (IFIPAICT)

Abstract

This paper presents a principled approach for optimizing iterative (or recursive) programs. The approach formulates a loop body as a function f and a change operation ⊕, incrementalizes f with respect to ⊕, and adopts an incrementalized loop body to form a new loop that is more efficient. Three general optimizations are performed as part of the adoption; they systematically handle initializations, termination conditions, and final return values on exits of loops. These optimizations are either omitted, or done in implicit, limited, or ad hoc ways in previous methods.

The new approach generalizes classical loop optimization techniques, notably strength reduction, in optimizing compilers, and it unifies and systematizes various optimization strategies in transformational programming. Such principled strength reduction performs drastic program efficiency improvement via incrementalization and appreciably reduces code size via associated optimizations. We give examples where this approach can systematically produce strength-reduced programs while no previous method can.

Keywords

program optimization incrementalization strength reduction caching intermediate results maintaining auxiliary information initialization termination condition loop optimization iteration recursion 

References

  1. Aho, A. V., Sethi, R. & Ullman, J. D. (1986). Compilers, Principles, Techniques, and Tools, Addison-Wesley, Reading, Massachusetts.Google Scholar
  2. Allen, F. E. (1969). Program optimization, Annual Review of Automatic Programming, Vol. 5, Pergamon Press, New York, pp. 239–307.Google Scholar
  3. Allen, F. E., Cocke, J. & Kennedy, K. (1981). Reduction of operator strength, in S. S. Muchnick & N. D. Jones (eds), Program Flow Analysis, Prentice-Hall, Englewood Cliffs, New Jersey, chapter 3, pp. 79–101.Google Scholar
  4. Banerjee, U. (1990). Unimodular transformations of double loops, Proceedings of the Workshop on Advances in Languages and Compilers for Parallel Processing, pp. 192–219.Google Scholar
  5. Bauer, F. L., Möller, B., Partsch, H. & Pepper, P. (1989). Formal program construction by transformations—Computer-aided, intuition-guided programming, IEEE Transactions on Software Engineering 15 (2): 165–180.zbMATHCrossRefGoogle Scholar
  6. Bird, R. S. (1984). The promotion and accumulation strategies in transformational programming, ACM Transactions on Programming Languages and Systems 6 (4): 487–504.zbMATHMathSciNetCrossRefGoogle Scholar
  7. Bird, R. S. (1985). Addendum: The promotion and accumulation strategies in transformational programming, ACM Transactions on Programming Languages and Systems 7 (3): 490–492.Google Scholar
  8. Broy, M. (1984). Algebraic methods for program construction: The project CIP, in P. Pepper (ed.), Program Transformation and Programming Environments, Springer-Verlag, Berlin, pp. 199–222.CrossRefGoogle Scholar
  9. Cai, J. & Paige, R. (1988/89). Program derivation by fixed point computation, Science of Computer Programming 11: 197–261.zbMATHMathSciNetCrossRefGoogle Scholar
  10. Cocke, J. & Kennedy, K. (1977). An algorithm for reduction of operator strength, Communications of the ACM 20 (11): 850–856.zbMATHCrossRefGoogle Scholar
  11. Cocke, J. & Schwartz, J. T. (1970). Programming Languages and Their Compilers; Preliminary Notes, Technical report, Courant Institute of Mathematical Sciences, New York University.Google Scholar
  12. Constable, R. L. et al. (1986). Implementing Mathematics with the Nuprl Proof Development System, Prentice-Hall, Englewood Cliffs, New Jersey.Google Scholar
  13. Dershowitz, N. (1983). The Evolution of Programs, Vol. 5 of Progress in Computer Science, Birkhäuser, Boston.zbMATHCrossRefGoogle Scholar
  14. Dijkstra, E. W. (1976). A Discipline of Programming, Prentice-Hall Series in Automatic Computation, Prentice-Hall, Englewood Cliffs, New Jersey.zbMATHGoogle Scholar
  15. Flores, I. (1963). The Logic of Computer Arithmetic, Prentice-Hall, Englewood Cliffs, New Jersey.zbMATHGoogle Scholar
  16. Fong, A. C. (1977). Generalized common subexpressions in very high level languages, Conference Record of the 4th Annual ACM Symposium on POPL, Los Angeles, California, pp. 48–57.Google Scholar
  17. Fong, A. C. (1979). Inductively computable constructs in very high level languages, Conference Record of the 6th Annual ACM Symposium on POPL, San Antonio, Texas, pp. 21–28.Google Scholar
  18. Fong, A. C. & Ullman, J. D. (1976). Inductive variables in very high level languages, Conference Record of the 3rd Annual ACM Symposium on POPL, Atlanta, Georgia, pp. 104–112.Google Scholar
  19. Garey, M. R. & Johnson, D. S. (1979). Computers and Intractability: A Guid to the Theory of NP-Completeness, W. H. Freeman and Company, New York.Google Scholar
  20. Grau, A. A., Hill, U. & Langmaac, H. (1967). Translation of ALGOL 60, Vol. 1 of Handbook for automatic computation, Springer, Berlin.Google Scholar
  21. Greibach, S. A. (1975). Theory of Program Structures: Schemes, Semantics, Verification, Vol. 36 of Lecture Notes in Computer Science, Springer-Verlag, Berlin.zbMATHCrossRefGoogle Scholar
  22. Gries, D. (1971). Compiler Construction for Digital Computers, John Wiley & Sons, New York.zbMATHGoogle Scholar
  23. Gries, D. (1981). The Science of Programming, Springer-Verlag, New York.zbMATHCrossRefGoogle Scholar
  24. Gries, D. (1984). A note on a standard strategy for developing loop invariants and loops, Science of Computer Programming 2: 207–214.CrossRefGoogle Scholar
  25. Joshi, S. M. & Dhamdhere, D. M. (1982a). A composite hoisting-strength reuction transformation for global program optimization—part I, International Journal of Computer Mathematics 11: 21–41.zbMATHCrossRefGoogle Scholar
  26. Joshi, S. M. & Dhamdhere, D. M. (1982b). A composite hoisting-strength reuction transformation for global program optimization—part II, International Journal of Computer Mathematics 11: 111–126.zbMATHCrossRefGoogle Scholar
  27. Knoop, J. (1994). Private comminication.Google Scholar
  28. Liu, Y. A. (1995). CACHET: An interactive, incremental-attribution-based program transformation system for deriving incremental programs, Proceedings of the 10th Knowledge-Based Software Engineering Conference, IEEE Computer Society Press, Boston, Massachusetts, pp. 1926.Google Scholar
  29. Liu, Y. A. (1996). Incremental Computation: A Semantics-Based Systematic Transformational Approach, PhD thesis, Department of Computer Science, Cornell University, Ithaca, New York.Google Scholar
  30. Liu, Y. A. & Stoller, S. D. (1997). Optimizing aggregate array computations, Technical Report TR 477, Computer Science Department, Indiana University, Bloomington, Indiana.Google Scholar
  31. Liu, Y. A., Stoller, S. D. & Teitelbaum, T. (1996). Discovering auxiliary information for incremental computation, Conference Record of the 23rd Annual ACM Symposium on POPL, St. Petersburg Beach, Florida, pp. 157–170.Google Scholar
  32. Liu, Y. A. & Teitelbaum, T. (1995a). Caching intermediate results for program improvement, Proceedings of the ACM SIGPLAN Symposium on PEPM, La Jolla, California, pp. 190–201.Google Scholar
  33. Liu, Y. A. & Teitelbaum, T. (1995b). Systematic derivation of incremental programs, Science of Computer Programming 24 (1): 1–39.zbMATHCrossRefGoogle Scholar
  34. O’Leary, J., Leeser, M., Hickey, J. & Aagaard, M. (1994). Non-restoring integer square root: A case study in design by principled optimization, in R. Kumar & T. Kropf (eds), Proceedings of the 2nd International Conference on Theorem Provers in Circuit Design: Theory, Practice, and Experience, Vol. 901 of Lecture Notes in Computer Science, Springer-Verlag, Berlin, pp. 52–71.CrossRefGoogle Scholar
  35. Paige, B. & Schwartz, J. T. (1977). Expression continuity and the formal differentiation of algorithms, Conference Record of the 4th Annual ACM Symposium on POPL, pp. 58–71.Google Scholar
  36. Paige, R. (1983). Transformational programming—Applications to algorithms and systems, Conference Record of the 10th Annual ACM Symposium on POPL, pp. 73–87.Google Scholar
  37. Paige, R. & Koenig, S. (1982). Finite differencing of computable expressions, ACM Transactions on Programming Languages and Systems 4(3): 402–454.zbMATHCrossRefGoogle Scholar
  38. Partsch, H. A. (1990). Specification and Transformation of Programs—A Formal Approach to Software Development, Springer-Verlag, Berlin.Google Scholar
  39. Reynolds, J. C. (1981). The Craft of Programming, Prentice-Hall, Englewood Cliffs, New Jersey.zbMATHGoogle Scholar
  40. Sethi, R. (1973). A note on implementing parallel assignment instructions, Information Processing Letter 2: 91–95.zbMATHCrossRefGoogle Scholar
  41. Smith, D. R. (1990). KIDS: A semiautomatic program development system, IEEE Transactions on Software Engineering 16 (9): 1024–1043.CrossRefGoogle Scholar
  42. Steffen, B., Knoop, J. & Rüthing, O. (1990). The value flow graph: A program representation for optimal program transformation, Proceedings of the 3rd ESOP, Vol. 432 of Lecture Notes in Computer Science, Springer-Verlag, Berlin, pp. 389–405.CrossRefGoogle Scholar
  43. Steffen, B., Knoop, J. & Rüthing, O. (1991). Efficient code motion and an adaption to strength reduction, Proceedings of the 4th International Joint Conference on TAPSOFT, Vol. 494 of Lecture Notes in Computer Science, Springer-Verlag, Berlin, pp. 394–415.Google Scholar
  44. Wolf, M. & Lam, M. (1991a). A data locality optimizing algorithm, Proceedings of the ACM SIGPLAN ’91 Conference on PLDI, pp. 30–44.Google Scholar
  45. Wolf, M. & Lam, M. (1991b). A loop transformation theory and an algorithm to maximize parallelism, IEEE Transactions on Parallel and Distributed Systems.Google Scholar

Copyright information

© IFIP 1997

Authors and Affiliations

  • Yanhong A. Liu
    • 1
  1. 1.Computer Science DepartmentIndiana UniversityBloomingtonUSA

Personalised recommendations