skip to main content
research-article

An SSA-based algorithm for optimal speculative code motion under an execution profile

Published:04 June 2011Publication History
Skip Abstract Section

Abstract

To derive maximum optimization benefits from partial redundancy elimination (PRE),it is necessary to go beyond its safety constraint. Algorithms for optimal speculative code motion have been developed based on the application of minimum cut to flow networks formed out of the control flow graph. These previous techniques did not take advantage of the SSA form, which is a popular program representation widely used in modern-day compilers. We have developed the MC-SSAPRE algorithm that enables an SSA-based compiler to take full advantage of SSA to perform optimal speculative code motion efficiently when an execution profile is available. Our work shows that it is possible to form flow networks out of SSA graphs, and the min-cut technique can be applied equally well on these flow networks to find the optimal code placement. We provide proofs of the correctness and computational and lifetime optimality of MC-SSAPRE. We analyze its time complexity to show its efficiency advantage. We have implemented MC-SSAPRE in the open-sourced Path64 compiler. Our experimental data based on the full SPEC CPU2006 Benchmark Suite show that MC-SSAPRE can further improve program performance over traditional SSAPRE, and that our sparse approach to the problem does result in smaller problem sizes.

References

  1. R. Bodik. Path-Sensitive Value-Flow Optimizations of Programs. PhD thesis, University of Pittsburgh, 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. R. Bodik, R. Gupta, and M. L. Soffa. Complete removal of redundant expressions. In Proceedings of the ACM SIGPLAN '98 Conference on Programming Language Design and Implementation, pages 1--14, 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Q. Cai and J. Xue. Optimal and efficient speculation-based partial redundancy elimination. In Proceedings of the 2th annual IEEE/ACM international symposium on Code generation and optimization, pages 91--102, 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. C. S. Chekuri, A. V. Goldberg, D. R. Karger, M. S. Levine, and C. Stein. Experimental study of minimum cut algorithms. In Proceedings of the Eighth Annual ACM-SIAM Symposium on Discrete Algorithms (SODA), pages 324--333, 1997. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. F. Chow, S. Chan, R. Kennedy, S. Liu, R. Lo, and P. Tu. A new algorithm for partial redundancy elimination based on ssa form. In Proceedings of the ACM SIGPLAN '97 Conference on Programming Language Design and Implementation, pages 273--286, 1997. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. R. Cytron, J. Ferrante, B. K. Rosen, M. N. Wegman, and F. K. Zadeck. Efficiently computing static single assignment form and the control dependence graph. ACM Trans. Program. Lang. Syst., 13 (4): 451--490, 1991. ISSN 0164-0925. http://doi.acm.org/10.1145/115372.115320. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. L. Ford and D. Fulkerson. Flows in Networks. Princeton University Press, 1962.Google ScholarGoogle Scholar
  8. git://github.org/path64/compiler.git.Google ScholarGoogle Scholar
  9. R. Gupta, D. A. Berson, and J. Z. Fang. Path profile guided partial redundancy elimination using speculation, 1997.Google ScholarGoogle Scholar
  10. R. N. Horspool and H. Ho. Partial redundancy elimination driven by a cost-benefit analysis, 1997.Google ScholarGoogle Scholar
  11. R. N. Horspool, D. J. Pereira, and B. Scholz. Fast profile-based partial redundancy elimination. In Proceedings of the 7th Joint Modular Languages Conference, pages 362--376, September 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. http://www.spec.org/cpu2006.Google ScholarGoogle Scholar
  13. K. Kennedy. Safety of code motion. International Journal of Computer Mathematics, 3 (2 and 3): 117--130, 1972.Google ScholarGoogle Scholar
  14. R. Kennedy, S. Chan, S. Liu, R. Lo, P. Tu, and F. Chow. Partial redundancy elimination in ssa form. ACM Trans. Program. Lang. Syst., 21 (3): 627--676, 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. J. Knoop, O. Rüthing, and B. Steffen. Lazy code motion. In Proceedings of the ACM SIGPLAN '92 Conference on Programming Language Design and Implementation, pages 224--234, 1992. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. J. Knoop, O. Rüthing, and B. Steffen. Optimal code motion: theory and practice. ACM Trans. Program. Lang. Syst., 16 (4): 1117--1155, 1994. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. J. Lin, T. Chen, W. chung Hsu, and P. chung Yew. A compiler framework for speculative analysis and optimizations. In Proceedings of the ACM SIGPLAN '03 Conference on Programming Language Design and Implementation, pages 289--299, 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. R. Lo, F. Chow, R. Kennedy, S. Liu, and P. Tu. Register promotion by sparse partial redundancy elimination of loads and stores. In Proceedings of the ACM SIGPLAN '98 Conference on Programming Language Design and Implementation, pages 26--37, 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. E. Morel and C. Renvoise. Global optimization by suppression of partial redundancies. Communications of the ACM, 22 (2): 96--103, 1979. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. B. Murphy, V. Menon, F. Schneider, T. Shpeisman, and A. Adl-Tabatabai. Fault-safe code motion for type-safe languages. In Proceedings of the 6th annual IEEE/ACM international symposium on Code generation and optimization, pages 144--154, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. B. Scholz, N. Horspool, and J. Knoop. Optimizing for space and time usage with speculative partial redundancy elimination. In Proceedings of the 2004 ACM SIGPLAN/SIGBED Conference on Languages, Compilers, and Tools for Embedded Systems, pages 221--230, 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. J. Xue and Q. Cai. A lifetime optimal algorithm for speculative pre. ACM Transactions on Architecture and Code Optimization, 3 (2): 115--155, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. An SSA-based algorithm for optimal speculative code motion under an execution profile

    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

    PDF Format

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader
    About Cookies On This Site

    We use cookies to ensure that we give you the best experience on our website.

    Learn more

    Got it!