O'Reilly logo

Compilers: Principles and Practice by Himanshu B. Dave, Parag H. Dave

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

9.8 Machine-dependent Optimization

The naïve code generator that we have demonstrated several times does generate code which will execute (after assembly and linker steps) but the code quality is rather poor, in the following respect:

  • Program size is big because the generated instruction sequences are quite long.
  • Program execution time is long because there are redundant instructions and/or memory transfers.
  • There is an inadequate use of CPU registers.
  • The code generator does not make good use of the facilities of the machine, in the form of power of the instruction set.

An example: with the E compilation scheme, the statement:

total = total + count * count;

compiles to:

movl total, %eax pushl %eax movl count, %eax pushl %eax movl count, %eax ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required