aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/include/asm/checksum.h
diff options
context:
space:
mode:
authorChristophe Leroy <christophe.leroy@csgroup.eu>2022-02-12 08:36:17 +0100
committerMichael Ellerman <mpe@ellerman.id.au>2022-05-06 00:00:20 +1000
commitf206fdd9d41bf7deb96219b8ca3499a5abd79b83 (patch)
treec1ac749778f42033eb99894a1fb3c7803e6b69cb /arch/powerpc/include/asm/checksum.h
parentpowerpc/64: remove system call instruction emulation (diff)
downloadlinux-dev-f206fdd9d41bf7deb96219b8ca3499a5abd79b83.tar.xz
linux-dev-f206fdd9d41bf7deb96219b8ca3499a5abd79b83.zip
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
Diffstat (limited to '')
-rw-r--r--arch/powerpc/include/asm/checksum.h9
1 files changed, 4 insertions, 5 deletions
diff --git a/arch/powerpc/include/asm/checksum.h b/arch/powerpc/include/asm/checksum.h
index ab3832b93f0a..8321f6053a67 100644
--- a/arch/powerpc/include/asm/checksum.h
+++ b/arch/powerpc/include/asm/checksum.h
@@ -95,16 +95,15 @@ static __always_inline __wsum csum_add(__wsum csum, __wsum addend)
{
#ifdef __powerpc64__
u64 res = (__force u64)csum;
-#endif
+
+ res += (__force u64)addend;
+ return (__force __wsum)((u32)res + (res >> 32));
+#else
if (__builtin_constant_p(csum) && csum == 0)
return addend;
if (__builtin_constant_p(addend) && addend == 0)
return csum;
-#ifdef __powerpc64__
- res += (__force u64)addend;
- return (__force __wsum)((u32)res + (res >> 32));
-#else
asm("addc %0,%0,%1;"
"addze %0,%0;"
: "+r" (csum) : "r" (addend) : "xer");