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.
This research was supported in part by NSF grants CCR-9904943, EIA-0072043, CCR-0208892, CCR-0105422, and by DOE grant DEFG02-02ER25543.
Chapter PDF
Similar content being viewed by others
Keywords
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.
References
Dongarra, J.J., Hinds, A.R.: Unrolling loops in FORTRAN. Software, Practice and Experience 9, 219–226 (1979)
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); Transformations
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)
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)
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)
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)
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)
Yang, M., Uh, G.R., Whalley, D.B.: Efficient and effective branch reordering using profile data, vol. 24, pp. 667–697 (2002)
Hennessy, J., Patterson, D.: Computer Architecture: A Quantitative Approach, 2nd edn. Morgan Kaufmann Publishers Inc., San Francisco (1996)
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)
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)
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)
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
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2003 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Kreahling, W., Whalley, D., Bailey, M., Yuan, X., Uh, GR., van Engelen, R. (2003). Branch Elimination via Multi-variable Condition Merging. In: Kosch, H., Böszörményi, L., Hellwagner, H. (eds) Euro-Par 2003 Parallel Processing. Euro-Par 2003. Lecture Notes in Computer Science, vol 2790. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-540-45209-6_40
Download citation
DOI: https://doi.org/10.1007/978-3-540-45209-6_40
Published:
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-40788-1
Online ISBN: 978-3-540-45209-6
eBook Packages: Springer Book Archive