patch + rfc: clear_storage() and vectors

Aldy Hernandez aldyh@redhat.com
Fri Feb 15 02:16:00 GMT 2002


On Friday, February 15, 2002, at 08:29  AM, Richard Henderson wrote:

> On Thu, Feb 14, 2002 at 02:15:55PM +1100, Aldy Hernandez wrote:
>> we could add them, but then we would have to make sure that every
>> simd port has an equivalent (set (reg:VEC) (const_int 0)) move.
>> i don't think this is necessarily true.
>
> I suspect that it is true -- it's too useful not to have.

ahh, what the heck.  i'm on a roll.

here's the patch that does the right thing.

ok?

2002-02-15  Aldy Hernandez  <aldyh@redhat.com>

	* emit-rtl.c (init_emit_once): Generate const0_rtx for vectors.

	* expr.c (clear_storage): Allow vectors.

Index: expr.c
===================================================================
RCS file: /cvs/uberbaum/gcc/expr.c,v
retrieving revision 1.417
diff -c -p -r1.417 expr.c
*** expr.c	2002/02/12 22:26:11	1.417
--- expr.c	2002/02/15 07:49:00
*************** clear_storage (object, size)
*** 2562,2569 ****

     /* If OBJECT is not BLKmode and SIZE is the same size as its mode,
        just move a zero.  Otherwise, do this a piece at a time.  */
!   if ((GET_MODE (object) != BLKmode
!        && !VECTOR_MODE_P (GET_MODE (object)))
         && GET_CODE (size) == CONST_INT
         && GET_MODE_SIZE (GET_MODE (object)) == (unsigned int) INTVAL 
(size))
       emit_move_insn (object, CONST0_RTX (GET_MODE (object)));
--- 2562,2568 ----

     /* If OBJECT is not BLKmode and SIZE is the same size as its mode,
        just move a zero.  Otherwise, do this a piece at a time.  */
!   if (GET_MODE (object) != BLKmode
         && GET_CODE (size) == CONST_INT
         && GET_MODE_SIZE (GET_MODE (object)) == (unsigned int) INTVAL 
(size))
       emit_move_insn (object, CONST0_RTX (GET_MODE (object)));
Index: emit-rtl.c
===================================================================
RCS file: /cvs/uberbaum/gcc/emit-rtl.c,v
retrieving revision 1.247
diff -c -p -r1.247 emit-rtl.c
*** emit-rtl.c	2002/01/31 06:21:19	1.247
--- emit-rtl.c	2002/02/15 07:49:02
*************** init_emit_once (line_numbers)
*** 4920,4925 ****
--- 4920,4954 ----
   	const_tiny_rtx[i][(int) mode] = GEN_INT (i);
       }

+   for (mode = GET_CLASS_NARROWEST_MODE (MODE_VECTOR_INT);
+        mode != VOIDmode;
+        mode = GET_MODE_WIDER_MODE (mode))
+     const_tiny_rtx[0][(int) mode] = const0_rtx;
+
+   for (mode = GET_CLASS_NARROWEST_MODE (MODE_VECTOR_FLOAT);
+        mode != VOIDmode;
+        mode = GET_MODE_WIDER_MODE (mode))
+     {
+       rtx tem = rtx_alloc (CONST_DOUBLE);
+       union real_extract u;
+
+       /* Zero any holes in a structure.  */
+       memset ((char *) &u, 0, sizeof u);
+       u.d = dconst0;
+
+       /* Avoid trailing garbage in the rtx.  */
+       if (sizeof (u) < sizeof (HOST_WIDE_INT))
+ 	CONST_DOUBLE_LOW (tem) = 0;
+       if (sizeof (u) < 2 * sizeof (HOST_WIDE_INT))
+ 	CONST_DOUBLE_HIGH (tem) = 0;
+
+       memcpy (&CONST_DOUBLE_LOW (tem), &u, sizeof u);
+       CONST_DOUBLE_CHAIN (tem) = NULL_RTX;
+       PUT_MODE (tem, mode);
+
+       const_tiny_rtx[0][(int) mode] = tem;
+     }
+
     for (i = (int) CCmode; i < (int) MAX_MACHINE_MODE; ++i)
       if (GET_MODE_CLASS ((enum machine_mode) i) == MODE_CC)
         const_tiny_rtx[0][i] = const0_rtx;



More information about the Gcc-patches mailing list