public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/meissner/heads/work044)] Use XXSPLTIW to load up V8HI constants.
@ 2021-04-02 17:16 Michael Meissner
  0 siblings, 0 replies; only message in thread
From: Michael Meissner @ 2021-04-02 17:16 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:4d62bffd4f2912b7bda1bfde889de8e71c1d5c49

commit 4d62bffd4f2912b7bda1bfde889de8e71c1d5c49
Author: Michael Meissner <meissner@linux.ibm.com>
Date:   Fri Apr 2 13:16:08 2021 -0400

    Use XXSPLTIW to load up V8HI constants.
    
    This patch adds support to use the ISA 3.1 XXSPLTIW instruction to load up
    V8HImode constants.
    
    gcc/
    2021-04-02  Michael Meissner  <meissner@linux.ibm.com>
    
            * config/rs6000/predicates.md (xxspltiw_operand): Add support for
            loading up V8HImode constants.
            * config/rs6000/rs6000.c (xxspltib_constant_p): Add support for
            loading up V8HImode constants with XXSPLTIW.
            (xxspltiw_constant_p): Add V8HImode support.
            * config/rs6000/vsx.md (XXSPLTIW): New iterator.
            (xxspltiw<mode>, xxspltiwv4si): Convert xxspltiwv4si into
            xxspltiw<mode> and handle V8HImode constants as well.

Diff:
---
 gcc/config/rs6000/predicates.md |  4 ++++
 gcc/config/rs6000/rs6000.c      | 16 ++++++++++++----
 gcc/config/rs6000/vsx.md        | 11 +++++++----
 3 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/gcc/config/rs6000/predicates.md b/gcc/config/rs6000/predicates.md
index aaf8697ead0..7c63320d599 100644
--- a/gcc/config/rs6000/predicates.md
+++ b/gcc/config/rs6000/predicates.md
@@ -651,6 +651,10 @@
   if (!xxspltiw_constant_p (op, mode, &value))
     return false;
 
+  /* xxspltiw_constant_p returns V8HI as (element | (element << 16)).  */
+  if (mode == V8HImode)
+    value = ((value & 0xffff) ^ 0x8000) - 0x8000;
+
   return !EASY_VECTOR_15 (value);
 })
 
diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index 351b2805ee2..a4f83b06727 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -6462,7 +6462,8 @@ xxspltib_constant_p (rtx op,
 
   /* If XXSPLTIW is available, don't return true if we can use that
      instruction instead of doing 2 instructions. */
-  else if (TARGET_XXSPLTIW && mode == V4SImode)
+  else if (TARGET_XXSPLTIW
+	   && (mode == V4SImode || mode == V8HImode))
     return false;
 
   else
@@ -6490,7 +6491,7 @@ xxspltiw_constant_p (rtx op,
   if (mode == VOIDmode)
     mode = GET_MODE (op);
 
-  if (mode != V4SImode)
+  if (mode != V8HImode && mode != V4SImode)
     return false;
 
   rtx element = op;
@@ -6510,10 +6511,17 @@ xxspltiw_constant_p (rtx op,
   if (!CONST_INT_P (element))
     return false;
 
-  if (!SIGNED_INTEGER_NBIT_P (INTVAL (element), 32))
+  HOST_WIDE_INT value = INTVAL (element);
+  if (!SIGNED_INTEGER_NBIT_P (value, 32))
     return false;
 
-  *constant_ptr = INTVAL (element);
+  if (mode == V8HImode)
+    {
+      value &= 0xffff;
+      value |= value << 16;
+    }
+
+  *constant_ptr = value;
   return true;
 }
 
diff --git a/gcc/config/rs6000/vsx.md b/gcc/config/rs6000/vsx.md
index a630eee2cb5..9ec0ef9ecb1 100644
--- a/gcc/config/rs6000/vsx.md
+++ b/gcc/config/rs6000/vsx.md
@@ -209,6 +209,9 @@
 (define_mode_iterator VSINT_84  [V4SI V2DI DI SI])
 (define_mode_iterator VSINT_842 [V8HI V4SI V2DI])
 
+;; Iterator for loading constants with xxspltiw
+(define_mode_iterator XXSPLTIW [V8HI V4SI])
+
 ;; Vector reverse byte modes
 (define_mode_iterator VEC_REVB [V8HI V4SI V2DI V4SF V2DF V1TI])
 
@@ -1160,14 +1163,14 @@
 
 
 ;; XXSPLTIW support.
-(define_insn "*xxspltiwv4si"
-  [(set (match_operand:V4SI 0 "vsx_register_operand" "=wa")
-	(match_operand:V4SI 1 "xxspltiw_operand"))]
+(define_insn "*xxspltiw<mode>"
+  [(set (match_operand:XXSPLTIW 0 "vsx_register_operand" "=wa")
+	(match_operand:XXSPLTIW 1 "xxspltiw_operand"))]
   "TARGET_XXSPLTIW"
 {
   long value = 0;
 
-  if (!xxspltiw_constant_p (operands[1], V4SImode, &value))
+  if (!xxspltiw_constant_p (operands[1], <MODE>mode, &value))
     gcc_unreachable ();
 
   operands[2] = GEN_INT (value);


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-04-02 17:16 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-02 17:16 [gcc(refs/users/meissner/heads/work044)] Use XXSPLTIW to load up V8HI constants Michael Meissner

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