Common subexpression elimination
The removal of common subexpression ( English common subexpression elimination ) describes a compiler optimization. A search is made for partial expressions that have already been calculated. If any are found, the previous result is stored in a variable and the repeated calculation is replaced with the variable.
example
In the following program section, the value of a * b is calculated twice :
x = a * b + c;
y = a * b + d;
The CSE then transforms the section so that the first result is cached:
_tmp = a * b;
x = _tmp + c;
y = _tmp + d;
Individual evidence
- ↑ Steven S. Muchnick: Advanced Compiler Design & Implementation , Morgan Kaufmann Publishers, 1997, ISBN 1-55860-320-4