[libc-commits] [libc] [libc] Implement wide read strlen with LLVM vector type (PR #152605)
Matt Arsenault via libc-commits
libc-commits at lists.llvm.org
Thu Aug 7 18:17:00 PDT 2025
================
@@ -81,6 +85,40 @@ LIBC_INLINE size_t string_length_wide_read(const char *src) {
return static_cast<size_t>(char_ptr - src);
}
+#if LIBC_HAS_VECTOR_TYPE
+LIBC_INLINE size_t string_length_wide_read_vector(const char *src) {
+ using namespace vector;
+
+ const Vector<char> null('\0');
+
+ // Align the pointer to the native vector width and shift out unused byted.
+ const char *aligned = reinterpret_cast<const char *>(
+ reinterpret_cast<uintptr_t>(src) &
+ ~static_cast<uintptr_t>(sizeof(Vector<char>) - 1));
----------------
arsenm wrote:
Use the builtin for pointer alignment
https://github.com/llvm/llvm-project/pull/152605
More information about the libc-commits
mailing list