Beating the compiler at signed 32-bit division
Summary
Daniel Lemire analyzes how compilers implement signed 32-bit division and demonstrates a 33-bit multiplier approach that can beat compiler-generated code on 64-bit systems. The post compares GCC/Clang results on Intel and ARM Apple M4, explains when a correction step is needed, and presents a runtime-divisor fastmod technique for speedups. It includes concrete code, performance measurements, and references to related literature.