Common Subexpression Elimination - Benefits

Benefits

The benefits of performing CSE are great enough that it is a commonly used optimization.

In simple cases like in the example above, programmers may manually eliminate the duplicate expressions while writing the code. The greatest source of CSEs are intermediate code sequences generated by the compiler, such as for array indexing calculations, where it is not possible for the developer to manually intervene. In some cases language features may create many duplicate expressions. For instance, C macros, where macro expansions may result in common subexpressions not apparent in the original source code.

Compilers need to be judicious about the number of temporaries created to hold values. An excessive number of temporary values creates register pressure possibly resulting in spilling registers to memory, which may take longer than simply recomputing an arithmetic result when it is needed.

Read more about this topic:  Common Subexpression Elimination

Famous quotes containing the word benefits:

    In America the young are always ready to give to those who are older than themselves the full benefits of their inexperience.
    Oscar Wilde (1854–1900)

    Through all opposition the personal benefits of the reform [dress] [bracketed word in original] have compensated; but had it been mainly sacrifice, the thought of working for the amelioration of women and the elevation of humanity would still have been the beacon-star guiding me on amid all discouragements.
    Susan Pecker Fowler (1823–1911)

    One of your biggest jobs as a parent of multiples is no bigger than simply talking to your children individually and requiring that they respond to you individually as well. The benefits of this kind of communication can be enormous, in terms of the relationship you develop with each child, in terms of their language development, and eventually in terms of their sense of individuality, too.
    Pamela Patrick Novotny (20th century)