HOME

TheInfoList



OR:

In
compiler theory In computing, a compiler is a computer program that translates computer code written in one programming language (the ''source'' language) into another language (the ''target'' language). The name "compiler" is primarily used for programs th ...
, partial redundancy elimination (PRE) is a
compiler optimization In computing, an optimizing compiler is a compiler that tries to minimize or maximize some attributes of an executable computer program. Common requirements are to minimize a program's execution time, memory footprint, storage size, and power con ...
that eliminates expressions that are redundant on some but not necessarily all paths through a program. PRE is a form of
common subexpression elimination In compiler theory, common subexpression elimination (CSE) is a compiler optimization that searches for instances of identical expressions (i.e., they all evaluate to the same value), and analyzes whether it is worthwhile replacing them with a sin ...
. An expression is called partially redundant if the
value Value or values may refer to: Ethics and social * Value (ethics) wherein said concept may be construed as treating actions themselves as abstract objects, associating value to them ** Values (Western philosophy) expands the notion of value beyo ...
computed by the expression is already available on some but not all paths through a program to that expression. An expression is fully redundant if the value computed by the expression is available on all paths through the program to that expression. PRE can eliminate partially redundant expressions by inserting the partially redundant expression on the paths that do not already compute it, thereby making the partially redundant expression fully redundant. For instance, in the following code: if (some_condition) else z = x + 4; the expression x+4 assigned to z is partially redundant because it is computed twice if some_condition is true. PRE would perform
code motion In computer science, code motion, also known as code hoisting, code sinking, loop-invariant code motion, or code factoring, is a blanket term for any process that moves code within a program for performance or size benefits, and is a common optim ...
on the expression to yield the following optimized code: if (some_condition) else z = t; An interesting property of PRE is that it performs (a form of)
common subexpression elimination In compiler theory, common subexpression elimination (CSE) is a compiler optimization that searches for instances of identical expressions (i.e., they all evaluate to the same value), and analyzes whether it is worthwhile replacing them with a sin ...
and
loop-invariant code motion In computer programming, loop-invariant code consists of statements or expressions (in an imperative programming language) that can be moved outside the body of a loop without affecting the semantics of the program. Loop-invariant code motion ( ...
at the same time.Effective Partial Redundancy Elimination
Briggs and Cooper, 1994 In addition, PRE can be extended to eliminate ''injured'' partial redundancies, thereby effectively performing
strength reduction In compiler construction, strength reduction is a compiler optimization where expensive operations are replaced with equivalent but less expensive operations. The classic example of strength reduction converts "strong" multiplications inside a loo ...
. This makes PRE one of the most important optimizations in optimizing compilers. Traditionally, PRE is applied to lexically equivalent expressions, but recently formulations of PRE based on
static single assignment form In compiler design, static single assignment form (often abbreviated as SSA form or simply SSA) is a property of an intermediate representation (IR) that requires each variable to be assigned exactly once and defined before it is used. Existing var ...
have been published that apply the PRE algorithm to values instead of expressions, unifying PRE and
global value numbering Value numbering is a technique of determining when two computations in a program are equivalent and eliminating one of them with a semantics-preserving optimization. Global value numbering Global value numbering (GVN) is a compiler optimization bas ...
.


See also

*
Value numbering Value numbering is a technique of determining when two computations in a program are equivalent and eliminating one of them with a semantics-preserving optimization. Global value numbering Global value numbering (GVN) is a compiler optimization bas ...
* Redundant code *
Dead code elimination In compiler theory, dead-code elimination (also known as DCE, dead-code removal, dead-code stripping, or dead-code strip) is a compiler optimization to remove code which does not affect the program results. Removing such code has several benefits: ...


References


Further reading

* Muchnick, Steven S. ''Advanced Compiler Design and Implementation''. Morgan Kaufmann. 1997. * Knoop, J., Ruthing, O., and Steffen, B. ''Lazy Code Motion''. ACM SIGPLAN Notices Vol. 27, Num. 7, Jul. 1992, '92 Conference on PLDI. * Paleri, V. K., Srikant, Y. N., and Shankar, P. ''A Simple Algorithm for Partial Redundancy Elimination''. SIGPLAN Notices, Vol. 33(12). pages 35–43 (1998). * Kennedy, R., Chan, S., Liu, S.M., Lo, R., Peng, T., and Chow, F. ''Partial Redundancy Elimination in SSA Form''. ACM Transactions on Programming Languages Vol. 21, Num. 3, pp. 627–676, 1999. * VanDrunen, T., and Hosking, A.L. ''Value-Based Partial Redundancy Elimination'', Lecture Notes in Computer Science Vol. 2985/2004, pp. 167 – 184, 2004. * Cai, Q. and Xue, J. ''Optimal and Efficient Speculation-Based Partial Redundancy Elimination". International Symposium on Code Generation and Optimization (CGO'03), 91-104, 2003. * Xue, J. and Knoop, J. '' A Fresh Look at PRE as a Maximum Flow Problem''. International Conference on Compiler Construction (CC'06), pages 139—154, Vienna, Austria, 2006. * Xue, J. and Cai Q. '' A lifetime optimal algorithm for speculative PRE''. ACM Transactions on Architecture and Code Optimization Vol. 3, Num. 3, pp. 115–155, 2006. {{Compiler optimizations Articles with example C code Compiler optimizations