diff options
author | Andrew Pinski <andrew_pinski@playstation.sony.com> | 2009-05-19 23:14:10 +0000 |
---|---|---|
committer | Andrew Pinski <pinskia@gcc.gnu.org> | 2009-05-19 16:14:10 -0700 |
commit | 5cfd5d9b8f7885b1010c829e1062dd2ff0fecdf1 (patch) | |
tree | b8154d36e2f96a8f40d569b0ad6bf21baf23422d /gcc | |
parent | dae279f018e31acdf2b50acff91b416b5b97645e (diff) | |
download | gcc-5cfd5d9b8f7885b1010c829e1062dd2ff0fecdf1.zip gcc-5cfd5d9b8f7885b1010c829e1062dd2ff0fecdf1.tar.gz gcc-5cfd5d9b8f7885b1010c829e1062dd2ff0fecdf1.tar.bz2 |
c-typeck.c (build_binary_op): Allow % on integal vectors.
2009-05-19 Andrew Pinski <andrew_pinski@playstation.sony.com>
* c-typeck.c (build_binary_op): Allow % on integal vectors.
* doc/extend.texi (Vector Extension): Document that % is allowed too.
009-05-19 Andrew Pinski <andrew_pinski@playstation.sony.com>
* typeck.c (build_binary_op): Allow % on integal vectors.
2009-05-19 Andrew Pinski <andrew_pinski@playstation.sony.com>
* gcc.dg/vector-4.c: New testcase.
* gcc.dg/simd-1b.c: % is now allowed for integer vectors.
* g++.dg/ext/vector16.C: New testcase.
From-SVN: r147722
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/c-typeck.c | 6 | ||||
-rw-r--r-- | gcc/cp/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/cp/typeck.c | 6 | ||||
-rw-r--r-- | gcc/doc/extend.texi | 2 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/ext/vector16.C | 11 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/simd-1b.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/vector-4.c | 11 |
9 files changed, 49 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 0fff6f8..698537f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2009-05-19 Andrew Pinski <andrew_pinski@playstation.sony.com> + + * c-typeck.c (build_binary_op): Allow % on integal vectors. + * doc/extend.texi (Vector Extension): Document that % is allowed too. + 2009-05-19 H.J. Lu <hongjiu.lu@intel.com> * config/i386/i386.c (ix86_avoid_jump_mispredicts): Check diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index 62b5ee9..ee1853a 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -8988,7 +8988,11 @@ build_binary_op (location_t location, enum tree_code code, case FLOOR_MOD_EXPR: warn_for_div_by_zero (location, op1); - if (code0 == INTEGER_TYPE && code1 == INTEGER_TYPE) + if (code0 == VECTOR_TYPE && code1 == VECTOR_TYPE + && TREE_CODE (TREE_TYPE (type0)) == INTEGER_TYPE + && TREE_CODE (TREE_TYPE (type1)) == INTEGER_TYPE) + common = 1; + else if (code0 == INTEGER_TYPE && code1 == INTEGER_TYPE) { /* Although it would be tempting to shorten always here, that loses on some targets, since the modulo instruction is undefined if the diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 813413e7..bd81af6 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,7 @@ +2009-05-19 Andrew Pinski <andrew_pinski@playstation.sony.com> + + * typeck.c (build_binary_op): Allow % on integal vectors. + 2009-05-18 Jason Merrill <jason@redhat.com> Implement explicit conversions ops as specified in N2437. diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 66472ee..a5f3618 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -3492,7 +3492,11 @@ cp_build_binary_op (location_t location, case FLOOR_MOD_EXPR: warn_for_div_by_zero (location, op1); - if (code0 == INTEGER_TYPE && code1 == INTEGER_TYPE) + if (code0 == VECTOR_TYPE && code1 == VECTOR_TYPE + && TREE_CODE (TREE_TYPE (type0)) == INTEGER_TYPE + && TREE_CODE (TREE_TYPE (type1)) == INTEGER_TYPE) + common = 1; + else if (code0 == INTEGER_TYPE && code1 == INTEGER_TYPE) { /* Although it would be tempting to shorten always here, that loses on some targets, since the modulo instruction is undefined if the diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index 6b626e2..98df9d5 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi @@ -5746,7 +5746,7 @@ produce code that uses 4 @code{SIs}. The types defined in this manner can be used with a subset of normal C operations. Currently, GCC will allow using the following operators -on these types: @code{+, -, *, /, unary minus, ^, |, &, ~}@. +on these types: @code{+, -, *, /, unary minus, ^, |, &, ~, %}@. The operations behave like C++ @code{valarrays}. Addition is defined as the addition of the corresponding elements of the operands. For diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d326755..df16058 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2009-05-19 Andrew Pinski <andrew_pinski@playstation.sony.com> + + * gcc.dg/vector-4.c: New testcase. + * gcc.dg/simd-1b.c: % is now allowed for integer vectors. + * g++.dg/ext/vector16.C: New testcase. + 2009-05-19 H.J. Lu <hongjiu.lu@intel.com> PR c/40172 diff --git a/gcc/testsuite/g++.dg/ext/vector16.C b/gcc/testsuite/g++.dg/ext/vector16.C new file mode 100644 index 0000000..7964a88 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/vector16.C @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +#define vector __attribute__((vector_size(4*sizeof(int)) )) + +vector int a, b, c; + + +/* Test that remainder works for vectors. */ +void f(void) +{ + a = b % c; +} diff --git a/gcc/testsuite/gcc.dg/simd-1b.c b/gcc/testsuite/gcc.dg/simd-1b.c index 56d94b9..1e2b597 100644 --- a/gcc/testsuite/gcc.dg/simd-1b.c +++ b/gcc/testsuite/gcc.dg/simd-1b.c @@ -14,7 +14,7 @@ void hanneke () { /* Operators on compatible SIMD types. */ - a %= b; /* { dg-error "invalid operands to binary %" } */ + a %= b; c &= d; a |= b; c ^= d; diff --git a/gcc/testsuite/gcc.dg/vector-4.c b/gcc/testsuite/gcc.dg/vector-4.c new file mode 100644 index 0000000..7964a88 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vector-4.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +#define vector __attribute__((vector_size(4*sizeof(int)) )) + +vector int a, b, c; + + +/* Test that remainder works for vectors. */ +void f(void) +{ + a = b % c; +} |