[libc-commits] [libc] [libc] Implement wide read strlen with LLVM vector type (PR #152605)

Joseph Huber via libc-commits libc-commits at lists.llvm.org
Thu Aug 7 18:18:16 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));
----------------
jhuber6 wrote:

Didn't work because the fallback is a one-dimensional vector and the builtin emits a warning on that being a no-op.

https://github.com/llvm/llvm-project/pull/152605


More information about the libc-commits mailing list