Advertisement

Branch Elimination via Multi-variable Condition Merging

  • William Kreahling
  • David Whalley
  • Mark Bailey
  • Xin Yuan
  • Gang-Ryung Uh
  • Robert van Engelen
Part of the Lecture Notes in Computer Science book series (LNCS, volume 2790)

Abstract

Conditional branches are expensive. Branches require a significant percentage of execution cycles since they occur frequently and cause pipeline flushes when mispredicted. In addition, branches result in forks in the control flow, which can prevent other code-improving transformations from being applied. In this paper we describe profile-based techniques for replacing the execution of a set of two or more branches with a single branch on a conventional scalar processor. First, we gather profile information to detect the frequently executed paths in a program. Second, we detect sets of conditions in frequently executed paths that can be merged into a single condition. Third, we estimate the benefit of merging each set of conditions. Finally, we restructure the control flow to merge the sets that are deemed beneficial. The results show that eliminating branches by merging conditions can significantly reduce the number of conditional branches performed in non-numerical applications.

Keywords

Multiple Variable Single Branch Conditional Branch Execution Cycle Branch Prediction 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 1.
    Dongarra, J.J., Hinds, A.R.: Unrolling loops in FORTRAN. Software, Practice and Experience 9, 219–226 (1979)zbMATHCrossRefGoogle Scholar
  2. 2.
    Allen, F.E., Cocke, J.: A catalogue of optimizing transformations. In: Rustin, R., ed.: Design and Optimization of Compilers, pp. 1–30. Prentice-Hall, Englewood Cliffs (1971); TransformationsGoogle Scholar
  3. 3.
    Granlund, T., Kenner, R.: Eliminating branches using a superoptimiser and the GNU C compiler. In: Fraser, C.W. (ed.) Proceedings of the SIGPLAN 1992 Conference on Programming Language Design and Implementation, San Francisco, CA, pp. 341–352. ACM Press, New York (1992)Google Scholar
  4. 4.
    Mueller, F., Whalley, D.B.: Avoiding conditional branches by code replication. In: Proceedings of the SIGPLAN 1995 Conference on Programming Language Design and Implementation, La Jolla, CA, pp. 56–66. ACM Press, New York (1995)CrossRefGoogle Scholar
  5. 5.
    Bodík, R., Gupta, R., Soffa, M.L.: Interprocedural conditional branch elimination. In: Proceedings of the SIGPLAN 1997 Conference on Programming Language Design and Implementation. ACM SIGPLAN Notices, vol. 32(5), pp. 146–158. ACM Press, New York (1997)CrossRefGoogle Scholar
  6. 6.
    Uh, G.R., Whalley, D.B.: Coalescing conditional branches into efficient indirect jumps. In: Proceedings of the International Static Analysis Symposium, pp. 315–329 (1997)Google Scholar
  7. 7.
    Yang, M., Uh, G.R., Whalley, D.B.: Improving performance by branch reordering. In: Proceedings of the SIGPLAN 1998 Conference on Programming Language Design and Implementation, Montreal, Canada, pp. 130–141. ACM Press, New York (1998)Google Scholar
  8. 8.
    Yang, M., Uh, G.R., Whalley, D.B.: Efficient and effective branch reordering using profile data, vol. 24, pp. 667–697 (2002)Google Scholar
  9. 9.
    Hennessy, J., Patterson, D.: Computer Architecture: A Quantitative Approach, 2nd edn. Morgan Kaufmann Publishers Inc., San Francisco (1996)Google Scholar
  10. 10.
    Warter, N.J., Mahlke, S.A., Hwu, W.M.W., Rau, B.R.: Reverse If-Conversion. In: Proceedings of the Conference on Programming Language Design and Implementation, pp. 290–299 (1993)Google Scholar
  11. 11.
    Schlansker, M., Kathail, V.: Critical path reduction for scalar programs. In: proceedings of the 28th Annual International Symposium on Microarchitecture, Ann Arbor, Michigan, IEEE Computer Society TC-MICRO and ACM SIGMICRO, pp. 57–69. IEEE Computer Society Press, Los Alamitos (1995)Google Scholar
  12. 12.
    Schlansker, M., Mahlke, S., Johnson, R.: Control CPR: A branch height reduction optimization for EPIC architectures. In: Proceedings of the SIGPLAN 1999 Conference on Programming Language Design and Implementation, Atlanta, Georgia, pp. 155–168. ACM Press, New York (1999)CrossRefGoogle Scholar
  13. 13.
    Kreahling, W., Whalley, D., Bailey, M., Yuan, X., Uh, G.R., van Engelen, R.: Branch elimination by condition merging. Technical report, Florida State University (2003), http://websrv.cs.fsu.edu/research/reports/TR-030201.ps

Copyright information

© Springer-Verlag Berlin Heidelberg 2003

Authors and Affiliations

  • William Kreahling
    • 1
  • David Whalley
    • 1
  • Mark Bailey
    • 2
  • Xin Yuan
    • 1
  • Gang-Ryung Uh
    • 3
  • Robert van Engelen
    • 1
  1. 1.Florida State UniversityTallahasseeUSA
  2. 2.Hamilton CollegeClintonUSA
  3. 3.Boise State UniversityBoiseUSA

Personalised recommendations