[6/9] rs6000: Rework vector integer comparison in rs6000_emit_vector_compare - p2

Message ID 20221124091557.514727-7-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 2, it's to refactor the handlings on LT and LTU.
This patch doesn't introduce any functionality change.

gcc/ChangeLog:

	* config/rs6000/rs6000.cc (rs6000_emit_vector_compare): Refine the
	handlings for operators LT and LTU.
---
 gcc/config/rs6000/rs6000.cc | 32 +++++++++-----------------------
 1 file changed, 9 insertions(+), 23 deletions(-)
  

Patch

diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc
index 0a5826800c5..c1aebbb5c03 100644
--- a/gcc/config/rs6000/rs6000.cc
+++ b/gcc/config/rs6000/rs6000.cc
@@ -15672,22 +15672,18 @@  rs6000_emit_vector_compare (enum rtx_code rcode,
       emit_insn (gen_rtx_SET (mask, gen_rtx_fmt_ee (rcode, dmode, op0, op1)));
       return mask;
     }
-
-  bool swap_operands = false;
-  bool try_again = false;
+  else if (rcode == LT || rcode == LTU)
+    {
+      /* lt{,u}(a,b) = gt{,u}(b,a)  */
+      enum rtx_code code = swap_condition (rcode);
+      std::swap (op0, op1);
+      mask = gen_reg_rtx (dmode);
+      emit_insn (gen_rtx_SET (mask, gen_rtx_fmt_ee (code, dmode, op0, op1)));
+      return mask;
+    }
 
   switch (rcode)
     {
-    case LT:
-      rcode = GT;
-      swap_operands = true;
-      try_again = true;
-      break;
-    case LTU:
-      rcode = GTU;
-      swap_operands = true;
-      try_again = true;
-      break;
     case NE:
       /* Invert condition and try again.
 	 e.g., A != B becomes ~(A==B).  */
@@ -15761,16 +15757,6 @@  rs6000_emit_vector_compare (enum rtx_code rcode,
       return NULL_RTX;
     }
 
-  if (try_again)
-    {
-      if (swap_operands)
-	std::swap (op0, op1);
-
-      mask = rs6000_emit_vector_compare (rcode, op0, op1, dmode);
-      if (mask)
-	return mask;
-    }
-
   /* You only get two chances.  */
   return NULL_RTX;
 }