public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] rs6000: Use known constant for GET_MODE_NUNITS and similar
@ 2022-01-13  1:56 Kewen.Lin
  2022-01-13  3:12 ` David Edelsohn
  0 siblings, 1 reply; 7+ messages in thread
From: Kewen.Lin @ 2022-01-13  1:56 UTC (permalink / raw)
  To: GCC Patches; +Cc: Segher Boessenkool, David Edelsohn, Bill Schmidt

Hi,

This patch is to clean up some codes with GET_MODE_UNIT_SIZE or
GET_MODE_NUNITS, which can use known constant instead.

Bootstrapped and regtested on powerpc64le-linux-gnu P9 and
powerpc64-linux-gnu P8.

Is it ok for trunk?

BR,
Kewen
-----
gcc/ChangeLog:

	* config/rs6000/altivec.md (altivec_vreveti2): Use known constant
	values to simplify code.
	* config/rs6000/vsx.md (*vsx_extract_si, *vsx_extract_si_<uns>float_df,
	*vsx_extract_si_<uns>float_<mode>, *vsx_insert_extract_v4sf_p9):
	Likewise.
---
 gcc/config/rs6000/altivec.md | 11 +++--------
 gcc/config/rs6000/vsx.md     |  8 ++++----
 2 files changed, 7 insertions(+), 12 deletions(-)

diff --git a/gcc/config/rs6000/altivec.md b/gcc/config/rs6000/altivec.md
index c2312cc1e0f..d5c4ecfa9b7 100644
--- a/gcc/config/rs6000/altivec.md
+++ b/gcc/config/rs6000/altivec.md
@@ -3957,17 +3957,12 @@ (define_expand "altivec_vreveti2"
 		      UNSPEC_VREVEV))]
   "TARGET_ALTIVEC"
 {
-  int i, j, size, num_elements;
+  int i;
   rtvec v = rtvec_alloc (16);
   rtx mask = gen_reg_rtx (V16QImode);

-  size = GET_MODE_UNIT_SIZE (TImode);
-  num_elements = GET_MODE_NUNITS (TImode);
-
-  for (j = 0; j < num_elements; j++)
-    for (i = 0; i < size; i++)
-      RTVEC_ELT (v, i + j * size)
-	= GEN_INT (i + (num_elements - 1 - j) * size);
+  for (i = 0; i < 16; i++)
+    RTVEC_ELT (v, i) = GEN_INT (i);

   emit_insn (gen_vec_initv16qiqi (mask, gen_rtx_PARALLEL (V16QImode, v)));
   emit_insn (gen_altivec_vperm_ti (operands[0], operands[1],
diff --git a/gcc/config/rs6000/vsx.md b/gcc/config/rs6000/vsx.md
index 802db0d112b..892b99c6d6b 100644
--- a/gcc/config/rs6000/vsx.md
+++ b/gcc/config/rs6000/vsx.md
@@ -3855,7 +3855,7 @@ (define_insn_and_split  "*vsx_extract_si"
   int value;

   if (!BYTES_BIG_ENDIAN)
-    element = GEN_INT (GET_MODE_NUNITS (V4SImode) - 1 - INTVAL (element));
+    element = GEN_INT (3 - INTVAL (element));

   /* If the value is in the correct position, we can avoid doing the VSPLT<x>
      instruction.  */
@@ -4231,7 +4231,7 @@ (define_insn_and_split "*vsx_extract_si_<uns>float_df"
   int value;

   if (!BYTES_BIG_ENDIAN)
-    element = GEN_INT (GET_MODE_NUNITS (V4SImode) - 1 - INTVAL (element));
+    element = GEN_INT (3 - INTVAL (element));

   /* If the value is in the correct position, we can avoid doing the VSPLT<x>
      instruction.  */
@@ -4274,7 +4274,7 @@ (define_insn_and_split "*vsx_extract_si_<uns>float_<mode>"
   int value;

   if (!BYTES_BIG_ENDIAN)
-    element = GEN_INT (GET_MODE_NUNITS (V4SImode) - 1 - INTVAL (element));
+    element = GEN_INT (3 - INTVAL (element));

   /* If the value is in the correct position, we can avoid doing the VSPLT<x>
      instruction.  */
@@ -4467,7 +4467,7 @@ (define_insn "*vsx_insert_extract_v4sf_p9"
   int ele = INTVAL (operands[4]);

   if (!BYTES_BIG_ENDIAN)
-    ele = GET_MODE_NUNITS (V4SFmode) - 1 - ele;
+    ele = 3 - ele;

   operands[4] = GEN_INT (GET_MODE_SIZE (SFmode) * ele);
   return "xxinsertw %x0,%x2,%4";
--
2.27.0


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

end of thread, other threads:[~2022-01-17  5:48 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-13  1:56 [PATCH] rs6000: Use known constant for GET_MODE_NUNITS and similar Kewen.Lin
2022-01-13  3:12 ` David Edelsohn
2022-01-13 12:40   ` Kewen.Lin
2022-01-13 15:15     ` David Edelsohn
2022-01-14 10:42       ` Kewen.Lin
2022-01-14 13:53         ` David Edelsohn
2022-01-17  5:48           ` Kewen.Lin

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