Science Fair Projects Ideas - Common subexpression elimination

All Science Fair Projects

      

Science Fair Project Encyclopedia for Schools!

  Search    Browse    Forum  Coach    Links    Editor    Help    Tell-a-Friend    Encyclopedia    Dictionary     

Science Fair Project Encyclopedia

For information on any area of science that interests you,
enter a keyword (eg. scientific method, molecule, cloud, carbohydrate etc.).
Or else, you can start by choosing any of the categories below.

Common subexpression elimination

In compiler theory, common subexpression elimination (CSE) is the practice of finding repeated redundant expression evaluations, and replacing them with a single computation assigned to a temporary variable. Although it can be done manually, the term usually refers to a compiler optimization.

Here is a simple example:

a = b * c + g;
d = b * c * d;
e = b * c;

which does four multiplies and one addition, can be replaced by

tmp = b * c;
a = tmp + g;
d = tmp * d;
e = tmp;

which does only two multiplies and one addition.

Although in simple cases like this, most programmers will habitually create "tmp" while writing the code, the compiler optimization becomes more important in the case of C macros, where macro expansions may result in common subexpressions not apparent in the original source, or in code sequences generated by the compiler, such as for array indexing calculations, or after in-line expansion.

CSE is usually advantageous, but the compiler needs to be judicious about the number of subexpressions it saves in temporaries; a excessive number of temporary values creates register pressure possibly resulting in register allocation saving and loading temporaries to/from memory, which may take longer than simply recomputing an arithmetic result when it is needed.

Compiler writers distinguish two kinds of CSE:

  • local common subexpression elimination works within a single basic block and is thus a simple optimization to implement.
  • global common subexpression elimination works on an entire procedure, and relies on dataflow analysis which expressions are available at which points in a procedure.

Reference

  • Steven S. Muchnick , Advanced Compiler Design and Implementation (Morgan Kauffmann , 1997) pp. 378-396
10-26-2009 08:16:03
The contents of this article is licensed from www.wikipedia.org under the GNU Free Documentation License. Click here to see the transparent copy and copyright details
Science kits, science lessons, science toys, maths toys, hobby kits, science games and books - these are some of many products that can help give your kid an edge in their science fair projects, and develop a tremendous interest in the study of science. When shopping for a science kit or other supplies, make sure that you carefully review the features and quality of the products. Compare prices by going to several online stores. Read product reviews online or refer to magazines.

Start by looking for your science kit review or science toy review. Compare prices but remember, Price $ is not everything. Quality does matter.
Science Fair Coach
What do science fair judges look out for?
ScienceHound
Science Fair Projects for students of all ages
All Science Fair Projects.com Site
All Science Fair Projects Homepage
Search | Browse | Links | From-our-Editor | Books | Help | Contact | Privacy | Disclaimer | Copyright Notice