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:

    The first principle of a free society is an untrammeled flow of words in an open forum.
    Adlai Stevenson (1900–1965)

    The monk in hiding himself from the world becomes not less than himself, not less of a person, but more of a person, more truly and perfectly himself: for his personality and individuality are perfected in their true order, the spiritual, interior order, of union with God, the principle of all perfection.
    Thomas Merton (1915–1968)

    If there be one principle more deeply rooted than any other in the mind of every American, it is that we should have nothing to do with conquest.
    Thomas Jefferson (1743–1826)