Subnormal floating-point numbers are expensive… on Intel processors

We represent floating-point numbers using the IEEE standard. For very small numbers, the standard uses special subnormal numbers. Unfortunately, they have a reputation of making operations slow. Thus video game programmers and machine learning specialists sometimes avoid computing with subnormal numbers for performance.

How slow are they? Let me measure. I wrote a small C++ benchmark with a few kernels over arrays of 16384 values (small enough to fit in cache):

  • multiply each value by 0.75,
  • add two arrays,
  • divide each value by 3,
  • multiply normal values by a tiny constant (2^-1030) so that the inputs are normal but the outputs are subnormal,
  • a dependent chain x *= 0.9999 repeated 16384 times.