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:

    We rail at trade, but the historian of the world will see that it was the principle of liberty; that it settled America, and destroyed feudalism, and made peace and keeps peace; that it will abolish slavery.
    Ralph Waldo Emerson (1803–1882)

    The principle of avoiding the unnecessary expenditure of energy has enabled the species to survive in a world full of stimuli; but it prevents the survival of the aristocracy.
    Rebecca West (1892–1983)

    Now, what I want is, Facts. Teach these boys and girls nothing but Facts. Facts alone are wanted in life. Plant nothing else, and root out everything else. You can only form the minds of reasoning animals upon Facts: nothing else will ever be of any service to them. This is the principle on which I bring up my own children, and this is the principle on which I bring up these children. Stick to Facts, sir!
    Charles Dickens (1812–1870)