Abstract
In code generation, instruction selection chooses processor instructions to implement a program under compilation where code quality crucially depends on the choice of instructions. Using methods from combinatorial optimization, this paper proposes an expressive model that integrates global instruction selection with global code motion. The model introduces (1) handling of memory computations and function calls, (2) a method for inserting additional jump instructions where necessary, (3) a dependency-based technique to ensure correct combinations of instructions, (4) value reuse to improve code quality, and (5) an objective function that reduces compilation time and increases scalability by exploiting bounding techniques. The approach is demonstrated to be complete and practical, competitive with LLVM, and potentially optimal (w.r.t. the model) for medium-sized functions. The results show that combinatorial optimization for instruction selection is well-suited to exploit the potential of modern processors in embedded systems.
- CPU Benchmarks -- Single Thread Performance. PassMark Software. URL: http://www.cpubenchmark.net/singleThread.html, updated June 2, 2017.Google Scholar
- A. V. Aho, M. Ganapathi, and S. W. K. Tjiang. 1989. Code Generation Using Tree Matching and Dynamic Programming. ACM Transactions on Programming Languages and Systems 11(4):491--516, 1989. Google Scholar
Digital Library
- J. R. Allen, K. Kennedy, C. Porterfield, and J. Warren. 1983. Conversion of Control Dependence to Data Dependence. In POPL’83. 177--189, 1983. Google Scholar
Digital Library
- M. Ali Arslan and K. Kuchcinski. 2013. Instruction Selection and Scheduling for DSP Kernels on Custom Architectures. In DSD’13. IEEE. 2013. Google Scholar
Digital Library
- S. Bansal and A. Aiken. 2006. Automatic Generation of Peephole Superoptimizers. In ASPLOS’06. 394--403. ACM, 2006. Google Scholar
Digital Library
- G. Barany and A. Krall. 2013. Optimal and Heuristic Global Code Motion for Minimal Spilling. In CC’13. 21--40. Springer, 2013. Google Scholar
Digital Library
- S. Bashford and R. Leupers. 1999. Constraint Driven Code Selection for Fixed-Point DSPs. In DAC’99. 817--822. ACM/IEEE, 1999. Google Scholar
Digital Library
- A. Bednarski and C. W. Kessler. 2006. Optimal Integrated VLIW Code Generation with Integer Linear Programming. 2006.Google Scholar
- J. Boender and C. S. Coen. 2014. On the Correctness of a Branch Displacement Algorithm. In TACAS’14. 605--619. Springer, 2014.Google Scholar
- S. Buchwald. 2015. Optgen: A Generator for Local Optimizations. In CC’15. 171--189. Springer, 2015.Google Scholar
- S. Buchwald and A. Zwinkau. 2010. Instruction Selection by Graph Transformation. In CASES’10. 31--40, 2010. Google Scholar
Digital Library
- R. C. Lozano, M. Carlsson, F. Drejhammar, and C. Schulte. Constraint-based Register Allocation and Instruction Scheduling. In CP’12. 750--766. Springer.Google Scholar
- R. C. Lozano, M. Carlsson, G. H. Blindell, and C. Schulte. 2014. Combinatorial Spill Code Optimization and Ultimate Coalescing. In LCTES’14. 23--32. ACM, 2014. Google Scholar
Digital Library
- G. G. Chu. 2011. Improving Combinatorial Optimization. Ph.D. Dissertation. The University of Melbourne, Australia. 2011.Google Scholar
- C. Click. 1995. Global Code Motion/Global Value Numbering. In PLDI’95. 246--257. ACM, 1995. Google Scholar
Digital Library
- L. P. Cordella, P. Foggia, C. Sansone, and M. Vento. 2004. A (Sub)Graph Isomorphism Algorithm for Matching Large Graphs. IEEE Transactions on Pattern Analysis and Machine Intelligence 26(10):1367--1372, 2004. Google Scholar
Digital Library
- R. Cytron, J. Ferrante, B. K. Rosen, M. N. Wegman, and F. K. Zadeck. 1991. Efficiently Computing Static Single Assignment Form and the Control Dependence Graph. ACM Transactions on Programming Languages and Systems 13(4):451--490, 1991. Google Scholar
Digital Library
- D. Ebner, F. Brandner, B. Scholz, A. Krall, P. Wiedermann, and A. Kadlec. 2008. Generalized Instruction Selection Using SSA-Graphs. In LCTES’08. 31--40. ACM, 2008. Google Scholar
Digital Library
- E. Eckstein, O. König, and B. Scholz. 2003. Code Instruction Selection Based on SSA-Graphs. In SCOPES’03. 49--65. ACM, 2003.Google Scholar
- M. A. Ertl. 1999. Optimal Code Selection in DAGs. In POPL’99. 242--249. ACM, 1999. Google Scholar
Digital Library
- M. A. Ertl, K. Casey, and D. Gregg. 2006. Fast and Flexible Instruction Selection with On-Demand Tree-Parsing Automata. In PLDI’06. 52--60. ACM, 2006. Google Scholar
Digital Library
- J. A. Fisher. 1981. Trace Scheduling: A Technique for Global Microcode Compaction. IEEE Trans. Comput. 30(7):478--490, 1981. Google Scholar
Digital Library
- A. Floch, C. Wolinski, and K. Kuchcinski. 2010. Combined Scheduling and Instruction Selection for Processors with Reconfigurable Cell Fabric. In ASAP’10. 167--174. IEEE, 2010.Google Scholar
- C. W. Fraser, R. R. Henry, and T. A. Proebsting. 1992. BURG: Fast Optimal Instruction Selection and Tree Parsing. SIGPLAN Notices 27(4):68--76, 1992. Google Scholar
Digital Library
- C. H. Gebotys. 1997. An Efficient Model for DSP Code Generation: Performance, Code Size, Estimated Energy. In ISSS’97. 41--47. IEEE, 1997. Google Scholar
Digital Library
- M. P. Gerlek, E. Stoltz, and M. Wolfe. 1995. Beyond Induction Variables: Detecting and Classifying Sequences Using a Demand-driven SSA Form. ACM Transactions on Programming Languages and Systems 17(1):85--122, 1995. Google Scholar
Digital Library
- T. Granlund and R. Kenner. 1992. Eliminating Branches Using a Superoptimizer and the GNU C Compiler. In PLDI’92. 341--352. ACM, 1992. Google Scholar
Digital Library
- G. H. Blindell. 2016. Instruction Selection: Principles, Methods, and Applications. Springer. 2016. ISBN 978-3-319-34017-3. Google Scholar
Digital Library
- G. H. Blindell, R. C. Lozano, M. Carlsson, and C. Schulte. 2015. Modeling Universal Instruction Selection. In CP’15. 609--626. Springer, 2015. Google Scholar
Digital Library
- D. B. Johnson. 1975. Finding All the Elementary Circuits of a Directed Graph. SIAM J. Comput. 4(1):77--84, 1975.Google Scholar
Digital Library
- N. Johnson and A. Mycroft. 2003. Combined Code Motion and Register Allocation Using the Value State Dependence Graph. In CC’03. 1--16. Springer, 2003. Google Scholar
Digital Library
- A. Jordan, N. Kim, and A. Krall. 2013. IR-level Versus Machine-level If-conversion for Predicated Architectures. In ODES’13. 3--10. ACM, 2013. Google Scholar
Digital Library
- D. R. Koes and S. C. Goldstein. 2008. Near-Optimal Instruction Selection on DAGs. In CGO’08. 45--54. IEEE/ACM, 2008. Google Scholar
Digital Library
- A. H. Land and A. G. Doig. 1960. An automatic method of solving discrete programming problems. Econometrica: Journal of the Econometric Society 497--520, 1960.Google Scholar
- S. Larsen and S. Amarasinghe. 2000. Exploiting Superword Level Parallelism with Multimedia Instruction Sets. In PLDI’00. 145--156. ACM, 2000. Google Scholar
Digital Library
- C. Lattner and V. Adve. 2004. LLVM: A Compilation Framework for Lifelong Program Analysis 8 Transformation. In IEEE/ACM International Symposium on Code Generation and Optimization. 75--86. IEEE, 2004. Google Scholar
Digital Library
- J.-L. Laurière. 1978. A Language and a Program for Stating and Solving Combinatorial Problems. Artificial Intelligence 10, (1):29--127, 1978.Google Scholar
Cross Ref
- Y. Law and J. Lee. 2006. Symmetry Breaking Constraints for Value Symmetries in Constraint Satisfaction. Constraints 11, (2--3):221--267, 2006. Google Scholar
Digital Library
- C. Lecoutre and R. Szymanek. 2006. Generalized Arc Consistency for Positive Table Constraints. In CP’06. 284--298. Springer, 2006. Google Scholar
Digital Library
- C. Lee, M. Potkonjak, and W. H. Mangione-Smith. 1997. MediaBench: A Tool for Evaluating and Synthesizing Multimedia and Communications Systems. In MICRO’97. 330--335. IEEE, 1997. Google Scholar
Digital Library
- R. Leupers. 2000. Code Selection for Media Processors with SIMD Instructions. In DATE’00. 4--8. IEEE, 2000. Google Scholar
Digital Library
- J. Liu, Y. Zhang, O. Jang, W. Ding, and M. Kandemir. 2012. A Compiler Framework for Extracting Superword Level Parallelism. In PLDI’12. 347--358. ACM, 2012. Google Scholar
Digital Library
- N. P. Lopes, D. Menendez, S. Nagarakatte, and J. Regehr. 2015. Provably Correct Peephole Optimizations with Alive. In PLDI’15. 22--32. ACM, 2015. Google Scholar
Digital Library
- K. Martin, C. Wolinski, K. Kuchcinski, A. Floch, and F. Charot. 2009. Constraint-Driven Instructions Selection and Application Scheduling in the DURASE System. In ASAP’09. 145--152. IEEE, 2009. Google Scholar
Digital Library
- N. Nethercote, P. J. Stuckey, R. Becket, S. Brand, G. J. Duck, and G. Tack. 2007. MiniZinc: Towards a Standard CP Modelling Language. In CP’07. 529--543. Springer, 2007. Google Scholar
Digital Library
- E. Pelegrí-Llopart and S. L. Graham. 1988. Optimal Code Generation for Expression Trees: An Application of BURS Theory. In POPL’88. 294--308. ACM, 1988. Google Scholar
Digital Library
- A. Phansalkar, A. Joshi, L. Eeckhout, and L. K. John. 2005. Measuring Program Similarity: Experiments with SPEC CPU Benchmark Suites. In ISPASS’05. 10--20. IEEE, 2005. Google Scholar
Digital Library
- Hexagon V5/V55 Programmer’s Reference Manual. Qualcomm Technologies Inc. 80-N2040-8 Rev. A.Google Scholar
- F. Rossi, P. van Beek, and T. Walsh. 2006. Handbook of Constraint Programming. Elsevier Science Inc. 2006. ISBN 0-444-52726-5. Google Scholar
Digital Library
- V. Sarkar, M. J. Serrano, and B. B. Simons. 2001. Register-sensitive Selection, Duplication, and Sequencing of Instructions. In ICS’01. 277--288. ACM, 2001. Google Scholar
Digital Library
- H. Tanaka, S. Kobayashi, Y. Takeuchi, K. Sakanushi, and M. Imai. 2013. A Code Selection Method for SIMD Processors with PACK Instructions. In SCOPES’03. 66--80. Springer, 2013.Google Scholar
- V. Živojnović, J. M. Velarde, C. Schläger, and H. Meyr. 1994. DSPstone: A DSP-Oriented Benchmarking Methodology. In ICSPAT’94. 715--720. Miller Freeman, 1994.Google Scholar
- N. J. Warter, S. A. Mahlke, W.-M. W. Hwu, and B. R. Rau. 1993. Reverse If-Conversion. In PLDI’93. 290--299. ACM, 1993. Google Scholar
Digital Library
- T. Wilson, G. Grewal, B. Halley, and D. Banerji. 1994. An Integrated Approach to Retargetable Code Generation. In ISSS’94. 70--75. IEEE, 1994. Google Scholar
Digital Library
Index Terms
Complete and Practical Universal Instruction Selection
Recommendations
Near-optimal instruction selection on dags
CGO '08: Proceedings of the 6th annual IEEE/ACM international symposium on Code generation and optimizationInstruction selection is a key component of code generation. High quality instruction selection is of particular importance in the embedded space where complex instruction sets are common and code size is a prime concern. Although instruction selection ...
Generalized instruction selection using SSA-graphs
LCTES '08: Proceedings of the 2008 ACM SIGPLAN-SIGBED conference on Languages, compilers, and tools for embedded systemsInstruction selection is a well-studied compiler phase that translates the compiler's intermediate representation of programs to a sequence of target-dependent machine instructions optimizing for various compiler objectives (e.g. speed and space). Most ...
Generalized instruction selection using SSA-graphs
LCTES '08Instruction selection is a well-studied compiler phase that translates the compiler's intermediate representation of programs to a sequence of target-dependent machine instructions optimizing for various compiler objectives (e.g. speed and space). Most ...






Comments