Code Size Reduction by Compiler Tuning

  • Masayo Haneda
  • Peter M. W. Knijnenburg
  • Harry A. G. Wijshoff
Part of the Lecture Notes in Computer Science book series (LNCS, volume 4017)


Code size is a main cost factor for many high volume electronic devices. It is therefore important to reduce the size of the applications in an embedded system. Several methods have been proposed to deal with this problem, mostly based on compressing the binaries. In this paper, we approach the problem from a different perspective. We try to exploit the back end code optimizations present in a production compiler to generate as few assembly instructions as possible. This approach is based on iterative compilation in which many different versions of the code are tested. We employ statistical analysis to identify the compiler options that have the largest effect on code size. We have applied this technique to gcc 3.3.4 using the MediaBench suite and four target architectures. We show that in almost all cases we produce shorter codes than the standard setting -Os does which is designed to optimize for size. In some cases, we generate code that is 30% shorter than -Os.


Orthogonal Array Code Size Assembly Code Instruction Schedule Short Code 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Beszédes, A., Ferenc, R., Gyimóthy, T., Dolenc, A., Karsisto, K.: Survey of code-size reduction methods. ACM Comput. Surv. 35, 223–267 (2003)CrossRefGoogle Scholar
  2. 2.
    Cooper, K., Hall, M., Torczon, L.: Unexpected side effects of inline substitution: A case study. ACM Letters on Programming Languages and Systems 1, 22–32 (1992)CrossRefGoogle Scholar
  3. 3.
    Pinkers, R.P.J., Knijnenburg, P.M.W., Haneda, M., Wijshoff, H.A.G.: Statistical selection of compiler options. In: Proc. Workshop on Modeling, Analysis, and Simulation of Computer and Telecommunication Systems (MASCOTS), pp. 494–501 (2004)Google Scholar
  4. 4.
    Fraser, C., Myers, E., Wendt, A.: Analyzing and compressing assembly code. In: Proc. SIGPLAN symposium on Compiler Construction, pp. 117–121 (1984)Google Scholar
  5. 5.
    Cooper, K., McIntosh, N.: Enhanced code compression for embedded risc processors. In: Proc. Programming Language Design and Implementation (PLDI), pp. 139–149 (1999)Google Scholar
  6. 6.
    Debray, S., Evans, W., Muth, R., Sutter, B.D.: Compiler techniques for code compaction. ACM Trans. Programming Languages and Systems 22, 378–415 (2000)CrossRefGoogle Scholar
  7. 7.
    Mathias, K., Eshelman, L., Schaffer, J., Augusteijn, L., Hoogendijk, P., van de Wiel, R.: Code compaction using genetic algorithms. In: Proc. Genetic and Evolutionary Computation Conference (GECCO), pp. 710–717 (2000)Google Scholar
  8. 8.
    Sutter, B.D., Vandierendonck, H., Bus, B.D., Bosschere, K.D.: On the side-effects of code abstraction. In: Proc. Language, Compiler, and Tool for Emebedded Systems (LCTES), pp. 244–253 (2003)Google Scholar
  9. 9.
    Cooper, K., Schielke, P., Subramanian, D.: Optimizing for reduced code space using genetic algorithms. In: Proc. Languages, Compilers, and Tools for Embedded Systems (LCTES), pp. 1–9 (1999)Google Scholar
  10. 10.
    Hedayat, A., Sloane, N., Stufken, J.: Orthogonal Arrays: Theory and Applications. Series in Statistics. Springer, Heidelberg (1999)zbMATHGoogle Scholar
  11. 11.
    Sloane, N.: A library of orthogonal arrays,
  12. 12.
    Hollander, M., Wolfe, D.A.: Nonparametric Statistical Methods. Wiley Series in Probability and Statistics (1999)Google Scholar
  13. 13.
    GNU Consortium: GCC online documentation,
  14. 14.
  15. 15.
    Haneda, M., Knijnenburg, P., Wijshoff, H.: Code size reduction by compiler tuning. Technical report, LIACS, Leiden Univeresity (2005)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2006

Authors and Affiliations

  • Masayo Haneda
    • 1
  • Peter M. W. Knijnenburg
    • 1
    • 2
  • Harry A. G. Wijshoff
    • 1
  1. 1.LIACSLeiden UniversityLeidenThe Netherlands
  2. 2.University of AmsterdamAmsterdamThe Netherlands

Personalised recommendations