public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Kewen Lin <linkw@linux.ibm.com>
To: gcc-patches@gcc.gnu.org
Cc: Kewen Lin <linkw@linux.ibm.com>,
	segher@kernel.crashing.org, dje.gcc@gmail.com,
	bergner@linux.ibm.com, meissner@linux.ibm.com
Subject: [PATCH 1/9] rs6000: Rework vector float comparison in rs6000_emit_vector_compare - p1
Date: Thu, 24 Nov 2022 03:15:49 -0600	[thread overview]
Message-ID: <20221124091557.514727-2-linkw@linux.ibm.com> (raw)
In-Reply-To: <20221124091557.514727-1-linkw@linux.ibm.com>

All kinds of vector float comparison operators have been
supported in a rtl comparison pattern as vector.md, we can
just emit an rtx comparison insn with the given comparison
operator in function rs6000_emit_vector_compare instead of
checking and handling the reverse condition cases.

This is part 1, it only handles the operators which are
already emitted with an rtx comparison previously in function
rs6000_emit_vector_compare_inner, they are EQ/GT/GE/ORDERED/
UNORDERED/UNEQ/LTGT.  There is no functionality change.

With this change, rs6000_emit_vector_compare_inner would
only work for vector integer comparison handling, it would
be cleaned up later in vector integer comparison rework.

gcc/ChangeLog:

	* config/rs6000/rs6000.cc (rs6000_emit_vector_compare_inner): Move
	MODE_VECTOR_FLOAT handlings out.
	(rs6000_emit_vector_compare): Emit rtx comparison for operators EQ/GT/
	GE/UNORDERED/ORDERED/UNEQ/LTGT of MODE_VECTOR_FLOAT directly, and
	adjust one call site of rs6000_emit_vector_compare_inner to
	rs6000_emit_vector_compare.
---
 gcc/config/rs6000/rs6000.cc | 47 ++++++++++++++++++++++++-------------
 1 file changed, 31 insertions(+), 16 deletions(-)

diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc
index d2743f7bce6..5a8f7ff3bf8 100644
--- a/gcc/config/rs6000/rs6000.cc
+++ b/gcc/config/rs6000/rs6000.cc
@@ -15644,7 +15644,6 @@ output_cbranch (rtx op, const char *label, int reversed, rtx_insn *insn)
 static rtx
 rs6000_emit_vector_compare_inner (enum rtx_code code, rtx op0, rtx op1)
 {
-  rtx mask;
   machine_mode mode = GET_MODE (op0);
 
   switch (code)
@@ -15652,19 +15651,11 @@ rs6000_emit_vector_compare_inner (enum rtx_code code, rtx op0, rtx op1)
     default:
       break;
 
-    case GE:
-      if (GET_MODE_CLASS (mode) == MODE_VECTOR_INT)
-	return NULL_RTX;
-      /* FALLTHRU */
-
     case EQ:
     case GT:
     case GTU:
-    case ORDERED:
-    case UNORDERED:
-    case UNEQ:
-    case LTGT:
-      mask = gen_reg_rtx (mode);
+      gcc_assert (GET_MODE_CLASS (mode) != MODE_VECTOR_FLOAT);
+      rtx mask = gen_reg_rtx (mode);
       emit_insn (gen_rtx_SET (mask, gen_rtx_fmt_ee (code, mode, op0, op1)));
       return mask;
     }
