From 8a2cee381065db182be6e18124193cc348b6b937 Mon Sep 17 00:00:00 2001 From: Jan Beulich Date: Fri, 9 Jul 2004 23:20:36 +0000 Subject: [PATCH] c-typeck.c (build_unary_op): include VECTOR_TYPE in set of codes permissible for unary plus. * c-typeck.c (build_unary_op): include VECTOR_TYPE in set of codes permissible for unary plus. From-SVN: r84417 --- gcc/ChangeLog | 5 ++++ gcc/c-typeck.c | 3 +- gcc/testsuite/gcc.dg/simd-1.c | 4 +-- gcc/testsuite/gcc.dg/simd-1b.c | 36 ++++++++++++++++++++++ gcc/testsuite/gcc.dg/simd-2.c | 55 ++++++++++++++++++++++++++++++++++ 5 files changed, 100 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/simd-1b.c create mode 100644 gcc/testsuite/gcc.dg/simd-2.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3c59958f24d..4e049420392 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -4,6 +4,11 @@ * config/ia64/ia64.c (ia64_function_arg): For a single element HFA, do return a parallel if hfa_mode == XFmode and mode == TImode. +2004-07-09 Jan Beulich + + * c-typeck.c (build_unary_op): include VECTOR_TYPE in set of codes + permissible for unary plus. + 2004-07-09 Jan Beulich * builtin-types.def (BT_UINT): Rename from BT_UNSIGNED. diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index ca2e6df793e..2c6df142597 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -2303,7 +2303,8 @@ build_unary_op (enum tree_code code, tree xarg, int flag) 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; diff --git a/gcc/testsuite/gcc.dg/simd-1.c b/gcc/testsuite/gcc.dg/simd-1.c index 43e63e4a40e..e36c5beec5c 100644 --- a/gcc/testsuite/gcc.dg/simd-1.c +++ b/gcc/testsuite/gcc.dg/simd-1.c @@ -14,8 +14,8 @@ v2si c, d; v8hi e; uv4si f; -int foo __attribute__((mode(DI))); -int foo1 __attribute__((mode(SI))); +long long foo; +int foo1; short foo2 __attribute__((vector_size (8))); void diff --git a/gcc/testsuite/gcc.dg/simd-1b.c b/gcc/testsuite/gcc.dg/simd-1b.c new file mode 100644 index 00000000000..d40fb0469ca --- /dev/null +++ b/gcc/testsuite/gcc.dg/simd-1b.c @@ -0,0 +1,36 @@ +/* { dg-do compile } */ +/* { dg-options "-Wall" } */ + +/* Origin: Aldy Hernandez . */ +/* Purpose: Program to test generic SIMD support. */ + +typedef int __attribute__((vector_size (16))) v4si; +typedef int __attribute__((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 *-*-* } } */ +} diff --git a/gcc/testsuite/gcc.dg/simd-2.c b/gcc/testsuite/gcc.dg/simd-2.c new file mode 100644 index 00000000000..20d4a07d46c --- /dev/null +++ b/gcc/testsuite/gcc.dg/simd-2.c @@ -0,0 +1,55 @@ +/* { dg-do compile } */ +/* { dg-options "-Wall" } */ + +/* Origin: Aldy Hernandez . */ +/* Purpose: Program to test generic SIMD support. */ + +typedef float __attribute__((vector_size(8))) v2sf; +typedef float __attribute__((vector_size(16))) v4sf; +typedef double __attribute__((vector_size(16))) v2df; + +v4sf a, b; +v2sf c, d; +v2df e; + +double foo; +float foo1; +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" } */ +} -- 2.30.2