powerpc: simplify csum_add(a, b) in case a or b is constant 0
authorChristophe Leroy <christophe.leroy@c-s.fr>
Tue, 22 Sep 2015 14:34:34 +0000 (16:34 +0200)
committerScott Wood <oss@buserror.net>
Sat, 5 Mar 2016 05:04:00 +0000 (23:04 -0600)
Simplify csum_add(a, b) in case a or b is constant 0

Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
Signed-off-by: Scott Wood <oss@buserror.net>
arch/powerpc/include/asm/checksum.h

index 1778f75..74cd8d8 100644 (file)
@@ -119,7 +119,13 @@ static inline __wsum csum_add(__wsum csum, __wsum addend)
 {
 #ifdef __powerpc64__
        u64 res = (__force u64)csum;
+#endif
+       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