vppinfra: small optimization in clib_memset_u64 56/35156/2
authorDamjan Marion <damarion@cisco.com>
Mon, 31 Jan 2022 16:42:44 +0000 (17:42 +0100)
committerFlorin Coras <florin.coras@gmail.com>
Thu, 10 Feb 2022 16:31:41 +0000 (16:31 +0000)
Type: improvement
Change-Id: I4b89c32c224caf8a3a4ac94b26ecefffd26c7038
Signed-off-by: Damjan Marion <damarion@cisco.com>
src/vppinfra/string.h

index 8c5bea1..0b18767 100644 (file)
@@ -320,9 +320,17 @@ clib_memset_u64 (void *p, u64 val, uword count)
   if (count == 0)
     return;
 #else
+#if defined(CLIB_HAVE_VEC128)
+  u64x2 v = u64x2_splat (val);
+#endif
   while (count >= 4)
     {
+#if defined(CLIB_HAVE_VEC128)
+      u64x2_store_unaligned (v, ptr);
+      u64x2_store_unaligned (v, ptr + 2);
+#else
       ptr[0] = ptr[1] = ptr[2] = ptr[3] = val;
+#endif
       ptr += 4;
       count -= 4;
     }