Faster programs with your compilers autovectorization feature
summary
Explains how compilers emit SIMD instructions, shows Clang/GCC/MSVC vectorization-report flags and why cost model indicates not beneficial appears, and demonstrates concrete fixes: give the compiler -O3 plus proper -march flags, convert arrays-of-structures to structure-of-arrays, apply loop interchange/peeling/unswitching or loop-distribution to turn random/strided accesses and iterator-dependent conditionals into sequential or constant accesses, use temporaries to remove loop-carried deps, and use pragmas or -ffast-math when acceptable; several examples (matrix multiply, image column sums, histogram) show multi× speedups after these minimal changes.
AI-written summary · about
chapters (16)
- 0:00Compiler autovectorization intro
- 1:33How vectorization speeds up
- 3:19Compiler flags for vectorization
- 5:08Inhibitors of compiler vectorization
- 6:10Memory access patterns
- 10:31Loop interchange fix
- 16:12Vectorization with classes
- 19:44Loop invariant conditions
- 23:17Iterator-dependent loops
- 25:21Simplify loop body
- 27:07Low trip count loops
- 29:36Loop carry dependencies
- 35:18Compiler idiosyncrasies
- 38:06Floating-point precision
- 39:27Manual vectorization
- 40:13Q&A
related talks
01h 05mThe Most Important Optimizations to Apply in Your C++ Programs
52mAdvanced SIMD Algorithms in Pictures
01h 06mUtilize your CPU power
01h 00mIntroduction to Hardware Efficiency in Cpp
01h 01mWant fast C++? Know your hardware!
01h 08mAn implementer's view of Boost.SIMD
11mChoosing the correct vectorization method
01h 03mUnlocking the value of C++20
