Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc: Reduce csum_add() complexity for PPC64

PPC64 does everything in C, gcc is able to skip calculation
when one of the operands in zero.

Move the constant folding in PPC32 part.

This helps GCC and reduces ppc64_defconfig by 170 bytes.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/a4ca63dd4c4b09e1906d08fb814af5a41d0f3fcb.1644651363.git.christophe.leroy@csgroup.eu

authored by

Christophe Leroy and committed by
Michael Ellerman
f206fdd9 a553476c

+4 -5
+4 -5
arch/powerpc/include/asm/checksum.h
··· 95 95 { 96 96 #ifdef __powerpc64__ 97 97 u64 res = (__force u64)csum; 98 - #endif 98 + 99 + res += (__force u64)addend; 100 + return (__force __wsum)((u32)res + (res >> 32)); 101 + #else 99 102 if (__builtin_constant_p(csum) && csum == 0) 100 103 return addend; 101 104 if (__builtin_constant_p(addend) && addend == 0) 102 105 return csum; 103 106 104 - #ifdef __powerpc64__ 105 - res += (__force u64)addend; 106 - return (__force __wsum)((u32)res + (res >> 32)); 107 - #else 108 107 asm("addc %0,%0,%1;" 109 108 "addze %0,%0;" 110 109 : "+r" (csum) : "r" (addend) : "xer");