Bit Twiddling, Duff's Device ... Extreme Code Optimizations
summary
Shows how low-level bit-manipulation techniques (bit twiddling) and clever loop-unrolling constructs like Duff's Device (Tom Duff, 1983) can implement certain operations without branches or loops. Explains the binary operations involved, gives examples of these extreme optimizations, and argues when and why they can still be useful with modern languages and runtimes.
AI-written summary · about
chapters (11)
- 0:00Extreme optimizations intro
- 6:37Compiler Explorer overview
- 7:40Bit twiddling basics
- 11:31Round to power of two
- 15:05Absolute value no branches
- 19:38Sign extend 24-bit words
- 25:35Bit parity calculation
- 30:08Zero-byte detection SWAR
- 33:14Reverse bit order
- 35:20Duff's Device explained
- 45:10Summary and conclusion
