IT lexicon › Programming › Early clobber

Early clobber

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

The marker saying an output operand is written before all inputs have been read, so the register allocator must not put them in the same register.

By default an allocator assumes an instruction reads everything first and writes last, which makes reusing an input register for the result an easy win. In GCC inline assembly the & modifier, as in "=&r", breaks that assumption. Leave it out and the code works until the optimizer spots a chance to share a register — at which point the block overwrites its own input halfway through.

The same notion lives in backends, for instructions where the hardware demands it. ARM's MUL before ARMv6 could not use the same register as destination and first source, and LLVM models that as an early-clobber flag on the operand. It is one of the few places where a single character in a string steers register allocation.

← Back to the lexicon