public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH, expand] Add const0 move checking for CLEAR_BY_PIECES optabs
@ 2024-01-16  2:04 HAO CHEN GUI
  2024-01-17  2:34 ` Jeff Law
  0 siblings, 1 reply; 2+ messages in thread
From: HAO CHEN GUI @ 2024-01-16  2:04 UTC (permalink / raw)
  To: gcc-patches
  Cc: Segher Boessenkool, David, Kewen.Lin, Peter Bergner, Richard Sandiford

Hi,
  This patch adds const0 move checking for CLEAR_BY_PIECES. The original
vec_duplicate handles duplicates of non-constant inputs. But 0 is a
constant. So even a platform doesn't support vec_duplicate, it could
still do clear by pieces if it supports const0 move by that mode.

  The test cases will be added in subsequent target specific patch.

  Bootstrapped and tested on x86 and powerpc64-linux BE and LE with no
regressions.

Thanks
Gui Haochen

ChangeLog
expand: Add const0 move checking for CLEAR_BY_PIECES optabs

vec_duplicate handles duplicates of non-constant inputs.  The 0 is a
constant.  So even a platform doesn't support vec_duplicate, it could
still do clear by pieces if it supports const0 move.  This patch adds
the checking.

gcc/
	* expr.cc (by_pieces_mode_supported_p): Add const0 move checking
	for CLEAR_BY_PIECES.

patch.diff
diff --git a/gcc/expr.cc b/gcc/expr.cc
index 34f5ff90a9f..cd960349a53 100644
--- a/gcc/expr.cc
+++ b/gcc/expr.cc
@@ -1006,14 +1006,21 @@ can_use_qi_vectors (by_pieces_operation op)
 static bool
 by_pieces_mode_supported_p (fixed_size_mode mode, by_pieces_operation op)
 {
-  if (optab_handler (mov_optab, mode) == CODE_FOR_nothing)
+  enum insn_code icode = optab_handler (mov_optab, mode);
+  if (icode == CODE_FOR_nothing)
     return false;

-  if ((op == SET_BY_PIECES || op == CLEAR_BY_PIECES)
+  if (op == SET_BY_PIECES
       && VECTOR_MODE_P (mode)
       && optab_handler (vec_duplicate_optab, mode) == CODE_FOR_nothing)
     return false;

+  if (op == CLEAR_BY_PIECES
+      && VECTOR_MODE_P (mode)
+      && optab_handler (vec_duplicate_optab, mode) == CODE_FOR_nothing
+      && !insn_operand_matches (icode, 1, CONST0_RTX (mode)))
+    return false;
+
   if (op == COMPARE_BY_PIECES
       && !can_compare_p (EQ, mode, ccp_jump))
     return false;

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH, expand] Add const0 move checking for CLEAR_BY_PIECES optabs
  2024-01-16  2:04 [PATCH, expand] Add const0 move checking for CLEAR_BY_PIECES optabs HAO CHEN GUI
@ 2024-01-17  2:34 ` Jeff Law
  0 siblings, 0 replies; 2+ messages in thread
From: Jeff Law @ 2024-01-17  2:34 UTC (permalink / raw)
  To: HAO CHEN GUI, gcc-patches
  Cc: Segher Boessenkool, David, Kewen.Lin, Peter Bergner, Richard Sandiford



On 1/15/24 19:04, HAO CHEN GUI wrote:
> Hi,
>    This patch adds const0 move checking for CLEAR_BY_PIECES. The original
> vec_duplicate handles duplicates of non-constant inputs. But 0 is a
> constant. So even a platform doesn't support vec_duplicate, it could
> still do clear by pieces if it supports const0 move by that mode.
> 
>    The test cases will be added in subsequent target specific patch.
> 
>    Bootstrapped and tested on x86 and powerpc64-linux BE and LE with no
> regressions.
> 
> Thanks
> Gui Haochen
> 
> ChangeLog
> expand: Add const0 move checking for CLEAR_BY_PIECES optabs
> 
> vec_duplicate handles duplicates of non-constant inputs.  The 0 is a
> constant.  So even a platform doesn't support vec_duplicate, it could
> still do clear by pieces if it supports const0 move.  This patch adds
> the checking.
> 
> gcc/
> 	* expr.cc (by_pieces_mode_supported_p): Add const0 move checking
> 	for CLEAR_BY_PIECES.'
This doesn't look like it fixes a regression.  So it seems to me it 
ought to wait for gcc-15.

Jeff

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-01-17  2:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-16  2:04 [PATCH, expand] Add const0 move checking for CLEAR_BY_PIECES optabs HAO CHEN GUI
2024-01-17  2:34 ` Jeff Law

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).