Branch elimination by condition merging

  • Authors:
  • William C. Kreahling;David Whalley;Mark W. Bailey;Xin Yuan;Gang-Ryung Uh;Robert van Engelen

  • Affiliations:
  • Florida State University, Tallahassee, FL;Florida State University, Tallahassee, FL;Hamilton College, Clinton, NY;Florida State University, Tallahassee, FL;Boise State University, Boise, ID;Florida State University, Tallahassee, FL

  • Venue:
  • Software—Practice & Experience
  • Year:
  • 2005

Quantified Score

Hi-index 0.00

Visualization

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. These sets of branches can include tests of multiple variables. For instance, the test if (p1 ! = 0 && p2 ! = 0), which is testing for NULL pointers, can be replaced with if (p1 & p2 ! = 0). Program profiling is performed to target condition merging along frequently executed paths. The results show that eliminating branches by merging conditions can significantly reduce the number of conditional branches executed in non-numerical applications.