public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: HaoChen Gui <guihaoc@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r14-5816] Clean up by_pieces_ninsns
Date: Fri, 24 Nov 2023 09:17:01 +0000 (GMT)	[thread overview]
Message-ID: <20231124091701.23E273858C2F@sourceware.org> (raw)

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

commit r14-5816-ge377a340b34de1b06f2825691e45a33affcb4c2d
Author: Haochen Gui <guihaoc@gcc.gnu.org>
Date:   Fri Nov 24 17:14:46 2023 +0800

    Clean up by_pieces_ninsns
    
    The by pieces compare can be implemented by overlapped operations. So
    it should be taken into consideration when doing the adjustment for
    overlap operations.  The mode returned from
    widest_fixed_size_mode_for_size is already checked with mov_optab in
    by_pieces_mode_supported_p called by widest_fixed_size_mode_for_size.
    So it is no need to check mov_optab again in by_pieces_ninsns.  The
    patch fixes these issues.
    
    gcc/
            * expr.cc (by_pieces_ninsns): Include by pieces compare when
            do the adjustment for overlap operations.  Replace mov_optab
            checks with gcc assertion.

Diff:
---
 gcc/expr.cc | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/gcc/expr.cc b/gcc/expr.cc
index d9320674203..c432170403b 100644
--- a/gcc/expr.cc
+++ b/gcc/expr.cc
@@ -1090,18 +1090,16 @@ by_pieces_ninsns (unsigned HOST_WIDE_INT l, unsigned int align,
   unsigned HOST_WIDE_INT n_insns = 0;
   fixed_size_mode mode;
 
-  if (targetm.overlap_op_by_pieces_p () && op != COMPARE_BY_PIECES)
+  if (targetm.overlap_op_by_pieces_p ())
     {
       /* NB: Round up L and ALIGN to the widest integer mode for
 	 MAX_SIZE.  */
       mode = widest_fixed_size_mode_for_size (max_size, op);
-      if (optab_handler (mov_optab, mode) != CODE_FOR_nothing)
-	{
-	  unsigned HOST_WIDE_INT up = ROUND_UP (l, GET_MODE_SIZE (mode));
-	  if (up > l)
-	    l = up;
-	  align = GET_MODE_ALIGNMENT (mode);
-	}
+      gcc_assert (optab_handler (mov_optab, mode) != CODE_FOR_nothing);
+      unsigned HOST_WIDE_INT up = ROUND_UP (l, GET_MODE_SIZE (mode));
+      if (up > l)
+	l = up;
+      align = GET_MODE_ALIGNMENT (mode);
     }
 
   align = alignment_for_piecewise_move (MOVE_MAX_PIECES, align);
@@ -1109,12 +1107,11 @@ by_pieces_ninsns (unsigned HOST_WIDE_INT l, unsigned int align,
   while (max_size > 1 && l > 0)
     {
       mode = widest_fixed_size_mode_for_size (max_size, op);
-      enum insn_code icode;
+      gcc_assert (optab_handler (mov_optab, mode) != CODE_FOR_nothing);
 
       unsigned int modesize = GET_MODE_SIZE (mode);
 
-      icode = optab_handler (mov_optab, mode);
-      if (icode != CODE_FOR_nothing && align >= GET_MODE_ALIGNMENT (mode))
+      if (align >= GET_MODE_ALIGNMENT (mode))
 	{
 	  unsigned HOST_WIDE_INT n_pieces = l / modesize;
 	  l %= modesize;

                 reply	other threads:[~2023-11-24  9:17 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=20231124091701.23E273858C2F@sourceware.org \
    --to=guihaoc@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).