Common Subexpression Elimination - Principle

Principle

The possibility to perform CSE is based on available expression analysis (a data flow analysis). An expression b*c is available at a point p in a program if:

  • every path from the initial node to p evaluates b*c before reaching p,
  • and there are no assignments to b or c after the evaluation but before p.

The cost/benefit analysis performed by an optimizer will calculate whether the cost of the store to tmp is less than the cost of the multiplication; in practice other factors such as which values are held in which registers are also significant.

Compiler writers distinguish two kinds of CSE:

  • local common subexpression elimination works within a single basic block
  • global common subexpression elimination works on an entire procedure,

Both kinds rely on data flow analysis of which expressions are available at which points in a program.

Read more about this topic:  Common Subexpression Elimination

Famous quotes containing the word principle:

    I often wish for the end of the wretched remnant of my life; and that wish is a rational one; but then the innate principle of self-preservation, wisely implanted in our natures, for obvious purposes, opposes that wish, and makes us endeavour to spin out our thread as long as we can, however decayed and rotten it may be.
    Philip Dormer Stanhope, 4th Earl Chesterfield (1694–1773)

    All Protestantism, even the most cold and passive, is a sort of dissent. But the religion most prevalent in our northern colonies is a refinement on the principle of resistance; it is the dissidence of dissent, and the Protestantism of the Protestant religion.
    Edmund Burke (1729–1797)

    The principle office of history I take to be this: to prevent virtuous actions from being forgotten, and that evil words and deeds should fear an infamous reputation with posterity.
    Tacitus (c. 55–117)