23 days ago
- Modern compilers, particularly Clang, optimize loops using branch-free instructions when using certain programming styles.
- A Quicksort implementation with sorting networks and loop unrolling was initially slower than C++ std::sort.
- Rewriting a beginner-friendly if-statement into a compact C idiom (using post-increment operators) significantly improved performance.
- The 'cosmetic' change triggered Clang to replace branches with csel (conditional select) instructions, making the code branchless.