@@ -15680,18 +15671,42 @@ rs6000_emit_vector_compare (enum rtx_code rcode,
 			    rtx op0, rtx op1,
 			    machine_mode dmode)
 {
-  rtx mask;
-  bool swap_operands = false;
-  bool try_again = false;
-
   gcc_assert (VECTOR_UNIT_ALTIVEC_OR_VSX_P (dmode));
   gcc_assert (GET_MODE (op0) == GET_MODE (op1));
+  rtx mask;
+
+  /* In vector.md, we support all kinds of vector float point
+     comparison operators in a comparison rtl pattern, we can
+     just emit the comparison rtx insn directly here.  Besides,
+     we should have a centralized place to handle the possibility
+     of raising invalid exception.  As the first step, only check
+     operators EQ/GT/GE/UNORDERED/ORDERED/LTGT/UNEQ for now, they
+     are handled equivalently as before.
+
+     FIXME: Handle the remaining vector float comparison operators
+     here.  */
+  if (GET_MODE_CLASS (dmode) == MODE_VECTOR_FLOAT
+      && (rcode == EQ
+	  || rcode == GT
+	  || rcode == GE
+	  || rcode == UNORDERED
+	  || rcode == ORDERED
+	  || rcode == LTGT
+	  || rcode == UNEQ))
+    {
+      mask = gen_reg_rtx (dmode);
+      emit_insn (gen_rtx_SET (mask, gen_rtx_fmt_ee (rcode, dmode, op0, op1)));
+      return mask;
+    }
 
   /* See if the comparison works as is.  */
   mask = rs6000_emit_vector_compare_inner (rcode, op0, op1);
   if (mask)
     return mask;
 
+  bool swap_operands = false;
+  bool try_again = false;
+
   switch (rcode)
     {
     case LT:
@@ -15791,7 +15806,7 @@ rs6000_emit_vector_compare (enum rtx_code rcode,
       if (swap_operands)
 	std::swap (op0, op1);
 
-      mask = rs6000_emit_vector_compare_inner (rcode, op0, op1);
+      mask = rs6000_emit_vector_compare (rcode, op0, op1, dmode);
       if (mask)
 	return mask;
     }
-- 
2.27.0


  reply	other threads:[~2022-11-24  9:16 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-24  9:15 [PATCH 0/9] rs6000: Rework rs6000_emit_vector_compare Kewen Lin
2022-11-24  9:15 ` Kewen Lin [this message]
2022-11-24  9:15 ` [PATCH 2/9] rs6000: Rework vector float comparison in rs6000_emit_vector_compare - p2 Kewen Lin
2022-11-24  9:15 ` [PATCH 3/9] rs6000: Rework vector float comparison in rs6000_emit_vector_compare - p3 Kewen Lin
2022-11-24  9:15 ` [PATCH 4/9] rs6000: Rework vector float comparison in rs6000_emit_vector_compare - p4 Kewen Lin
2022-11-24  9:15 ` [PATCH 5/9] rs6000: Rework vector integer comparison in rs6000_emit_vector_compare - p1 Kewen Lin
2022-11-24  9:15 ` [PATCH 6/9] rs6000: Rework vector integer comparison in rs6000_emit_vector_compare - p2 Kewen Lin
2022-11-24  9:15 ` [PATCH 7/9] rs6000: Rework vector integer comparison in rs6000_emit_vector_compare - p3 Kewen Lin
2022-11-24  9:15 ` [PATCH 8/9] rs6000: Rework vector integer comparison in rs6000_emit_vector_compare - p4 Kewen Lin
2022-11-24  9:15 ` [PATCH 9/9] rs6000: Rework vector integer comparison in rs6000_emit_vector_compare - p5 Kewen Lin
2022-12-14 11:23 ` PING^1 [PATCH 0/9] rs6000: Rework rs6000_emit_vector_compare Kewen.Lin
2023-05-17  6:26   ` PING^2 " Kewen.Lin
2023-06-15  6:38     ` PING^3 " Kewen.Lin
2023-07-06 21:54       ` Michael Meissner
2023-08-07 10:05       ` PING^4 " Kewen.Lin
2023-10-25  2:47         ` PING^5 " Kewen.Lin
2023-11-08  2:50           ` PING^6 " Kewen.Lin
2023-12-04  9:50             ` PING^7 " Kewen.Lin
2023-12-12  6:08               ` PING^8 " Kewen.Lin

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=20221124091557.514727-2-linkw@linux.ibm.com \
    --to=linkw@linux.ibm.com \
    --cc=bergner@linux.ibm.com \
    --cc=dje.gcc@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=meissner@linux.ibm.com \
    --cc=segher@kernel.crashing.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).