[libc-commits] [PATCH] D106551: [libc] optimize bzero/memset for x86

Guillaume Chatelet via Phabricator via libc-commits libc-commits at lists.llvm.org
Fri Jul 23 05:22:06 PDT 2021


This revision was automatically updated to reflect the committed changes.
Closed by commit rG24ffb98f9dbd: [libc] optimize bzero/memset for x86 (authored by gchatelet).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106551/new/

https://reviews.llvm.org/D106551

Files:
  libc/src/string/memory_utils/memset_utils.h


Index: libc/src/string/memory_utils/memset_utils.h
===================================================================
--- libc/src/string/memory_utils/memset_utils.h
+++ libc/src/string/memory_utils/memset_utils.h
@@ -49,28 +49,33 @@
 // superior for sizes that mattered.
 inline static void GeneralPurposeMemset(char *dst, unsigned char value,
                                         size_t count) {
+#if defined(__i386__) || defined(__x86_64__)
+  using namespace ::__llvm_libc::x86;
+#else
+  using namespace ::__llvm_libc::scalar;
+#endif
+
   if (count == 0)
     return;
   if (count == 1)
-    return SplatSet<scalar::_1>(dst, value);
+    return SplatSet<_1>(dst, value);
   if (count == 2)
-    return SplatSet<scalar::_2>(dst, value);
+    return SplatSet<_2>(dst, value);
   if (count == 3)
-    return SplatSet<scalar::_3>(dst, value);
+    return SplatSet<_3>(dst, value);
   if (count == 4)
-    return SplatSet<scalar::_4>(dst, value);
+    return SplatSet<_4>(dst, value);
   if (count <= 8)
-    return SplatSet<HeadTail<scalar::_4>>(dst, value, count);
+    return SplatSet<HeadTail<_4>>(dst, value, count);
   if (count <= 16)
-    return SplatSet<HeadTail<scalar::_8>>(dst, value, count);
+    return SplatSet<HeadTail<_8>>(dst, value, count);
   if (count <= 32)
-    return SplatSet<HeadTail<scalar::_16>>(dst, value, count);
+    return SplatSet<HeadTail<_16>>(dst, value, count);
   if (count <= 64)
-    return SplatSet<HeadTail<scalar::_32>>(dst, value, count);
+    return SplatSet<HeadTail<_32>>(dst, value, count);
   if (count <= 128)
-    return SplatSet<HeadTail<scalar::_64>>(dst, value, count);
-  return SplatSet<Align<scalar::_32, Arg::Dst>::Then<Loop<scalar::_32>>>(
-      dst, value, count);
+    return SplatSet<HeadTail<_64>>(dst, value, count);
+  return SplatSet<Align<_32, Arg::Dst>::Then<Loop<_32>>>(dst, value, count);
 }
 
 } // namespace __llvm_libc


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D106551.361163.patch
Type: text/x-patch
Size: 1900 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20210723/908aac92/attachment.bin>


More information about the libc-commits mailing list