Auto-vectorizing operations on buffers of unknown length
7 days ago
- #GCC
- #optimization
- #auto-vectorization
- GCC isn’t capable of auto-vectorizing simple search operations like strlen() when the buffer length isn’t explicitly specified.
- GCC 15.1 introduces improved auto-vectorization for loops with known lengths, enabling vectorization of operations like finding a character in a buffer.
- A trick to auto-vectorize strlen() involves passing SIZE_MAX as the length, making the loop condition redundant in practice.
- Benchmarks show a 10x-15x speed-up for operations similar to strlen() when auto-vectorized.
- A new GCC patch set aims to auto-vectorize loops without known lengths, making the 'fake length' trick unnecessary.
- Clang currently cannot auto-vectorize the functions discussed, unlike GCC.