Another example for optimization on a higher level is the calculation of absolute values. In C, the programmer has to write something on the order of:
float x, y;
x = (y < 0.0) ? -y : y;
This results in lengthy and inefficient code. The Compiler recognizes cases like this and treats them specially in order to generate the most efficient code. Only the most significant bit has to be cleared.