Signed Integers: Faster and Corrector
summary
Claim: using signed integers lets the optimizer generate simpler, faster code by relying on signed overflow undefined behavior. Evidence: GCC blog examples and live Compiler Explorer comparisons showing smaller assembly for add, multiply/divide patterns. Surprise: a mul then div sequence reduces to a cheap operation (example: 14 divided by 7 yields 2 in the optimized case). Caveats: depends on undefined behavior, const/contract assumptions, and careful reasoning about correctness.
AI-written summary · about
chapters (3)
related talks
01h 01mTo Int or to Uint, This is the Question
55mClean Integral Code
52mAdvanced SIMD Algorithms in Pictures
48m[a bit noisy] Optimizing Generic Algorithms
38mEngineering Software Integral Types
42mFaster programs with your compilers autovectorization feature
07mType punning done right
37mAssociative Iteration - Shaping Ancient Mathematical Knowledge Into Powerful Bit-fiddling Techniques
