public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Xi Ruoyao <xry111@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r14-3819] LoongArch: Slightly simplify loongarch_block_move_straight
Date: Sat,  9 Sep 2023 06:36:29 +0000 (GMT)	[thread overview]
Message-ID: <20230909063629.609A53858D35@sourceware.org> (raw)

https://gcc.gnu.org/g:c0bb7a6f39e58717d34c9459586c0b1d5db16d89

commit r14-3819-gc0bb7a6f39e58717d34c9459586c0b1d5db16d89
Author: Xi Ruoyao <xry111@xry111.site>
Date:   Fri Sep 8 00:29:57 2023 +0800

    LoongArch: Slightly simplify loongarch_block_move_straight
    
    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.

Diff:
---
 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 509ef2b97f1c..845fad5a8e8b 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);

                 reply	other threads:[~2023-09-09  6:36 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230909063629.609A53858D35@sourceware.org \
    --to=xry111@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).