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]

permit unary plus to be used with vector types


Up to 3.4.0, applying a unary plus to a vector type is rejected; here is
the one line fix for this. I am not aware of an exisiting bug number for
this. Adjusted one of the exisiting test cases to check for this, also
created a second similar one for basic floating point vector testing.
The additions uncover a couple of other issues which, since I don't know
how to better deal with them, I made expected failures.

Bootstrapped and "make check"-ed on i686-pc-linux-gnu.

Jan

--- /usr/local/src/gcc-3.4.0/gcc/c-typeck.c	2004-03-31
02:24:49.000000000 +0200
+++ 3.4.0/gcc/c-typeck.c	2004-05-12 10:08:35.000000000 +0200
@@ -2194,7 +2202,8 @@
 	 is enough to prevent anybody from looking inside for
 	 associativity, but won't generate any code.  */
       if (!(typecode == INTEGER_TYPE || typecode == REAL_TYPE
-	    || typecode == COMPLEX_TYPE))
+	    || typecode == COMPLEX_TYPE
+	    || typecode == VECTOR_TYPE))
 	{
 	  error ("wrong type argument to unary plus");
 	  return error_mark_node;
---
/usr/local/src/gcc-3.4.0/gcc/testsuite/gcc.dg/simd-1.c	2002-06-18
03:35:39.000000000 +0200
+++ 3.4.0/gcc/testsuite/gcc.dg/simd-1.c	2004-05-24
14:25:32.000000000 +0200
@@ -51,7 +51,15 @@
   a -= b;
   a *= b;
   a /= b;
-  a = -b;
+  a %= b; /* { dg-bogus "invalid operands to binary %" "" { xfail
*-*-* } } */
+  a &= b;
+  a |= b;
+  a ^= b;
+  a >>= b; /* { dg-bogus "invalid operands to binary >>" "" { xfail
*-*-* } } */
+  a <<= b; /* { dg-bogus "invalid operands to binary <<" "" { xfail
*-*-* } } */
+  a = +b;
+  c = -d;
+  b = ~a;
 
   /* Operators on incompatible SIMD types.  */
   a = b + c; /* { dg-error "can't convert between vector values of
different size" } */
---
/usr/local/src/gcc-3.4.0/gcc/testsuite/gcc.dg/simd-2.c	1970-01-01
01:00:00.000000000 +0100
+++ 3.4.0/gcc/testsuite/gcc.dg/simd-2.c	2004-05-24
14:32:35.000000000 +0200
@@ -0,0 +1,55 @@
+/* { dg-do compile } */
+/* { dg-options "-Wall" } */
+
+/* Origin: Aldy Hernandez <aldyh@redhat.com>.  */
+/* Purpose: Program to test generic SIMD support.  */
+
+typedef float __attribute__((mode(V2SF))) v2sf;
+typedef float __attribute__((mode(V2DF))) v2df;
+typedef float __attribute__((mode(V4SF))) v4sf;
+
+v4sf a, b;
+v2sf c, d;
+v2df e;
+
+float foo __attribute__((mode(DF)));
+float foo1 __attribute__((mode(SF)));
+float foo2 __attribute__((mode(V4DF)));
+
+void
+hanneke ()
+{
+  /* Assignment.  */
+  a = b;
+
+  /* Assignment of different types.  */
+  b = c; /* { dg-error "incompatible types in assignment" } */
+  d = a; /* { dg-error "incompatible types in assignment" } */
+
+  /* Casting between SIMDs of the same size.  */
+  e = (typeof (e)) a;
+
+  /* Assignment between scalar and SIMD of different size.  */
+  foo = a; /* { dg-error "incompatible types in assignment" } */
+
+  /* Casted assignment between scalar and SIMD of same size.  */
+  foo = (typeof (foo)) foo2; /* { dg-bogus "aggregate value used where
a float was expected" "" { xfail *-*-* } } */
+
+  /* Casted assignment between scalar and SIMD of different size.  */
+  foo1 = (typeof (foo1)) foo2; /* { dg-bogus "aggregate value used
where a float was expected" "" { xfail *-*-* } } */
+/*foo1 = (typeof (foo1)) foo2;    { *dg-error "can't convert between
vector values of different size" } */
+
+  /* Operators on compatible SIMD types.  */
+  a += b + b;
+  a -= b;
+  a *= b;
+  a /= b;
+  a = +b;
+  c = -d;
+
+  /* Operators on incompatible SIMD types.  */
+  a = b + c; /* { dg-error "can't convert between vector values of
different size" } */
+  a = b - c; /* { dg-error "can't convert between vector values of
different size" } */
+  a = b * c; /* { dg-error "can't convert between vector values of
different size" } */
+  a = b / c; /* { dg-error "can't convert between vector values of
different size" } */
+}


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