libcpp: Implement AArch64 SVE2 search_line_fast
Replaces Neon-based string searching with SVE2 for improved performance on AArch64.
This commit introduces an AArch64 SVE2-accelerated function for finding the next newline, carriage return, backslash, or question mark character. The new implementation leverages SVE2’s vector-length agnostic capabilities to perform the search in fewer instructions, offering better scalability on wider processor implementations compared to the previous Neon-based approach. The function is compiled with a +sve2 target attribute and selected at startup via getauxval, ensuring it’s used when available.
In Details
The libcpp search_line_fast helper, previously optimized with NEON, is refactored to use AArch64 SVE2 intrinsics. The new implementation utilizes SVE2's match instruction for set membership testing and brkb/incp for pointer updates. This avoids per-iteration loop overhead and reduces instruction count by performing the search in a vector-length agnostic manner, suitable for wider SVE2 implementations. Runtime selection via getauxval handles availability.
- SVE2
- Scalable Vector Extension 2 is an ARM architecture feature that provides advanced SIMD and vector processing capabilities. It allows instructions to operate on vectors whose length is determined at runtime, enabling code to adapt to different processor implementations.
- NEON
- NEON is ARM's advanced SIMD (Single Instruction, Multiple Data) instruction set. It provides a way to perform the same operation on multiple data points simultaneously, accelerating multimedia and signal processing tasks.
- libcpp
- The C++ standard library implementation used by Clang. It includes components like the preprocessor (cpp) which handles text manipulation and character set conversions.
- getauxval
- A Linux function that retrieves values from the auxiliary vector, which contains information passed from the kernel to a user-space process. It can be used to dynamically select optimized code paths at runtime.