Partial-redundancy elimination (original) (raw)

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: if (some_condition) { // some code that does not alter x y = x + 4; } else { // other code that does not alter x } z = x + 4; if (some_condition) { // some code that does not alter x t = x + 4; y = t; } else { // other code that does not alter x t = x + 4; } z = t;