Chapter 2: Introduction to compilers

Code Optimization

. No strong counter part with English, but is similar to editing/précis writing

. Automatically modify programs so that they

- Run faster

- Use less resources (memory, registers, space, fewer fetches etc.)

. Some common optimizations

- Common sub-expression elimination

- Copy propagation

- Dead code elimination

- Code motion

- Strength reduction

- Constant folding

. Example: x = 15 * 3 is transformed to x = 45

There is no strong counterpart in English, this is similar to precise writing where one cuts down the redundant words. It basically cuts down the redundancy. We modify the compiled code to make it more efficient such that it can - Run faster - Use less resources, such as memory, register, space, fewer fetches etc.