IT lexicon › Programming › Lazy code motion

Lazy code motion

Programming På svenska → Updated: 2026-11-07

A take on partial redundancy elimination that places computations as late as possible, so values aren't kept alive for no reason.

Morel and Renvoise's original PRE from 1979 hoisted computations as early as it could. That removed the redundancy but stretched lifetimes, and a temporary sitting in a register through half a function can cost more than the computation it saved. Jens Knoop, Oliver Rüthing and Bernhard Steffen presented lazy code motion at PLDI 1992: first find the earliest safe placement, then push the computation forward for as long as doing so creates no new redundancy.

A less celebrated win was in the machinery. Morel–Renvoise needed a bidirectional data-flow analysis that was notoriously hard to reason about; lazy code motion gets by with four unidirectional bit-vector analyses. GCC's RTL-level PRE still runs on it and keeps it in a file of its own, lcm.cc.

← Back to the lexicon