Register deprivation: spills and runtime under forced register scarcity
2 days ago
- Reserving registers via gcc -ffixed-<reg> reliably increases spills, but static spill count is a weak predictor of runtime cost (Pearson r=0.55).
- Removing registers slows 8 of 9 kernels by 14–76% at the tightest budget; SipHash shows no slowdown despite 23 added spills.
- The slowdown is specific to the register file used: e.g., reserving GP registers on SHA-256 costs +33%, while reserving XMM costs only +5.6%.
- GCC auto-vectorizes part of SHA-256 with SSE, causing XMM reservation to increase stack spills 8-fold.
- Per-kernel cost per added spill varies ~30x, from about 0%/spill (SipHash) to 2.2%/spill (FIR filter).
- Out-of-order execution hides spill latency, making spills cheap; historical x86-32 would have had higher and more uniform cost.
- The experiment used gcc 15.2.0 -O2 on an Intel Xeon E-2236; code is available on GitHub.