[v2] hash: provide crc32 functions based on intrinsics
Checks
Commit Message
MSVC does not support inline asm so replace crc32 inline function
implementations with intrinsics compatible with all toolchains.
Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
lib/hash/rte_crc_x86.h | 38 +++++++++++++-------------------------
1 file changed, 13 insertions(+), 25 deletions(-)
Comments
On Tue, 21 May 2024 17:02:14 -0700
Tyler Retzlaff <roretzla@linux.microsoft.com> wrote:
> MSVC does not support inline asm so replace crc32 inline function
> implementations with intrinsics compatible with all toolchains.
>
> Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
> ---
always good to remove asm since in tends not to get optimized.
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
> From: Stephen Hemminger [mailto:stephen@networkplumber.org]
> Sent: Wednesday, 22 May 2024 04.21
>
> On Tue, 21 May 2024 17:02:14 -0700
> Tyler Retzlaff <roretzla@linux.microsoft.com> wrote:
>
> > MSVC does not support inline asm so replace crc32 inline function
> > implementations with intrinsics compatible with all toolchains.
> >
> > Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
> > ---
>
> always good to remove asm since in tends not to get optimized.
>
> Acked-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Morten Brørup <mb@smartsharesystems.com>
22/05/2024 10:36, Morten Brørup:
> > From: Stephen Hemminger [mailto:stephen@networkplumber.org]
> > Sent: Wednesday, 22 May 2024 04.21
> >
> > On Tue, 21 May 2024 17:02:14 -0700
> > Tyler Retzlaff <roretzla@linux.microsoft.com> wrote:
> >
> > > MSVC does not support inline asm so replace crc32 inline function
> > > implementations with intrinsics compatible with all toolchains.
> > >
> > > Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
> >
> > always good to remove asm since in tends not to get optimized.
> >
> > Acked-by: Stephen Hemminger <stephen@networkplumber.org>
>
> Acked-by: Morten Brørup <mb@smartsharesystems.com>
Applied, thanks.
@@ -5,35 +5,33 @@
#ifndef _RTE_CRC_X86_H_
#define _RTE_CRC_X86_H_
+#include <rte_vect.h>
+
static inline uint32_t
crc32c_sse42_u8(uint8_t data, uint32_t init_val)
{
- __asm__ volatile(
- "crc32b %[data], %[init_val];"
- : [init_val] "+r" (init_val)
- : [data] "rm" (data));
- return init_val;
+ return _mm_crc32_u8(init_val, data);
}
static inline uint32_t
crc32c_sse42_u16(uint16_t data, uint32_t init_val)
{
- __asm__ volatile(
- "crc32w %[data], %[init_val];"
- : [init_val] "+r" (init_val)
- : [data] "rm" (data));
- return init_val;
+ return _mm_crc32_u16(init_val, data);
}
static inline uint32_t
crc32c_sse42_u32(uint32_t data, uint32_t init_val)
{
- __asm__ volatile(
- "crc32l %[data], %[init_val];"
- : [init_val] "+r" (init_val)
- : [data] "rm" (data));
- return init_val;
+ return _mm_crc32_u32(init_val, data);
+}
+
+#ifdef RTE_ARCH_X86_64
+static inline uint32_t
+crc32c_sse42_u64(uint64_t data, uint64_t init_val)
+{
+ return _mm_crc32_u64(init_val, data);
}
+#endif
static inline uint32_t
crc32c_sse42_u64_mimic(uint64_t data, uint64_t init_val)
@@ -49,16 +47,6 @@
return (uint32_t)init_val;
}
-static inline uint32_t
-crc32c_sse42_u64(uint64_t data, uint64_t init_val)
-{
- __asm__ volatile(
- "crc32q %[data], %[init_val];"
- : [init_val] "+r" (init_val)
- : [data] "rm" (data));
- return (uint32_t)init_val;
-}
-
/*
* Use single crc32 instruction to perform a hash on a byte value.
* Fall back to software crc32 implementation in case SSE4.2 is