Peephole optimization examples.
Redundant loads and stores
. Consider the code sequence
Move R0 , a
Move a, R0
. Instruction 2 can always be removed if it does not have a label.
Now, we will give some examples of program transformations that are characteristic of peephole optimization:
Redundant loads and stores:
If we see the instruction sequence
Move R0 , a
Move a, R0
We can delete instruction (2) because whenever (2) is executed, (1) will ensure that the value of a is already in register R0. Note that is (2) has a label, we could not be sure that (1) was always executed immediately before (2) and so we could not remove (2).
|