Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3658667imm; Mon, 4 Jun 2018 07:18:12 -0700 (PDT) X-Google-Smtp-Source: ADUXVKL5U9UU5gB4DUTuXW1mxngupGOhGzo5WbEJnzZ5QjmsWudwQHMRPqujUXJE18ld5EN8KYGw X-Received: by 2002:a17:902:6b04:: with SMTP id o4-v6mr22124495plk.101.1528121891975; Mon, 04 Jun 2018 07:18:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528121891; cv=none; d=google.com; s=arc-20160816; b=zs/0DiXUKWZYHQFz8IeebBanCfmPG4dpfj+PNot8v1aqF0Lemb5l+sB/XrEQKdY3fL rVPvq5B7xxVPnPltxFvCvgyZpZ2xCAKTZP/0J5mTpBNWJHcutMNh7EpoPvLCzG4ZmKt5 wm996qySI1Zw3fGlcuIG9BWZ4r2oEqQ3kH4NbzJkGv1nWRFwUKKUE3TUDVwPep9NTVqh DjV7jQjx7ORPDCx+CIyb72MUpVkQyLQizy61jtv1pH1wyDiHP/llWee8tNZ9G9e4WzC/ unaKPzM8gjtrjWzBrR/wl4OE4/fLZZ8jJw7NeMjqgdt+Jb/k6HGF2Vkn14vxiCQgOafX atfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:message-id:subject:cc:from:to :in-reply-to:arc-authentication-results; bh=mamqPHY+hHRWb9ZhXMHTU6UO1UEPPmqVuFHdZMSFJpc=; b=ynf7LgUq1x6vP0OR0RKaydDtiF2V4ZcFXjPK6+KojeK+n7YFVK69hK9NqP8Lp4oE/5 5FZyIeR/zz7ORtwx3kMWx0UtPwNZaHnaPaaR5zyTK2QYFBhVACKtN0wQmJ4ZryUmGfI6 K5JxUFTZOM63AVSVERvMIzuPHmwB8VkxvBG/LlTlzJZpwpG5kCVniL/5v9TZ/6jt+UWp thIgKpqnQkiDE1tUawEvwTZ89LlaGmZwQ+Wq9nmp/Jut8PNhF63BmOVjwpxmlogfG6VD LBhoFzLWgUNlQCyXQYMcsQ7lZTuuMZEG5QVxq/WmAzXovMh3Sdog88ScAGvJF4zoNznZ UhaQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 68-v6si20502030pga.324.2018.06.04.07.17.57; Mon, 04 Jun 2018 07:18:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753550AbeFDOKi (ORCPT + 99 others); Mon, 4 Jun 2018 10:10:38 -0400 Received: from ozlabs.org ([203.11.71.1]:38629 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753443AbeFDOKe (ORCPT ); Mon, 4 Jun 2018 10:10:34 -0400 Received: by ozlabs.org (Postfix, from userid 1034) id 40zxfc4bqmz9s2t; Tue, 5 Jun 2018 00:10:32 +1000 (AEST) X-powerpc-patch-notification: thanks X-powerpc-patch-commit: 55a0edf083022e402042255a0afb03d0b3a63a9b In-Reply-To: <20180410063435.272F8653BC@po15720vm.idsi0.si.c-s.fr> To: Christophe Leroy , Benjamin Herrenschmidt , Paul Mackerras , Scott Wood From: Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: Re: powerpc/64: optimises from64to32() Message-Id: <40zxfc4bqmz9s2t@ozlabs.org> Date: Tue, 5 Jun 2018 00:10:32 +1000 (AEST) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2018-04-10 at 06:34:35 UTC, Christophe Leroy wrote: > The current implementation of from64to32() gives a poor result: > > 0000000000000270 <.from64to32>: > 270: 38 00 ff ff li r0,-1 > 274: 78 69 00 22 rldicl r9,r3,32,32 > 278: 78 00 00 20 clrldi r0,r0,32 > 27c: 7c 60 00 38 and r0,r3,r0 > 280: 7c 09 02 14 add r0,r9,r0 > 284: 78 09 00 22 rldicl r9,r0,32,32 > 288: 7c 00 4a 14 add r0,r0,r9 > 28c: 78 03 00 20 clrldi r3,r0,32 > 290: 4e 80 00 20 blr > > This patch modifies from64to32() to operate in the same > spirit as csum_fold() > > It swaps the two 32-bit halves of sum then it adds it with the > unswapped sum. If there is a carry from adding the two 32-bit halves, > it will carry from the lower half into the upper half, giving us the > correct sum in the upper half. > > The resulting code is: > > 0000000000000260 <.from64to32>: > 260: 78 60 00 02 rotldi r0,r3,32 > 264: 7c 60 1a 14 add r3,r0,r3 > 268: 78 63 00 22 rldicl r3,r3,32,32 > 26c: 4e 80 00 20 blr > > Signed-off-by: Christophe Leroy Applied to powerpc next, thanks. https://git.kernel.org/powerpc/c/55a0edf083022e402042255a0afb03 cheers