Skip to content

Commit cf1ea3a

Browse files
committed
x86/crc32: improve crc32c_arch() code generation with clang
crc32c_arch() is affected by llvm/llvm-project#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. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Eric Biggers <[email protected]>
1 parent 4ffd508 commit cf1ea3a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

arch/x86/lib/crc32-glue.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ u32 crc32c_arch(u32 crc, const u8 *p, size_t len)
5555

5656
for (num_longs = len / sizeof(unsigned long);
5757
num_longs != 0; num_longs--, p += sizeof(unsigned long))
58-
asm(CRC32_INST : "+r" (crc) : "rm" (*(unsigned long *)p));
58+
asm(CRC32_INST : "+r" (crc) : ASM_INPUT_RM (*(unsigned long *)p));
5959

6060
for (len %= sizeof(unsigned long); len; len--, p++)
61-
asm("crc32b %1, %0" : "+r" (crc) : "rm" (*p));
61+
asm("crc32b %1, %0" : "+r" (crc) : ASM_INPUT_RM (*p));
6262

6363
return crc;
6464
}

0 commit comments

Comments
 (0)