* [PATCH] x86/crc32: improve crc32c_arch() code generation with clang
@ 2025-02-10 21:07 Eric Biggers
2025-02-12 20:10 ` Eric Biggers
0 siblings, 1 reply; 2+ messages in thread
From: Eric Biggers @ 2025-02-10 21:07 UTC (permalink / raw)
To: linux-kernel; +Cc: linux-crypto, Ard Biesheuvel, x86
From: Eric Biggers <ebiggers@google.com>
crc32c_arch() is affected by
https://github.com/llvm/llvm-project/issues/20571 where clang
unnecessarily spills the inputs to "rm"-constrained operands to the
stack. Replace "rm" with ASM_INPUT_RM which partially works around this
by expanding to "r" when the compiler is clang. This results in better
code generation with clang, though still not optimal.
Signed-off-by: Eric Biggers <ebiggers@google.com>
---
This applies to
https://git.kernel.org/pub/scm/linux/kernel/git/ebiggers/linux.git/log/?h=crc-next
arch/x86/lib/crc32-glue.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/x86/lib/crc32-glue.c b/arch/x86/lib/crc32-glue.c
index 9c3f9c1b7bb9..4b4721176799 100644
--- a/arch/x86/lib/crc32-glue.c
+++ b/arch/x86/lib/crc32-glue.c
@@ -53,14 +53,14 @@ u32 crc32c_arch(u32 crc, const u8 *p, size_t len)
return crc;
}
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));
+ asm(CRC32_INST : "+r" (crc) : ASM_INPUT_RM (*(unsigned long *)p));
for (len %= sizeof(unsigned long); len; len--, p++)
- asm("crc32b %1, %0" : "+r" (crc) : "rm" (*p));
+ asm("crc32b %1, %0" : "+r" (crc) : ASM_INPUT_RM (*p));
return crc;
}
EXPORT_SYMBOL(crc32c_arch);
base-commit: 4ffd50862d41e5aaf2e749efa354afaa1317c309
--
2.48.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] x86/crc32: improve crc32c_arch() code generation with clang
2025-02-10 21:07 [PATCH] x86/crc32: improve crc32c_arch() code generation with clang Eric Biggers
@ 2025-02-12 20:10 ` Eric Biggers
0 siblings, 0 replies; 2+ messages in thread
From: Eric Biggers @ 2025-02-12 20:10 UTC (permalink / raw)
To: linux-kernel; +Cc: linux-crypto, Ard Biesheuvel, x86
On Mon, Feb 10, 2025 at 01:07:41PM -0800, Eric Biggers wrote:
> From: Eric Biggers <ebiggers@google.com>
>
> crc32c_arch() is affected by
> https://github.com/llvm/llvm-project/issues/20571 where clang
> unnecessarily spills the inputs to "rm"-constrained operands to the
> stack. Replace "rm" with ASM_INPUT_RM which partially works around this
> by expanding to "r" when the compiler is clang. This results in better
> code generation with clang, though still not optimal.
>
> Signed-off-by: Eric Biggers <ebiggers@google.com>
> ---
>
> This applies to
> https://git.kernel.org/pub/scm/linux/kernel/git/ebiggers/linux.git/log/?h=crc-next
Applied to crc-next.
- Eric
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-02-12 20:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-10 21:07 [PATCH] x86/crc32: improve crc32c_arch() code generation with clang Eric Biggers
2025-02-12 20:10 ` Eric Biggers
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).