[5/9] rs6000: Rework vector integer comparison in rs6000_emit_vector_compare - p1

Message ID 20221124091557.514727-6-linkw@linux.ibm.com
State New
Headers
Series rs6000: Rework rs6000_emit_vector_compare |

Commit Message

Kewen.Lin Nov. 24, 2022, 9:15 a.m. UTC
  The current handlings in rs6000_emit_vector_compare is a bit
complicated to me, especially after we emit vector float
comparison insn with the given code directly.  So it's better
to refactor the handlings of vector integer comparison here.

This is part 1, it's to remove the helper function
rs6000_emit_vector_compare_inner and move the logics into
rs6000_emit_vector_compare.  This patch doesn't introduce any
functionality change.

gcc/ChangeLog:

	* config/rs6000/rs6000.cc (rs6000_emit_vector_compare_inner): Remove.
	(rs6000_emit_vector_compare): Emit rtx comparison for operators EQ/
	GT/GTU directly.
---
 gcc/config/rs6000/rs6000.cc | 37 +++++++++----------------------------
 1 file changed, 9 insertions(+), 28 deletions(-)
  

Patch

diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc
index 94e039649f5..0a5826800c5 100644
--- a/gcc/config/rs6000/rs6000.cc
+++ b/gcc/config/rs6000/rs6000.cc
@@ -15639,30 +15639,6 @@  output_cbranch (rtx op, const char *label, int reversed, rtx_insn *insn)
   return string;
 }
 
-/* Return insn for VSX or Altivec comparisons.  */
-
-static rtx
-rs6000_emit_vector_compare_inner (enum rtx_code code, rtx op0, rtx op1)
-{
-  machine_mode mode = GET_MODE (op0);
-  gcc_assert (GET_MODE_CLASS (mode) != MODE_VECTOR_FLOAT);
-
-  switch (code)
-    {
-    default:
-      break;
-
-    case EQ:
-    case GT:
-    case GTU:
-      rtx mask = gen_reg_rtx (mode);
-      emit_insn (gen_rtx_SET (mask, gen_rtx_fmt_ee (code, mode, op0, op1)));
-      return mask;
-    }
-
-  return NULL_RTX;
-}
-
 /* Emit vector compare for operands OP0 and OP1 using code RCODE.
    DMODE is expected destination mode. This is a recursive function.  */
 
@@ -15687,10 +15663,15 @@  rs6000_emit_vector_compare (enum rtx_code rcode,
       return mask;
     }
 
-  /* See if the comparison works as is.  */
-  mask = rs6000_emit_vector_compare_inner (rcode, op0, op1);
-  if (mask)
-    return mask;
+  /* For any of vector integer comparison operators for which we
+     have direct hardware instructions, just emit it directly
+     here.  */
+  if (rcode == EQ || rcode == GT || rcode == GTU)
+    {
+      mask = gen_reg_rtx (dmode);
+      emit_insn (gen_rtx_SET (mask, gen_rtx_fmt_ee (rcode, dmode, op0, op1)));
+      return mask;
+    }
 
   bool swap_operands = false;
   bool try_again = false;