When float division beats integer division

9 points by nrposner


bitshift

Very counterintuitive, very fun!

It's interesting they got a speedup on both Intel and AMD. I wonder if there's something fundamental about floating point that makes division easier. Obviously exponents are easier, but the harder part is the mantissa.

My best guess is because floating point allows iterative methods like Newton-Raphson, which Wikipedia calls "Fast division methods". Whereas for integer, you'd have to use SRT division which is "slow"?

You're always doing integer math (pointer arithmetic), so it would seem like that choosing integer math would load the int math part of the cpu, while if you used floats for the actual data you could use more of the silicon to get the job done

I really like this idea: it's a cool fact and I want it to be the explanation—and it probably is the explanation for different benchmarks. But I don't think it explains why an individual IDIVQ instruction has a worse official throughput than DIVSD.

olliej

It’s worth noting that when performing floating point division the dominant cost is the integer division of the significand. I wonder how much of the performance win is “fp math gets more division hardware” (e.g fp division is much more likely to be perf sensitive than integer div), and how much is the reduced width of the division?