← Back to the chapter · Previous detail · Next detail →
Technical detail · Software Optimization Techniques
Code density and instruction-level parallelism
18.14 Code Density and Instruction-Level Parallelism
Code density and execution width are not the same optimisation. Figure 6 compares compressed encodings, complex instruction set (CISC) decoding, and very-long-instruction-word (VLIW) bundles against one signed-update-slot constraint.
In Figure 6, Compressed 16-bit encodings reduce flash traffic but may need extra instructions when registers or immediates do not fit. VLIW bundles expose parallel slots to the compiler, yet unused slots become encoded NOPs; the Measure the whole image card therefore requires text size, cycles, stalls, energy, and worst-case execution time (WCET) together.
Code occupies silicon and consumes energy every time it is fetched. One historical same-process comparison put a 128 Mbit (16 MB) flash array at 27.3 mm and a Cortex-M3 core at 0.43 mm in a 0.13 m technology. The ratio is about
That is not a modern die-area prediction; it is a scale lesson. A memory large enough to hold software can dwarf a small processor core, so instruction density can affect area, fetch bandwidth, leakage, and update time.
Compressed instruction sets commonly provide short 16-bit encodings alongside wider 32-bit encodings. Short forms save bytes but have fewer encoding bits, so they may expose only a subset of registers, smaller immediate ranges, fewer addressing modes, or an explicit mode/history constraint on older designs. The assembler expands to a wider form when operands do not fit. The source line stays the same while its byte cost changes; use the disassembly and section map to see what was selected.
Complex instruction sets take another route: encode more work per instruction. This can improve density, but decoding and execution hardware become more complex, and a rarely used instruction contributes nothing if the compiler cannot recognize or safely generate it. Very-long-instruction-word (VLIW) machines expose parallel functional-unit slots directly to the compiler. A bundle might contain an add, multiply, load, and branch slot; when independent work cannot fill a slot, the encoding carries a no-operation. VLIW therefore exchanges dynamic scheduling hardware for compiler scheduling and can waste code space when parallelism is sparse.
The practical rule is to separate three quantities: source statements, executed operations, and fetched instruction bytes. None is a reliable proxy for the other two.