vppinfra: use unaligned non-vector load/stores in x86 memcpy 55/34055/2
authorDamjan Marion <damarion@cisco.com>
Tue, 12 Oct 2021 13:34:31 +0000 (15:34 +0200)
committerFlorin Coras <florin.coras@gmail.com>
Tue, 12 Oct 2021 19:48:02 +0000 (19:48 +0000)
Type: fix
Change-Id: I54ef23a52f05cc95210a736f84b927dd69b8a6f7
Signed-off-by: Damjan Marion <damarion@cisco.com>
src/vppinfra/memcpy_avx2.h
src/vppinfra/memcpy_avx512.h
src/vppinfra/memcpy_sse3.h
src/vppinfra/types.h

index f7a36f0..ac29d25 100644 (file)
@@ -135,19 +135,19 @@ clib_memcpy_fast_avx2 (void *dst, const void *src, size_t n)
        }
       if (n & 0x02)
        {
-         *(u16 *) dstu = *(const u16 *) srcu;
-         srcu = (uword) ((const u16 *) srcu + 1);
-         dstu = (uword) ((u16 *) dstu + 1);
+         *(u16u *) dstu = *(const u16u *) srcu;
+         srcu = (uword) ((const u16u *) srcu + 1);
+         dstu = (uword) ((u16u *) dstu + 1);
        }
       if (n & 0x04)
        {
-         *(u32 *) dstu = *(const u32 *) srcu;
-         srcu = (uword) ((const u32 *) srcu + 1);
-         dstu = (uword) ((u32 *) dstu + 1);
+         *(u32u *) dstu = *(const u32u *) srcu;
+         srcu = (uword) ((const u32u *) srcu + 1);
+         dstu = (uword) ((u32u *) dstu + 1);
        }
       if (n & 0x08)
        {
-         *(u64 *) dstu = *(const u64 *) srcu;
+         *(u64u *) dstu = *(const u64u *) srcu;
        }
       return ret;
     }
index 98dac75..2025070 100644 (file)
@@ -165,18 +165,18 @@ clib_memcpy_fast_avx512 (void *dst, const void *src, size_t n)
        }
       if (n & 0x02)
        {
-         *(u16 *) dstu = *(const u16 *) srcu;
-         srcu = (uword) ((const u16 *) srcu + 1);
-         dstu = (uword) ((u16 *) dstu + 1);
+         *(u16u *) dstu = *(const u16u *) srcu;
+         srcu = (uword) ((const u16u *) srcu + 1);
+         dstu = (uword) ((u16u *) dstu + 1);
        }
       if (n & 0x04)
        {
-         *(u32 *) dstu = *(const u32 *) srcu;
-         srcu = (uword) ((const u32 *) srcu + 1);
-         dstu = (uword) ((u32 *) dstu + 1);
+         *(u32u *) dstu = *(const u32u *) srcu;
+         srcu = (uword) ((const u32u *) srcu + 1);
+         dstu = (uword) ((u32u *) dstu + 1);
        }
       if (n & 0x08)
-       *(u64 *) dstu = *(const u64 *) srcu;
+       *(u64u *) dstu = *(const u64u *) srcu;
       return ret;
     }
 
index aea2005..2ad3648 100644 (file)
@@ -210,19 +210,19 @@ clib_memcpy_fast_sse3 (void *dst, const void *src, size_t n)
        }
       if (n & 0x02)
        {
-         *(u16 *) dstu = *(const u16 *) srcu;
-         srcu = (uword) ((const u16 *) srcu + 1);
-         dstu = (uword) ((u16 *) dstu + 1);
+         *(u16u *) dstu = *(const u16u *) srcu;
+         srcu = (uword) ((const u16u *) srcu + 1);
+         dstu = (uword) ((u16u *) dstu + 1);
        }
       if (n & 0x04)
        {
-         *(u32 *) dstu = *(const u32 *) srcu;
-         srcu = (uword) ((const u32 *) srcu + 1);
-         dstu = (uword) ((u32 *) dstu + 1);
+         *(u32u *) dstu = *(const u32u *) srcu;
+         srcu = (uword) ((const u32u *) srcu + 1);
+         dstu = (uword) ((u32u *) dstu + 1);
        }
       if (n & 0x08)
        {
-         *(u64 *) dstu = *(const u64 *) srcu;
+         *(u64u *) dstu = *(const u64u *) srcu;
        }
       return ret;
     }
index c5e7f09..b52d603 100644 (file)
@@ -163,6 +163,13 @@ typedef f64 fword;
        __attribute__ ((aligned (align), packed));      \
     } *) (addr))->_data)
 
+typedef u16 u16u __attribute__ ((aligned (1)));
+typedef u32 u32u __attribute__ ((aligned (1)));
+typedef u64 u64u __attribute__ ((aligned (1)));
+typedef i16 i16u __attribute__ ((aligned (1)));
+typedef i32 i32u __attribute__ ((aligned (1)));
+typedef i64 i64u __attribute__ ((aligned (1)));
+
 #endif /* included_clib_types_h */
 
 /*