Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp4650603pxb; Sat, 12 Feb 2022 13:00:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJzwOd7TffcBQUdHgO+tJGyzCQlXbd+HUSC+O9+pxwzOAER0XaU7255wDKohmXsCBCtPWGYF X-Received: by 2002:a05:6402:1681:: with SMTP id a1mr8104315edv.167.1644699604753; Sat, 12 Feb 2022 13:00:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644699604; cv=none; d=google.com; s=arc-20160816; b=hdVMBcRZGjEXMVdqFVgs1NSv8u45lLrdOoZ1N4lw1muu5DOOOQTBKI496Re5QsXYrI 0xirIQaLgPRKFgGe2gJojxEASoKxK9n/dieSlwu+NPe5NOesNELOIKaVpTlTRqoJzNxl /t0rPnGlJpyHquic9aLQDZ5qcveWsue3Z/vh8TlaiX0fI4/upbBDeqNsSTNWnogEbMhI 6efv+k1BxixKuEJGt308s+l+7yYkGKrT9R5ezRRX+pV1mwA5c0dlTM8xB7fjuCP5GEwS rovOE3DNbQYgLCiPIkBx2RmycDt0bHNZqYmELlyXUH1iETcZVbr/2+yHS3kD2kD5ZbWd KiUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=tZ5n7ZJkXqoJioWBe794p/k321oXstsduYkqLjoACEw=; b=n6dypWANbXDdg+MlxwMKLMAnLCFM/N3VJYd7+hnZSLVM/NMoj9R6V92tXX3BUpWnyl /M3iPlh7sySENuxicTu/DDW4dSe6ThDUU20ARPgas9plA+eibvgpY4ImZsflt16EhEZn +K+e6k7bSuPfSrl/TmZN3AyqoZg6XZ8qG8K4wS7Q5ywSW6IhsgtTe7qWEJCxa8bN1VjW rWnrO7V828GyncwUjq0ZYyqnueqQhlwc0opBGb8Ovh+AInapWGmRr/wyUICM+j68XNGe Uwyc82SY+OsxQysi5eF7sfyHxrkSR+2bVSanDn8J1acpIP/ETxqSmbLNCGbg5pJ5IF6O r/0w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g15si13682899ejt.914.2022.02.12.12.59.41; Sat, 12 Feb 2022 13:00:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232431AbiBLHgf (ORCPT + 99 others); Sat, 12 Feb 2022 02:36:35 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:51322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231893AbiBLHge (ORCPT ); Sat, 12 Feb 2022 02:36:34 -0500 Received: from pegase2.c-s.fr (pegase2.c-s.fr [93.17.235.10]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ADC4526AD6 for ; Fri, 11 Feb 2022 23:36:31 -0800 (PST) Received: from localhost (mailhub3.si.c-s.fr [172.26.127.67]) by localhost (Postfix) with ESMTP id 4Jwj3L05r6z9sSl; Sat, 12 Feb 2022 08:36:30 +0100 (CET) X-Virus-Scanned: amavisd-new at c-s.fr Received: from pegase2.c-s.fr ([172.26.127.65]) by localhost (pegase2.c-s.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id YH9d5bLukDHE; Sat, 12 Feb 2022 08:36:29 +0100 (CET) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase2.c-s.fr (Postfix) with ESMTP id 4Jwj3K69Qlz9sSf; Sat, 12 Feb 2022 08:36:29 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id BBADA8B766; Sat, 12 Feb 2022 08:36:29 +0100 (CET) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id 5Wjtjkt5FelZ; Sat, 12 Feb 2022 08:36:29 +0100 (CET) Received: from PO20335.IDSI0.si.c-s.fr (unknown [192.168.6.139]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 8DB268B763; Sat, 12 Feb 2022 08:36:29 +0100 (CET) Received: from PO20335.IDSI0.si.c-s.fr (localhost [127.0.0.1]) by PO20335.IDSI0.si.c-s.fr (8.17.1/8.16.1) with ESMTPS id 21C7aJMJ1582946 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Sat, 12 Feb 2022 08:36:20 +0100 Received: (from chleroy@localhost) by PO20335.IDSI0.si.c-s.fr (8.17.1/8.17.1/Submit) id 21C7aHCA1582945; Sat, 12 Feb 2022 08:36:17 +0100 X-Authentication-Warning: PO20335.IDSI0.si.c-s.fr: chleroy set sender to christophe.leroy@csgroup.eu using -f From: Christophe Leroy To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: Christophe Leroy , linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Subject: [PATCH] powerpc: Reduce csum_add() complexity for PPC64 Date: Sat, 12 Feb 2022 08:36:17 +0100 Message-Id: X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1644651376; l=1197; s=20211009; h=from:subject:message-id; bh=U5EmRa7z4Ma/DFv0qhSDVvJA4tBg+isoQi09WUvKg+8=; b=KJrT27Qc+2p02+9Sde8X9nsa3+2JOSXSvKurff5AknJt2FnwWPSgmPCM19veBsggrnd9GslHzzE+ 6AjZY8AfDa+UjYwLIYA38FtPm+KNUcDSIjYQMP+LrONI1J3dwBMU X-Developer-Key: i=christophe.leroy@csgroup.eu; a=ed25519; pk=HIzTzUj91asvincQGOFx6+ZF5AoUuP9GdOtQChs7Mm0= Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org PPC64 does everything in C, gcc is able to skip calculation when one of the operands in zero. Move the constant folding in PPC32 part. This helps GCC and reduces ppc64_defconfig by 170 bytes. Signed-off-by: Christophe Leroy --- arch/powerpc/include/asm/checksum.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/arch/powerpc/include/asm/checksum.h b/arch/powerpc/include/asm/checksum.h index 3288a1bf5e8d..e4e25b46ac49 100644 --- a/arch/powerpc/include/asm/checksum.h +++ b/arch/powerpc/include/asm/checksum.h @@ -95,16 +95,15 @@ static __always_inline __wsum csum_add(__wsum csum, __wsum addend) { #ifdef __powerpc64__ u64 res = (__force u64)csum; -#endif + + res += (__force u64)addend; + return (__force __wsum)((u32)res + (res >> 32)); +#else if (__builtin_constant_p(csum) && csum == 0) return addend; if (__builtin_constant_p(addend) && addend == 0) return csum; -#ifdef __powerpc64__ - res += (__force u64)addend; - return (__force __wsum)((u32)res + (res >> 32)); -#else asm("addc %0,%0,%1;" "addze %0,%0;" : "+r" (csum) : "r" (addend) : "xer"); -- 2.34.1