IT lexicon › Programming › Demanded-bits analysis

Demanded-bits analysis

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

The backward analysis that works out, for each value, which bits the rest of the program actually reads, so the computation of all the others can be simplified or dropped.

If a result is only ever stored as a byte, its upper 56 bits don't matter, and neither does how they were computed. (x | 0xFF00) & 0xFF becomes x & 0xFF, because the or only touched bits nobody asks about. A multiply whose high half is never used can be narrowed, and a sign extension whose new bits nobody reads can become a plain copy.

It is the mirror image of known bits: that one asks what we know about a value, this one asks what anyone cares about. Formally it's liveness analysis at the level of individual bits. LLVM has it both as a standalone analysis and as SimplifyDemandedBits, which InstCombine and the backend's DAG combiner call constantly.

← Back to the lexicon