[v2,2/2] powerpc32: add support for csum_add()

Segher Boessenkool segher at kernel.crashing.org
Tue May 5 08:10:55 AEST 2015


On Fri, May 01, 2015 at 08:00:14PM -0500, Scott Wood wrote:
> On Tue, 2015-04-28 at 21:01 +0200, christophe leroy wrote:
> > The generated code is most likely different on ppc64. I have no ppc64
> > compiler

For reference: yes you do.  Just add -m64.

> Ideal (short of a 64-bit __wsum) would probably be something like (untested):
> 
> 	add	r3,r3,r4
> 	srdi	r5,r3,32
> 	add	r3,r3,r5
> 	clrldi	r3,r3,32
> 
> Or in C code (which would let the compiler schedule it better):
> 
> static inline __wsum csum_add(__wsum csum, __wsum addend)
> {
>         u64 res = (__force u64)csum;
>         res += (__force u32)addend;
>         return (__force __wsum)((u32)res + (res >> 32));
> }

Older GCC make exactly your asm code for that, in 64-bit; newer GCC get
two adds (one as 32-bit, one as 64-bit, it does not see those are the
same, grrr); and GCC 5 makes the perfect  addc 3,4,3 ; addze 3,3  for
this in 32-bit mode.  You don't want to see what older GCC does with
32-bit though :-/


Segher


More information about the Linuxppc-dev mailing list