Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752067AbbEDWMm (ORCPT ); Mon, 4 May 2015 18:12:42 -0400 Received: from gate.crashing.org ([63.228.1.57]:36845 "EHLO gate.crashing.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751908AbbEDWLy (ORCPT ); Mon, 4 May 2015 18:11:54 -0400 Date: Mon, 4 May 2015 17:10:55 -0500 From: Segher Boessenkool To: Scott Wood Cc: christophe leroy , Paul Mackerras , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: Re: [v2,2/2] powerpc32: add support for csum_add() Message-ID: <20150504221055.GA17056@gate.crashing.org> References: <20150203113927.8604D1A5F14@localhost.localdomain> <20150325013023.GA7588@home.buserror.net> <553FD904.8000309@c-s.fr> <1430528414.16357.201.camel@freescale.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1430528414.16357.201.camel@freescale.com> User-Agent: Mutt/1.4.2.3i Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1234 Lines: 36 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/