IT lexicon › Programming › Strength reduction

Strength reduction

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

An expensive operation is replaced with a cheaper one that gives the same answer, typically a multiplication inside a loop with a running addition.

The classic case is address arithmetic. A loop reading a[i] formally computes base + i * 8 on every iteration, but since i goes up by one each time, adding eight to a pointer is enough. The compiler finds these induction variables and rewrites them, and often the counter i itself can then be deleted. John Cocke and Ken Kennedy published an algorithm for it in 1977.

The simpler local form, turning x * 8 into a shift and unsigned x / 2 likewise, is often left to the peephole optimizer. The payoff has shrunk as multipliers got faster, but an addition is still cheaper and easier to schedule.

← Back to the lexicon