A method for analyzing and optimizing programs that operate on a data
structure where the state of the data structure must be valid at certain
program points. The program is represented as a control-flow graph. The
method decomposes the state of the data structure into components, and
applies partial redundancy elimination to place instructions that set the
state of the data structure, with a variation that permits speculative
placement. Application extends to manipulating a stack that keeps track
of what to do should an exception arise during execution. In this
context, a control-flow representation of contingencies is converted into
placement of instructions that manipulate the stack.