From patchwork Fri Jan 13 18:27:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 63176 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 14CD638AA24C for ; Fri, 13 Jan 2023 18:29:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 14CD638AA24C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1673634592; bh=AEda2Go3RyWSXhVZCPPbGr7GU1m00/hwPQA/uASx4qs=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=d1ZsykHFedgQ8FbOUQJm1FeFxteOdA+dCkOrWXFXZXoQhOhQPO1lYThaNnoQ8CSR4 EcOQO5J5ws7DHJIaPgQ5J0mNvky/cbP/DhN3JvRZ8LOewSCwlBsqcDLk/PT6vV9eF8 lQoFpdffvWMcDvI2x/WEDqxhv0AfCI+KLG2RaYGw= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by sourceware.org (Postfix) with ESMTPS id 58508383FBAD for ; Fri, 13 Jan 2023 18:27:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 58508383FBAD Received: by mail-pl1-x62c.google.com with SMTP id d9so24241819pll.9 for ; Fri, 13 Jan 2023 10:27:55 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AEda2Go3RyWSXhVZCPPbGr7GU1m00/hwPQA/uASx4qs=; b=F65X61+CTtInSePdWYYr262RTJ1p8svkkN0NvVSjFZ3owDzW2yHyWEFzl5TyPNd36a ioPqMKTWsGksvXXAyvQVtoFvaokGPFD8G5vhWsBkFD4K3+pw9zD0EBkQVvI1kdPKYTyP AaE/fhyT9dCSnXgKMW7VYNoADA5/zeeNhAFhWrGCqtCRnxBEzEEzFSW0VqqaNpa0k+gl r3UeTD+cw1AxaJbBLgr3jR6EPSjsfR79SS35Y6Xs2XE+/zD4VftR8/fE9Mnx7SzuSzPB oSgYSeSMVZdawGHG/kTJ+ubwDY1k/tJ295B6z9rsdg9O6A30tmoK5QbV2Ncjqpk+8fwi YIwQ== X-Gm-Message-State: AFqh2krNCEuUqWuAqvFNbaFR2T9cA/K7LbpS/gTFRseHuRkpTVfxkCkW CRC69dzRF7pEhZfb7I6Wrf6w3La5yYlSUDOH X-Google-Smtp-Source: AMrXdXvVX1+xlt7KeIUxci0atE4lpy3Og63FF4DrfXjT2dFtH3h37CzR3K4Gt+B2PDw3MiK38LBSPA== X-Received: by 2002:a17:902:a3cd:b0:193:bec:497c with SMTP id q13-20020a170902a3cd00b001930bec497cmr25259985plb.68.1673634474386; Fri, 13 Jan 2023 10:27:54 -0800 (PST) Received: from stoup.. (rrcs-173-198-77-218.west.biz.rr.com. [173.198.77.218]) by smtp.gmail.com with ESMTPSA id s17-20020a170902c65100b001927ebc40e2sm14443640pls.193.2023.01.13.10.27.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Jan 2023 10:27:53 -0800 (PST) To: libc-alpha@sourceware.org Cc: adhemerval.zanella@linaro.org, goldstein.w.n@gmail.com Subject: [PATCH v8 12/17] hppa: Add memcopy.h Date: Fri, 13 Jan 2023 08:27:28 -1000 Message-Id: <20230113182733.1268668-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230113182733.1268668-1-richard.henderson@linaro.org> References: <20230113182733.1268668-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Richard Henderson via Libc-alpha From: Richard Henderson Reply-To: Richard Henderson Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" GCC's combine pass cannot merge (x >> c | y << (32 - c)) into a double-word shift unless (1) the subtract is in the same basic block and (2) the result of the subtract is used exactly once. Neither condition is true for any use of MERGE. By forcing the use of a double-word shift, we not only reduce contention on SAR, but also allow the setting of SAR to be hoisted outside of a loop. Checked on hppa-linux-gnu. Message-Id: <20230111204558.2402155-13-adhemerval.zanella@linaro.org> --- sysdeps/hppa/memcopy.h | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 sysdeps/hppa/memcopy.h diff --git a/sysdeps/hppa/memcopy.h b/sysdeps/hppa/memcopy.h new file mode 100644 index 0000000000..0d4b4ac435 --- /dev/null +++ b/sysdeps/hppa/memcopy.h @@ -0,0 +1,42 @@ +/* Definitions for memory copy functions, PA-RISC version. + Copyright (C) 2023 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library. If not, see + . */ + +#include + +/* Use a single double-word shift instead of two shifts and an ior. + If the uses of MERGE were close to the computation of shl/shr, + the compiler might have been able to create this itself. + But instead that computation is well separated. + + Using an inline function instead of a macro is the easiest way + to ensure that the types are correct. */ + +#undef MERGE + +static __always_inline op_t +MERGE (op_t w0, int shl, op_t w1, int shr) +{ + _Static_assert (OPSIZ == 4 || OPSIZ == 8, "Invalid OPSIZE"); + + op_t res; + if (OPSIZ == 4) + asm ("shrpw %1,%2,%%sar,%0" : "=r"(res) : "r"(w0), "r"(w1), "q"(shr)); + else if (OPSIZ == 8) + asm ("shrpd %1,%2,%%sar,%0" : "=r"(res) : "r"(w0), "r"(w1), "q"(shr)); + return res; +}