From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753011AbbCYBXL (ORCPT ); Tue, 24 Mar 2015 21:23:11 -0400 Received: from mail-bn1bon0138.outbound.protection.outlook.com ([157.56.111.138]:23136 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752362AbbCYBXH (ORCPT ); Tue, 24 Mar 2015 21:23:07 -0400 Date: Tue, 24 Mar 2015 20:22:48 -0500 From: Scott Wood To: LEROY Christophe CC: Benjamin Herrenschmidt , Paul Mackerras , , Subject: Re: powerpc32: rearrange instructions order in ip_fast_csum() Message-ID: <20150325012248.GA7270@home.buserror.net> References: <20150203113927.B909E1A5F15@localhost.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20150203113927.B909E1A5F15@localhost.localdomain> User-Agent: Mutt/1.5.23 (2014-03-12) X-Originating-IP: [2601:2:5800:3f7:12bf:48ff:fe84:c9a0] X-ClientProxiedBy: BN3PR11CA0022.namprd11.prod.outlook.com (25.162.169.32) To BY1PR03MB1482.namprd03.prod.outlook.com (25.162.210.140) Authentication-Results: c-s.fr; dkim=none (message not signed) header.d=none; X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY1PR03MB1482;UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY1PR03MB1465; X-Forefront-Antispam-Report: BMV:1;SFV:NSPM;SFS:(10019020)(6009001)(51704005)(24454002)(77156002)(2950100001)(62966003)(87976001)(86362001)(53416004)(40100003)(54356999)(76176999)(50986999)(46406003)(19580405001)(42186005)(110136001)(122386002)(33656002)(92566002)(23726002)(97756001)(83506001)(50466002)(46102003)(3826002);DIR:OUT;SFP:1102;SCL:1;SRVR:BY1PR03MB1482;H:home.buserror.net;FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(5002010)(5005006);SRVR:BY1PR03MB1482;BCL:0;PCL:0;RULEID:;SRVR:BY1PR03MB1482; X-Forefront-PRVS: 052670E5A4 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Mar 2015 01:23:02.8162 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR03MB1482 X-OriginatorOrg: freescale.com Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 03, 2015 at 12:39:27PM +0100, LEROY Christophe wrote: > On PPC_8xx, lwz has a 2 cycles latency, and branching also takes 2 cycles. > As the size of the header is minimum 5 words, we can unroll the loop for the > first words to reduce number of branching, and we can re-order the instructions > to limit loading latency. Please wrap commit messages at around 70 characters. > Signed-off-by: Christophe Leroy > --- > arch/powerpc/lib/checksum_32.S | 10 +++++++--- > 1 file changed, 7 insertions(+), 3 deletions(-) > > diff --git a/arch/powerpc/lib/checksum_32.S b/arch/powerpc/lib/checksum_32.S > index 6d67e05..5500704 100644 > --- a/arch/powerpc/lib/checksum_32.S > +++ b/arch/powerpc/lib/checksum_32.S > @@ -26,13 +26,17 @@ > _GLOBAL(ip_fast_csum) > lwz r0,0(r3) > lwzu r5,4(r3) > - addic. r4,r4,-2 > + addic. r4,r4,-4 > addc r0,r0,r5 > mtctr r4 > blelr- > -1: lwzu r4,4(r3) > - adde r0,r0,r4 > + lwzu r5,4(r3) > + lwzu r4,4(r3) The blelr is pointless since len is guaranteed to be >= 5 (assuming that comment is accurate), but now it's both pointless and in the wrong place, since you haven't yet finished the four words that you subtracted from r4. How about keeping the blelr, without the -, moving it after the initial words, and changing the number of inital words to 5? Also maybe do all the loads up front, since many PPC chips have a three cycle load latency rather than two. -Scott