public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* allow unary plus to be used with vector types
@ 2004-07-07 12:18 Jan Beulich
  2004-07-10  0:01 ` Richard Henderson
  0 siblings, 1 reply; 2+ messages in thread
From: Jan Beulich @ 2004-07-07 12:18 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 4797 bytes --]

bootstrapped and tested on x86_64-unknown-linux-gnu.

2004-07-07 Jan Beulich <jbeulich@novell.com>

	* c-typeck.c (build_unary_op): include VECTOR_TYPE in set of
codes
	permissible for unary plus.

testsuite:
2004-07-07 Jan Beulich <jbeulich@novell.com>

	* gcc.dg/simd-1b.c, gcc.dg/simd-2.c: New tests (to complement
	gcc.dg/simd-1.c).

---
/home/jbeulich/src/gcc/mainline/2004-07-05.10.09/gcc/c-typeck.c	2004-07-05
09:18:02.000000000 +0200
+++ 2004-07-05.10.09/gcc/c-typeck.c	2004-07-06 17:44:04.873675360
+0200
@@ -2303,7 +2303,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;
---
/home/jbeulich/src/gcc/mainline/2004-07-05.10.09/gcc/testsuite/gcc.dg/simd-1b.c	1970-01-01
01:00:00.000000000 +0100
+++ 2004-07-05.10.09/gcc/testsuite/gcc.dg/simd-1b.c	2004-07-07
10:24:08.708705896 +0200
@@ -0,0 +1,36 @@
+/* { dg-do compile } */
+/* { dg-options "-Wall" } */
+
+/* Origin: Aldy Hernandez <aldyh@redhat.com>.  */
+/* Purpose: Program to test generic SIMD support.  */
+
+typedef int __attribute__((mode (SI), vector_size (16))) v4si;
+typedef int __attribute__((mode (SI), vector_size (8))) v2si;
+
+v4si a, b;
+v2si c, d;
+
+void
+hanneke ()
+{
+  /* Operators on compatible SIMD types.  */
+  a %= b; /* { dg-bogus "invalid operands to binary %" "" { xfail
*-*-* } } */
+  c &= d;
+  a |= b;
+  c ^= d;
+  a >>= b; /* { dg-bogus "invalid operands to binary >>" "" { xfail
*-*-* } } */
+  c <<= d; /* { dg-bogus "invalid operands to binary <<" "" { xfail
*-*-* } } */
+  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-bogus "invalid operands to binary %" "" { xfail
*-*-* } } */
+  d = c & b; /* { 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" } */
+  d = c ^ b; /* { 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-bogus "invalid operands to binary >>" "" { xfail
*-*-* } } */
+/*  d = c << b;  { dg*error "can't convert between vector values of
different size" } */
+  d = c << b; /* { dg-bogus "invalid operands to binary <<" "" { xfail
*-*-* } } */
+}
---
/home/jbeulich/src/gcc/mainline/2004-07-05.10.09/gcc/testsuite/gcc.dg/simd-2.c	1970-01-01
01:00:00.000000000 +0100
+++ 2004-07-05.10.09/gcc/testsuite/gcc.dg/simd-2.c	2004-07-07
10:26:09.543336240 +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(SF), vector_size(8))) v2sf;
+typedef float __attribute__((mode(DF), vector_size(16))) v2df;
+typedef float __attribute__((mode(SF), vector_size(16))) v4sf;
+
+v4sf a, b;
+v2sf c, d;
+v2df e;
+
+float foo __attribute__((mode(DF)));
+float foo1 __attribute__((mode(SF)));
+v2sf foo2;
+
+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*error "can't convert between
vector values of different size" } */
+  foo1 = (typeof (foo1)) foo2; /* { dg-bogus "aggregate value used
where a float was expected" "" { xfail *-*-* } } */
+
+  /* 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" } */
+}


[-- Attachment #2: gcc-mainline-vector-unary-plus.patch --]
[-- Type: application/octet-stream, Size: 4742 bytes --]

2004-07-07 Jan Beulich <jbeulich@novell.com>

	* c-typeck.c (build_unary_op): include VECTOR_TYPE in set of codes
	permissible for unary plus.

testsuite:
2004-07-07 Jan Beulich <jbeulich@novell.com>

	* gcc.dg/simd-1b.c, gcc.dg/simd-2.c: New tests (to complement
	gcc.dg/simd-1.c).

--- /home/jbeulich/src/gcc/mainline/2004-07-05.10.09/gcc/c-typeck.c	2004-07-05 09:18:02.000000000 +0200
+++ 2004-07-05.10.09/gcc/c-typeck.c	2004-07-06 17:44:04.873675360 +0200
@@ -2303,7 +2303,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;
--- /home/jbeulich/src/gcc/mainline/2004-07-05.10.09/gcc/testsuite/gcc.dg/simd-1b.c	1970-01-01 01:00:00.000000000 +0100
+++ 2004-07-05.10.09/gcc/testsuite/gcc.dg/simd-1b.c	2004-07-07 10:24:08.708705896 +0200
@@ -0,0 +1,36 @@
+/* { dg-do compile } */
+/* { dg-options "-Wall" } */
+
+/* Origin: Aldy Hernandez <aldyh@redhat.com>.  */
+/* Purpose: Program to test generic SIMD support.  */
+
+typedef int __attribute__((mode (SI), vector_size (16))) v4si;
+typedef int __attribute__((mode (SI), vector_size (8))) v2si;
+
+v4si a, b;
+v2si c, d;
+
+void
+hanneke ()
+{
+  /* Operators on compatible SIMD types.  */
+  a %= b; /* { dg-bogus "invalid operands to binary %" "" { xfail *-*-* } } */
+  c &= d;
+  a |= b;
+  c ^= d;
+  a >>= b; /* { dg-bogus "invalid operands to binary >>" "" { xfail *-*-* } } */
+  c <<= d; /* { dg-bogus "invalid operands to binary <<" "" { xfail *-*-* } } */
+  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-bogus "invalid operands to binary %" "" { xfail *-*-* } } */
+  d = c & b; /* { 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" } */
+  d = c ^ b; /* { 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-bogus "invalid operands to binary >>" "" { xfail *-*-* } } */
+/*  d = c << b;  { dg*error "can't convert between vector values of different size" } */
+  d = c << b; /* { dg-bogus "invalid operands to binary <<" "" { xfail *-*-* } } */
+}
--- /home/jbeulich/src/gcc/mainline/2004-07-05.10.09/gcc/testsuite/gcc.dg/simd-2.c	1970-01-01 01:00:00.000000000 +0100
+++ 2004-07-05.10.09/gcc/testsuite/gcc.dg/simd-2.c	2004-07-07 10:26:09.543336240 +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(SF), vector_size(8))) v2sf;
+typedef float __attribute__((mode(DF), vector_size(16))) v2df;
+typedef float __attribute__((mode(SF), vector_size(16))) v4sf;
+
+v4sf a, b;
+v2sf c, d;
+v2df e;
+
+float foo __attribute__((mode(DF)));
+float foo1 __attribute__((mode(SF)));
+v2sf foo2;
+
+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*error "can't convert between vector values of different size" } */
+  foo1 = (typeof (foo1)) foo2; /* { dg-bogus "aggregate value used where a float was expected" "" { xfail *-*-* } } */
+
+  /* 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" } */
+}

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: allow unary plus to be used with vector types
  2004-07-07 12:18 allow unary plus to be used with vector types Jan Beulich
@ 2004-07-10  0:01 ` Richard Henderson
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Henderson @ 2004-07-10  0:01 UTC (permalink / raw)
  To: Jan Beulich; +Cc: gcc-patches

On Wed, Jul 07, 2004 at 02:13:44PM +0200, Jan Beulich wrote:
> 	* c-typeck.c (build_unary_op): include VECTOR_TYPE in set of codes
> 	permissible for unary plus.

Applied.


r~

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-07-09 23:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-07-07 12:18 allow unary plus to be used with vector types Jan Beulich
2004-07-10  0:01 ` Richard Henderson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).