From patchwork Thu Sep 7 16:33:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xi Ruoyao X-Patchwork-Id: 137653 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ab0a:0:b0:3f2:4152:657d with SMTP id m10csp13988vqo; Thu, 7 Sep 2023 09:36:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGJvd1YauQc7B+wUMgNJm1XRctXz995ZzUqJVo7QKF8kbju0jaoveY2HeojDk7sxv0Q1f80 X-Received: by 2002:a50:ee10:0:b0:52e:1a29:98a with SMTP id g16-20020a50ee10000000b0052e1a29098amr4613287eds.40.1694104562955; Thu, 07 Sep 2023 09:36:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694104562; cv=none; d=google.com; s=arc-20160816; b=FaE77orazrNe8dWEOMcVxnRjYaX4GU81UtuMbeBUW7Xwnp2/iKLa0BS/vOKQ+dv8bB 1bl2W4mt8KLBZf/uWaMhZt1iRmrCHqlPsX9QhmGR0jtqG6FJMgGlZCuw5h+4NtFKhhOa 8DbH43JQM0sU9Oezffp5aEelQdu4yHSg+REb7ktEyt8BiqQqTEEX+wfxmP4U1vJq/BvP klYAj3PreXiB2Ti2CqvPSZhC6FD9Mm1vN01avujBKVaV8gPB2lxHuenl3/Eq2IzZOdQt VjO0g5XfcU1f3UAd3Ygj1PcvccaI+GgEhov2tErtVpyK/1Pg2f8bIJfN2Ydk8U0/6iFt Z6DQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=Y+PP9CjgqGcClj2OLLX0fVztqipf3pDkEJRKXH20xSE=; fh=q6FHtQ1B3olX6oLgixZqvnH85nrSbljxIHPliKzeBJ0=; b=CV60JkgB6RRRvQfQRmRMcJNGKIrHICMDu702InbaaNDCv2ddapc7lHtwZKdtv2Zuj6 n/IbgMlpllD6yR/dgU3X6szz+EYkL5FzPsH1jpfT5poxjpt4pVrMdhByQmWO7CyjiDZU pzBPum8Ct57edj1GOTSwrOl5v3o4mJQTrdt6bjn/oPXNntjRLNiiURc8EHbVqlWRtTud WkiCX9uhYtybduIsY4tCOAHMHjO4uSxNTMJsk20VLNK5i+TUxr8BuHIWNi0N1ItJi4TD lim232ndvU5qlFjXRakZCOk2OQIkmDa2csWjU5zKU/slT8XKm+49UwNZQk3yO8gNLJvo wpJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=aphEd4ft; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id p4-20020aa7d304000000b0052a48204781si10810124edq.543.2023.09.07.09.36.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 09:36:02 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=aphEd4ft; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BCE03385841D for ; Thu, 7 Sep 2023 16:36:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BCE03385841D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1694104561; bh=Y+PP9CjgqGcClj2OLLX0fVztqipf3pDkEJRKXH20xSE=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=aphEd4ftgbL9AMHc6ey2K9Nk9QUZpp+HYz5z7fQxunVE+Cp9uusBgwbM4OzgYJ9jo vBcE20C/YLr30I8Pm0SGvm3rgbCteQ9zwMaBZWteV+Ie21e8qsgXsmXkS0QiHM2Sa3 c4saWyg1PZQWV7CAJUAixN7bSiSk7v13x2ikCK1M= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from xry111.site (xry111.site [IPv6:2001:470:683e::1]) by sourceware.org (Postfix) with ESMTPS id B1EE93858D1E for ; Thu, 7 Sep 2023 16:35:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B1EE93858D1E Received: from stargazer.. (unknown [IPv6:240e:358:1175:f400:dc73:854d:832e:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (Client did not present a certificate) (Authenticated sender: xry111@xry111.site) by xry111.site (Postfix) with ESMTPSA id 76580659AC; Thu, 7 Sep 2023 12:34:59 -0400 (EDT) To: gcc-patches@gcc.gnu.org Subject: [PATCH] LoongArch: Slightly simplify loongarch_block_move_straight Date: Fri, 8 Sep 2023 00:33:37 +0800 Message-ID: <20230907163336.66198-2-xry111@xry111.site> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 X-Spam-Status: No, score=-8.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, LIKELY_SPAM_FROM, SPF_HELO_PASS, 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: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Xi Ruoyao via Gcc-patches From: Xi Ruoyao Reply-To: Xi Ruoyao Cc: xuchenghua@loongson.cn, chenglulu , i@xen0n.name Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776397386204122917 X-GMAIL-MSGID: 1776397386204122917 gcc/ChangeLog: * config/loongarch/loongarch.cc (loongarch_block_move_straight): Check precondition (delta must be a power of 2) and use popcount_hwi instead of a homebrew loop. --- I've not run a full bootstrap with this, but it should be obvious. Ok for trunk? gcc/config/loongarch/loongarch.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/gcc/config/loongarch/loongarch.cc b/gcc/config/loongarch/loongarch.cc index 509ef2b97f1..845fad5a8e8 100644 --- a/gcc/config/loongarch/loongarch.cc +++ b/gcc/config/loongarch/loongarch.cc @@ -5225,9 +5225,8 @@ loongarch_block_move_straight (rtx dest, rtx src, HOST_WIDE_INT length, emit two ld.d/st.d pairs, one ld.w/st.w pair, and one ld.b/st.b pair. For each load/store pair we use a dedicated register to keep the pipeline as populated as possible. */ - HOST_WIDE_INT num_reg = length / delta; - for (delta_cur = delta / 2; delta_cur != 0; delta_cur /= 2) - num_reg += !!(length & delta_cur); + gcc_assert (pow2p_hwi (delta)); + HOST_WIDE_INT num_reg = length / delta + popcount_hwi (length % delta); /* Allocate a buffer for the temporary registers. */ regs = XALLOCAVEC (rtx, num_reg);