This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Some vector simplifications for combine


I have a testcase here where some vector operations aren't optimized too well.
This patch attempts to fix it.  It's not really likely to catch a lot of
simplifications, but it's a start.

Bernd
	* combine.c (combine_simplify_rtx): Try to simplify VEC_SELECT of
	VEC_CONCAT.

Index: combine.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/combine.c,v
retrieving revision 1.148
diff -u -p -r1.148 combine.c
--- combine.c	2000/09/04 10:18:31	1.148
+++ combine.c	2000/09/07 12:10:36
@@ -4539,6 +4539,45 @@ combine_simplify_rtx (x, op0_mode, last,
 
       break;
 
+    case VEC_SELECT:
+      {
+	rtx op0 = XEXP (x, 0);
+	rtx op1 = XEXP (x, 1);
+	int len;
+
+	if (GET_CODE (op1) != PARALLEL)
+	  abort ();
+	len = XVECLEN (op1, 0);
+	if (len == 1
+	    && GET_CODE (XVECEXP (op1, 0, 0)) == CONST_INT
+	    && GET_CODE (op0) == VEC_CONCAT)
+	  {
+	    int offset = INTVAL (XVECEXP (op1, 0, 0)) * GET_MODE_SIZE (GET_MODE (x));
+
+	    /* Try to find the element in the VEC_CONCAT.  */
+	    for (;;)
+	      {
+		if (GET_MODE (op0) == GET_MODE (x))
+		  return op0;
+		if (GET_CODE (op0) == VEC_CONCAT)
+		  {
+		    HOST_WIDE_INT op0_size = GET_MODE_SIZE (GET_MODE (XEXP (op0, 0)));
+		    if (op0_size < offset)
+		      op0 = XEXP (op0, 0);
+		    else
+		      {
+			offset -= op0_size;
+			op0 = XEXP (op0, 1);
+		      }
+		  }
+		else
+		  break;
+	      }
+	  }
+      }
+
+      break;
+      
     default:
       break;
     }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]