Advertisement

Register Pressure Sensitive Redundancy Elimination

  • Rajiv Gupta
  • Rastislav Bodík
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 1575)

Abstract

Redundancy elimination optimizations avoid repeated computation of the same value by computing the value once, saving it in a temporary, and reusing the value from the temporary when it is needed again. Examples of redundancy elimination optimizations include common subexpression elimination, loop invariant code motion and partial redundancy elimination. We demonstrate that the introduction of temporaries to save computed values can result in a significant increase in register pressure. An increase in register pressure may in turn trigger generation of spill code which can more than offset the gains derived from redundancy elimination. While current techniques minimize increases in register pressure, to avoid spill code generation it is instead necessary to ensure that register pressure does not exceed the number of available registers.

In this paper we develop a redundancy elimination algorithm that is sensitive to register pressure: our novel technique first sets upper limits on allowed register pressure and then performs redundancy elimination within these limits. By setting strict register pressure limits for frequently executed (hot) blocks and higher limits for infrequently executed (cold) blocks, our algorithm permits trade-off between redundancy removal from hot blocks at the expense of introducing spill code in cold blocks. In addition, the program profile is also used to prioritize optimizable expressions; when not enough registers are available, the most profitable redundancies are removed first. To increase redundancy elimination within the allowed register pressure, our algorithm lowers the pressure with two new program transformation techniques: (a) whenever possible, we avoid inserting a temporary and instead access the reused value from existing variables, which reduces the life time of the temporary beyond existing live-range optimal algorithms; and (b) the live ranges of variables referenced by the expressions are shortened by combining expression hoisting with assignment sinking.

Keywords

data flow analysis code optimization partial redundancy elimination partial dead code elimination code motion register pressure spill code 

References

  1. 1.
    Bodik, R., Gupta, R., Soffa, M.L.: Complete Removal of Redundant Expressions. In: ACM SIGPLAN Conference on Programming Language Design and Implementation, Montreal, Canada, June 1998, pp. 1–14 (1998)Google Scholar
  2. 2.
    Bodik, R., Gupta, R., Soffa, M.L.: Load-Reuse Analysis: Design and Evaluation. In: ACM SIGPLAN Conference on Programming Language Design and Implementation, Atlanta, Georgia (May 1999)Google Scholar
  3. 3.
    Bodik, R., Gupta, R.: Partial Dead Code Elimination using Slicing Transformations. In: ACM SIGPLAN Conference on Programming Language Design and Implementation, Las Vegas, Nevada, June 1997, pp. 159–170 (1997)Google Scholar
  4. 4.
    Bodik, R., Anik, S.: Path-Sensitive Value-Flow Analysis. In: 25th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, San Diego, California (January 1998)Google Scholar
  5. 5.
    Briggs, P., Cooper, K.D., Torczon, L.: Rematerialization. In: ACM SIGPLAN Conf. on Prog. Language Design and Implementation, June 1992, pp. 311–321 (1992)Google Scholar
  6. 6.
    Briggs, P., Cooper, K.D.: Effective Partial Redundancy Elimination. In: ACM SIGPLAN Conference on Programming Language Design and Implementation, June 1994, pp. 159–170 (1994)Google Scholar
  7. 7.
    Chow, F., Chan, S., Kennedy, R., Liu, S.-M., Lo, R., Tu, P.: A New Algorithm for Partial Redundancy Elimination based upon SSA Form. In: ACM SIGPLAN Conference on Programming Language Design and Implementation, Las Vegas, Nevada, June 1997, pp. 273–286 (1997)Google Scholar
  8. 8.
    Click, C.: Global Code Motion Global Value Numbering. In: ACM SIGPLAN Conference on Programming Language Design and Implementation, LaJolla, CA, June 1995, pp. 246–257 (1995)Google Scholar
  9. 9.
    Dhamdhere, D.M.: Practical Adaptation of Global Optimization Algorithm of Morel and Renvoise. ACM Trans. on Programming Languages 13(2), 291–294 (1991)CrossRefGoogle Scholar
  10. 10.
    Gupta, R.: A Code Motion Framework for Global Instruction Scheduling. In: Koskimies, K. (ed.) CC 1998. LNCS, vol. 1383, pp. 219–233. Springer, Heidelberg (1998)CrossRefGoogle Scholar
  11. 11.
    Gupta, R., Berson, D., Fang., J.Z.: Path Profile GuidedP artial DeadCo de Elimination using Predication. In: International Conference on Parallel Architectures and Compilation Techniques, San Francisco, Ca, November 1997, pp. 102–115 (1997)Google Scholar
  12. 12.
    Gupta, R., Berson, D., Fang., J.Z.: Resource-Sensitive Profile-Directed Data Flow Analysis for Code Optimization. In: The 30th Annual IEEE/ACM International Symposium on Microarchitecture, Research Triangle Park, NC, December 1997, pp. 558–568 (1997)Google Scholar
  13. 13.
    Gupta, R., Berson, D., Fang, J.Z.: Path Profile Guided Partial Redundancy Elimination using Speculation. In: IEEE International Conference on Computer Languages, Chicago, Illinois, May 1998, pp. 230–239 (1998)Google Scholar
  14. 14.
    Horspool, R.N., Ho, H.C.: Partial Redundancy Elimination Driven by a Cost- Benefit Analysis. In: 8th Israeli Conference on Computer Systems and Software Engineering, Herzliya, Israel, June 1997, pp. 111–118 (1997)Google Scholar
  15. 15.
    Ruthing, O.: Optimal Code Motion in Presence of Large Expressions. In: IEEE International Conference on Computer Languages, Chicago, Illinois (1998)Google Scholar
  16. 16.
    Morel, E., Renvoise, C.: Global Optimization by Suppression of Partial Redundancies. Communications of the ACM 22(2), 96–103 (1979)zbMATHCrossRefMathSciNetGoogle Scholar
  17. 17.
    Knoop, J., Ruthing, O., Steffen, B.: Lazy Code Motion. In: Proceedings of Conference on Programming Language Design and Implementation, pp. 224–234 (1992)Google Scholar
  18. 18.
    Knoop, J., Ruthing, O., Steffen, B.: Partial Dead Code Elimination. In: Proceedings of Conference on Programming Language Design and Implementation, pp. 147–158 (1994)Google Scholar
  19. 19.
    Steffen, B.: Data Flow Analysis as Model Checking. In: Ito, T., Meyer, A.R. (eds.) TACS 1991. LNCS, vol. 526. Springer, Heidelberg (1991)Google Scholar
  20. 20.
    Steffen, B., Knoop, J., Rüthing, O.: The value flow graph: A program representation for optimal program transformations. In: Jones, N.D. (ed.) ESOP 1990. LNCS, vol. 432. Springer, Heidelberg (1990)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 1999

Authors and Affiliations

  • Rajiv Gupta
    • 1
  • Rastislav Bodík
    • 1
  1. 1.Dept. of Computer ScienceUniv. of PittsburghPittsburghUSA

Personalised recommendations