aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2021-10-12 15:34:31 +0200
committerFlorin Coras <florin.coras@gmail.com>2021-10-12 19:48:02 +0000
commit21b4e337b67c8de9f1b7f59a86f1ec4e5f02372b (patch)
tree6ad45e7135c928942583f4ded29ff4bf06576a69 /src
parente8f57d593ea8bdfdff2e32562a520501b735f012 (diff)
vppinfra: use unaligned non-vector load/stores in x86 memcpy
Type: fix Change-Id: I54ef23a52f05cc95210a736f84b927dd69b8a6f7 Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src')
-rw-r--r--src/vppinfra/memcpy_avx2.h14
-rw-r--r--src/vppinfra/memcpy_avx512.h14
-rw-r--r--src/vppinfra/memcpy_sse3.h14
-rw-r--r--src/vppinfra/types.h7
4 files changed, 28 insertions, 21 deletions
diff --git a/src/vppinfra/memcpy_avx2.h b/src/vppinfra/memcpy_avx2.h
index f7a36f0e5cb..ac29d2590a7 100644
--- a/src/vppinfra/memcpy_avx2.h
+++ b/src/vppinfra/memcpy_avx2.h
@@ -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;
}
diff --git a/src/vppinfra/memcpy_avx512.h b/src/vppinfra/memcpy_avx512.h
index 98dac75beac..2025070272e 100644
--- a/src/vppinfra/memcpy_avx512.h
+++ b/src/vppinfra/memcpy_avx512.h
@@ -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;
}
diff --git a/src/vppinfra/memcpy_sse3.h b/src/vppinfra/memcpy_sse3.h
index aea2005d95a..2ad3648a52a 100644
--- a/src/vppinfra/memcpy_sse3.h
+++ b/src/vppinfra/memcpy_sse3.h
@@ -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;
}
diff --git a/src/vppinfra/types.h b/src/vppinfra/types.h
index c5e7f09ef23..b52d6034ae9 100644
--- a/src/vppinfra/types.h
+++ b/src/vppinfra/types.h
@@ -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 */
/*