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
This commit is contained in:
Andrew Pinski 2009-05-19 23:14:10 +00:00 committed by Andrew Pinski
parent dae279f018
commit 5cfd5d9b8f
9 changed files with 49 additions and 4 deletions

View File

@ -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

View File

@ -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

View File

@ -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.

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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;
}

View File

@ -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;

View File

@ -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;
}