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]
Other format: [Raw text]

patch: handle vector constants in arrays


Pretty obvious. Fixes the test below, which is currently aborting.

This (as well as the last patch for which I forgot to mention) was bootstrapped and regtested on x86, and was regtested on a cross powerpc-eabispe toolchain.

Ok for mainline and e500 branch?

2003-05-05 Aldy Hernandez <aldyh@redhat.com>

* testsuite/gcc.c-torture/compile/simd-6.c: New.

* c-typeck.c (digest_init): Handle arrays of vector constants.

Index: testsuite/gcc.c-torture/compile/simd-6.c
===================================================================
RCS file: testsuite/gcc.c-torture/compile/simd-6.c
diff -N testsuite/gcc.c-torture/compile/simd-6.c
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/gcc.c-torture/compile/simd-6.c	5 May 2003 18:40:43 -0000
***************
*** 0 ****
--- 1,3 ----
+ typedef int __attribute__((mode(V2SI))) vec;
+
+ vec a[] = {(vec) {1, 2}, {3, 4}};
Index: c-typeck.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-typeck.c,v
retrieving revision 1.236
diff -c -p -r1.236 c-typeck.c
*** c-typeck.c	3 May 2003 21:44:25 -0000	1.236
--- c-typeck.c	5 May 2003 18:40:44 -0000
*************** digest_init (type, init, require_constan
*** 4779,4788 ****
    /* Build a VECTOR_CST from a *constant* vector constructor.  If the
       vector constructor is not constant (e.g. {1,2,3,foo()}) then punt
       below and handle as a constructor.  */
!   if (code == VECTOR_TYPE
!       && comptypes (TREE_TYPE (inside_init), type)
!       && TREE_CONSTANT (inside_init))
!     return build_vector (type, CONSTRUCTOR_ELTS (inside_init));

    /* Any type can be initialized
       from an expression of the same type, optionally with braces.  */
--- 4787,4803 ----
    /* Build a VECTOR_CST from a *constant* vector constructor.  If the
       vector constructor is not constant (e.g. {1,2,3,foo()}) then punt
       below and handle as a constructor.  */
!     if (code == VECTOR_TYPE
!         && comptypes (TREE_TYPE (inside_init), type)
!         && TREE_CONSTANT (inside_init))
!       {
! 	if (TREE_CODE (inside_init) == VECTOR_CST
! 	    && comptypes (TYPE_MAIN_VARIANT (TREE_TYPE (inside_init)),
! 			  TYPE_MAIN_VARIANT (type)))
! 	  return inside_init;
! 	else
! 	  return build_vector (type, CONSTRUCTOR_ELTS (inside_init));
!       }

    /* Any type can be initialized
       from an expression of the same type, optionally with braces.  */


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