Improving performance by branch reordering

  • Authors:
  • Minghui Yang;Gang-Ryung Uh;David B. Whalley

  • Affiliations:
  • Department of Computer Science, Florida State University, Tallahassee, FL;Lucent Technologies, 1247 S. Cedar Crest Blvd., Allentown, PA;Department of Computer Science, Florida State University, Tallahassee, FL

  • Venue:
  • PLDI '98 Proceedings of the ACM SIGPLAN 1998 conference on Programming language design and implementation
  • Year:
  • 1998

Quantified Score

Hi-index 0.00

Visualization

Abstract

The conditional branch has long been considered an expensive operation. The relative cost of conditional branches has increased as recently designed machines are now relying on deeper pipelines and higher multiple issue. Reducing the number of conditional branches executed can often result in a substantial performance benefit. This paper describes a code-improving transformation to reorder sequences of conditional branches. First, sequences of branches that can be reordered are detected in the control flow. Second, profiling information is collected to predict the probability that each branch will transfer control out of the sequence. Third, the cost of performing each conditional branch is estimated. Fourth, the most beneficial ordering of the branches based on the estimated probability and cost is selected. The most beneficial ordering often included the insertion of additional conditional branches that did not previously exist in the sequence. Finally, the control flow is restructured to refflect the new ordering. The results of applying the transformation were significant reductions in the dynamic number of instructions and branches, as well as decreases in execution time.