This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
patch + rfc: clear_storage() and vectors
- From: Aldy Hernandez <aldyh at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 14 Feb 2002 14:15:55 +1100
- Subject: patch + rfc: clear_storage() and vectors
hi guys.
clear_storage cannot handle vector registers because we do not
have CONST0_RTXs defined for vector modes. 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 have added a big comment to clear_storage() explaining more.
so for:
vector int foo = (vector int){0,0,0,0};
we load the vector, element wise which is not ideal at all.
ideally for constructors, we should see if we have a vector clear
instruction, use it, otherwise load elementwise.
i'm seeing lots of infrastructure missing around here...
ok?
2002-02-14 Aldy Hernandez <aldyh@redhat.com>
* expr.c (store_constructor): Do not call clear_storage for vector
registers.
(clear_storage): Abort if we get a vector register.
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/14 03:14:41
*************** clear_storage (object, size)
*** 2560,2565 ****
--- 2560,2581 ----
unsigned int align = (GET_CODE (object) == MEM ? MEM_ALIGN (object)
: GET_MODE_ALIGNMENT (GET_MODE (object)));
+ /* We should not be called with vector registers because we
+ have no CONST0_RTXs defined for the vector modes. Perhaps
+ we should, but then we'd have to make sure that every vector
+ port has a corresponding:
+
+ (set (reg:VECMODE 999)
+ (const_int 0))
+
+ for ever vector mode. I don't know whether every SIMD
+ implementation has a way of clearing a vector register (?).
+
+ We can only abort, otherwise we either try to use a nonexistant
+ CONST0_RTX for a vector, or attempt to bzero/memset a register. */
+ if (GET_CODE (object) == REG && VECTOR_MODE_P (GET_MODE (object)))
+ abort ();
+
/* 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
*************** store_constructor (exp, target, cleared,
*** 4614,4620 ****
need_to_clear = 1;
}
! if (need_to_clear && size > 0)
{
if (! cleared)
clear_storage (target, GEN_INT (size));
--- 4630,4641 ----
need_to_clear = 1;
}
! if (need_to_clear && size > 0
! /* The function clear_storage() cannot handle vector
! registers, so punt below and fill each element. See note
! in clear_storage(). */
! && (GET_CODE (target) != REG ||
! !VECTOR_MODE_P (GET_MODE (target))))
{
if (! cleared)
clear_storage (target, GEN_INT (size));