LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Segher Boessenkool <segher@kernel.crashing.org>
To: Scott Wood <scottwood@freescale.com>
Cc: christophe leroy <christophe.leroy@c-s.fr>,
	Paul Mackerras <paulus@samba.org>,
	linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org
Subject: Re: [v2,2/2] powerpc32: add support for csum_add()
Date: Mon, 4 May 2015 17:10:55 -0500	[thread overview]
Message-ID: <20150504221055.GA17056@gate.crashing.org> (raw)
In-Reply-To: <1430528414.16357.201.camel@freescale.com>

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

  reply	other threads:[~2015-05-04 22:12 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-03 11:39 [PATCH v2 2/2] " Christophe Leroy
2015-03-25  1:30 ` [v2,2/2] " Scott Wood
     [not found]   ` <553FD904.8000309@c-s.fr>
2015-05-02  1:00     ` Scott Wood
2015-05-04 22:10       ` Segher Boessenkool [this message]
2015-05-19 11:37         ` leroy christophe
2015-03-31  3:14 ` Scott Wood

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150504221055.GA17056@gate.crashing.org \
    --to=segher@kernel.crashing.org \
    --cc=christophe.leroy@c-s.fr \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=paulus@samba.org \
    --cc=scottwood@freescale.com \
    --subject='Re: [v2,2/2] powerpc32: add support for csum_add()' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).