[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <d20da175-2102-4ac0-bf91-0ab8f6b6b317@intel.com>
Date: Thu, 27 Feb 2025 08:26:31 -0800
From: Dave Hansen <dave.hansen@...el.com>
To: Bill Wendling <morbo@...gle.com>
Cc: Thomas Gleixner <tglx@...utronix.de>, Ingo Molnar <mingo@...hat.com>,
Borislav Petkov <bp@...en8.de>, Dave Hansen <dave.hansen@...ux.intel.com>,
"maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" <x86@...nel.org>,
"H. Peter Anvin" <hpa@...or.com>, Eric Biggers <ebiggers@...nel.org>,
Ard Biesheuvel <ardb@...nel.org>, Nathan Chancellor <nathan@...nel.org>,
Nick Desaulniers <nick.desaulniers+lkml@...il.com>,
Justin Stitt <justinstitt@...gle.com>, LKML <linux-kernel@...r.kernel.org>,
linux-crypto@...r.kernel.org, clang-built-linux <llvm@...ts.linux.dev>
Subject: Re: [PATCH] x86/crc32: use builtins to improve code generation
On 2/26/25 22:12, Bill Wendling wrote:
> #ifdef CONFIG_X86_64
> -#define CRC32_INST "crc32q %1, %q0"
> +#define CRC32_INST __builtin_ia32_crc32di
> #else
> -#define CRC32_INST "crc32l %1, %0"
> +#define CRC32_INST __builtin_ia32_crc32si
> #endif
>
> /*
> @@ -78,10 +78,10 @@ u32 crc32c_le_arch(u32 crc, const u8 *p, size_t len)
>
> for (num_longs = len / sizeof(unsigned long);
> num_longs != 0; num_longs--, p += sizeof(unsigned long))
> - asm(CRC32_INST : "+r" (crc) : "rm" (*(unsigned long *)p));
> + crc = CRC32_INST(crc, *(unsigned long *)p);
Could we get rid of the macros, please?
unsigned long crc32_ul(unsigned long crc, unsigned long data)
{
if (IS_DEFINED(CONFIG_X86_64))
return __builtin_ia32_crc32di(crc, data)
else
return __builtin_ia32_crc32si(crc, data)
}
I guess it could also do some check like:
if (sizeof(int) == sizeof(long))
instead of CONFIG_X86_64, but the CONFIG_X86_64 will make it more
obvious when someone comes through to rip out 32-bit support some day.
Powered by blists - more mailing lists