Partial-redundancy elimination

In compiler theory, partial redundancy elimination (PRE) is a compiler optimization that eliminates expressions that are redundant on some but not necessarily all paths through a program.

PRE is a form of common subexpression elimination.

For instance, in the following code: 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 on the expression to yield the following optimized code: An interesting property of PRE is that it performs (a form of) common subexpression elimination and loop-invariant code motion at the same time.

[1][2] In addition, PRE can be extended to eliminate injured partial redundancies, thereby effectively performing strength reduction.