These days, compilers are pretty smart. They can perform all sorts of code transformations, from simple inlining to sophisticated register analysis, that make compiled code run faster. In most situations, faster is better than smaller, because disk space is ridiculously cheap. However, on the embedded systems with which we routinely work, small is often at least as important as fast, because the systems on which we work sometimes have extreme memory constraints and no disk space. This chapter describes GCC’s code optimization capabilities. By this point in the book, you have a pretty good grasp of how to compile your code and how to make GCC do what you want it to. The next step, accordingly, is to make your code faster or smaller. If your luck holds out, you might even be able to make your next program faster and smaller. After a quick, high-level overview of compiler optimization theory you will look at GCC’s command-line options for code optimization. First, you will look at GCC’s general, architecture-independent optimizations. Then, you will learn about the architecture-specific optimizations.
KeywordsBasic Block Optimize Code Code Size Memory Footprint Code Transformation
Unable to display preview. Download preview PDF.