Skip to content

Commit

Permalink
powerpc: simplify csum_add(a, b) in case a or b is constant 0
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Christophe Leroy authored and Scott Wood committed Mar 5, 2016
1 parent f867d55 commit 5a8847c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions arch/powerpc/include/asm/checksum.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5a8847c

Please sign in to comment.