Near-optimal intraprocedural branch alignment

Branch alignment reorders the basic blocks of a program to minimize pipeline penalties due to control-transfer instructions. Prior work in branch alignment has produced useful heuristic methods. We present a branch alignment algorithm that usually achieves the minimum possible pipeline penalty and on our benchmarks averages within 0.3% of a provable optimum. We compare the control penalties and running times of our algorithm to an older, greedy approach and observe that both the greedy method and our method are close to the lower bound on control penalties, suggesting that greedy is good enough. Surprisingly, in actual execution our method produces programs that run noticeably faster than the greedy method. We also report results from training and testing on different data sets, validating that our results can be achieved in real-world usage. Training and testing on different data sets slightly reduced the benefits from both branch alignment algorithms, but the ranking of the algorithms does not change, and the bulk of the benefits remain.

[1]  David B. Whalley,et al.  Avoiding conditional branches by code replication , 1995, PLDI '95.

[2]  Richard M. Karp,et al.  A Patching Algorithm for the Nonsymmetric Traveling-Salesman Problem , 1979, SIAM J. Comput..

[3]  Richard M. Karp,et al.  The traveling-salesman problem and minimum spanning trees: Part II , 1971, Math. Program..

[4]  Richard E. Korf,et al.  Performance of Linear-Space Search Algorithms , 1995, Artif. Intell..

[5]  Michael D. Smith,et al.  Improving the accuracy of static branch prediction using branch correlation , 1994, ASPLOS VI.

[6]  Craig Partridge,et al.  Improving UNIX kernel performance using profile based optimization , 1994 .

[7]  David Applegate,et al.  Finding Cuts in the TSP (A preliminary report) , 1995 .

[8]  Linda S. Wilson,et al.  Delivering binary object modification tools for program tools for program analysis and optimization , 1996 .

[9]  W. W. Hwu,et al.  Achieving high instruction cache performance with an optimizing compiler , 1989, ISCA '89.

[10]  Christos H. Papadimitriou,et al.  Local Search for the Asymmetric Traveling Salesman Problem , 1980, Oper. Res..

[11]  Steven W. K. Tjiang,et al.  SUIF: an infrastructure for research on parallelizing and optimizing compilers , 1994, SIGP.

[12]  David S. Johnson,et al.  Asymptotic experimental analysis for the Held-Karp traveling salesman bound , 1996, SODA '96.

[13]  Donald L. Miller,et al.  Exact Solution of Large Asymmetric Traveling Salesman Problems , 1991, Science.

[14]  Alan Jay Smith,et al.  Branch Prediction Strategies and Branch Target Buffer Design , 1995, Computer.

[15]  S. McFarling,et al.  Reducing the cost of branches , 1986, ISCA '86.

[16]  Andreas Krall,et al.  Improving semi-static branch prediction by code replication , 1994, PLDI '94.

[17]  Michael D. Smith,et al.  A comparative analysis of schemes for correlated branch prediction , 1995, Proceedings 22nd Annual International Symposium on Computer Architecture.

[18]  Michael D. Smith,et al.  Branch Instrumentation in SUIF , 1996 .

[19]  Linda S. Wilson,et al.  Delivering Binary Object Modication Tools for Program Analysis and Optimization , 1996, Digit. Tech. J..

[20]  Karl Pettis,et al.  Profile guided code positioning , 1990, PLDI '90.

[21]  S. McFarling Program optimization for instruction caches , 1989, ASPLOS 1989.

[22]  Edward W. Felten,et al.  Large-Step Markov Chains for the Traveling Salesman Problem , 1991, Complex Syst..

[23]  Joseph A. Fisher,et al.  Predicting conditional branch directions from previous runs of a program , 1992, ASPLOS V.

[24]  Dirk Grunwald,et al.  Reducing branch costs via branch alignment , 1994, ASPLOS VI.

[25]  James E. Smith,et al.  A study of branch prediction strategies , 1981, ISCA '98.

[26]  Josep Torrellas,et al.  Optimizing instruction cache performance for operating system intensive workloads , 1995, Proceedings of 1995 1st IEEE Symposium on High Performance Computer Architecture.

[27]  Richard M. Karp,et al.  The Traveling-Salesman Problem and Minimum Spanning Trees , 1970, Oper. Res..