* [PATCH] Disallow bitwise operations (&, ^, and |) on vector float types (PR 30428)
@ 2007-08-14 0:37 Andrew Pinski
2007-08-14 5:39 ` Ian Lance Taylor
0 siblings, 1 reply; 2+ messages in thread
From: Andrew Pinski @ 2007-08-14 0:37 UTC (permalink / raw)
To: GCC Patches
[-- Attachment #1: Type: text/plain, Size: 795 bytes --]
Hi,
Currently both the C and C++ allow binary bitwise operations on the
vector float types. This does not make sense as the standard does not
allow it for floating point types, vector types should follow what is
allowed for the base types also.
This patch disallows binary bitwise operations on vector float types
like what is done for floating point types.
OK? Bootstrapped and tested on i386-apple-darwin8.10 with no regressions.
Thanks,
Andrew Pinski
ChangeLog:
* c-typeck.c (build_binary_op): Disallow vector float types with
BIT_IOR_EXPR, BIT_AND_EXPR, and BIT_XOR_EXPR.
cp/ChangeLog:
* typeck.c (build_binary_op): Disallow vector float types with
BIT_IOR_EXPR, BIT_AND_EXPR, and BIT_XOR_EXPR.
testsuite/ChangeLog:
* gcc.dg/vector-2.c: New test.
* g++.dg/ext/vector8.C: New test.
[-- Attachment #2: fixpr30428.diff.txt --]
[-- Type: text/plain, Size: 2429 bytes --]
Index: testsuite/gcc.dg/vector-2.c
===================================================================
--- testsuite/gcc.dg/vector-2.c (revision 0)
+++ testsuite/gcc.dg/vector-2.c (revision 0)
@@ -0,0 +1,21 @@
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+/* Check for application of |, ^, and & on vector types. */
+#define vector __attribute__((vector_size(16) ))
+
+vector float a;
+vector int a1;
+vector float b;
+vector int b1;
+
+int f(void)
+{
+ a = a | b; /* { dg-error "" } */
+ a = a & b; /* { dg-error "" } */
+ a = a ^ b; /* { dg-error "" } */
+ a1 = a1 | b1;
+ a1 = a1 & b1;
+ a1 = a1 ^ b1;
+}
+
Index: testsuite/g++.dg/ext/vector8.C
===================================================================
--- testsuite/g++.dg/ext/vector8.C (revision 0)
+++ testsuite/g++.dg/ext/vector8.C (revision 0)
@@ -0,0 +1,21 @@
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+/* Check for application of |, ^, and & on vector types. */
+#define vector __attribute__((vector_size(16) ))
+
+vector float a;
+vector int a1;
+vector float b;
+vector int b1;
+
+int f(void)
+{
+ a = a | b; /* { dg-error "" } */
+ a = a & b; /* { dg-error "" } */
+ a = a ^ b; /* { dg-error "" } */
+ a1 = a1 | b1;
+ a1 = a1 & b1;
+ a1 = a1 ^ b1;
+}
+
Index: cp/typeck.c
===================================================================
--- cp/typeck.c (revision 127395)
+++ cp/typeck.c (working copy)
@@ -3214,7 +3214,9 @@ build_binary_op (enum tree_code code, tr
case BIT_IOR_EXPR:
case BIT_XOR_EXPR:
if ((code0 == INTEGER_TYPE && code1 == INTEGER_TYPE)
- || (code0 == VECTOR_TYPE && code1 == VECTOR_TYPE))
+ || (code0 == VECTOR_TYPE && code1 == VECTOR_TYPE
+ && !VECTOR_FLOAT_TYPE_P (type0)
+ && !VECTOR_FLOAT_TYPE_P (type1)))
shorten = -1;
break;
Index: c-typeck.c
===================================================================
--- c-typeck.c (revision 127396)
+++ c-typeck.c (working copy)
@@ -7892,7 +7892,11 @@ build_binary_op (enum tree_code code, tr
case BIT_XOR_EXPR:
if (code0 == INTEGER_TYPE && code1 == INTEGER_TYPE)
shorten = -1;
- else if (code0 == VECTOR_TYPE && code1 == VECTOR_TYPE)
+ /* Allow vector types which are not floating point types. */
+ else if (code0 == VECTOR_TYPE
+ && code1 == VECTOR_TYPE
+ && !VECTOR_FLOAT_TYPE_P (type0)
+ && !VECTOR_FLOAT_TYPE_P (type1))
common = 1;
break;
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Disallow bitwise operations (&, ^, and |) on vector float types (PR 30428)
2007-08-14 0:37 [PATCH] Disallow bitwise operations (&, ^, and |) on vector float types (PR 30428) Andrew Pinski
@ 2007-08-14 5:39 ` Ian Lance Taylor
0 siblings, 0 replies; 2+ messages in thread
From: Ian Lance Taylor @ 2007-08-14 5:39 UTC (permalink / raw)
To: Andrew Pinski; +Cc: GCC Patches
"Andrew Pinski" <pinskia@gmail.com> writes:
> ChangeLog:
> * c-typeck.c (build_binary_op): Disallow vector float types with
> BIT_IOR_EXPR, BIT_AND_EXPR, and BIT_XOR_EXPR.
>
> cp/ChangeLog:
> * typeck.c (build_binary_op): Disallow vector float types with
> BIT_IOR_EXPR, BIT_AND_EXPR, and BIT_XOR_EXPR.
>
> testsuite/ChangeLog:
> * gcc.dg/vector-2.c: New test.
> * g++.dg/ext/vector8.C: New test.
This is OK.
Thanks.
Ian
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-08-14 5:39 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-14 0:37 [PATCH] Disallow bitwise operations (&, ^, and |) on vector float types (PR 30428) Andrew Pinski
2007-08-14 5:39 ` Ian Lance Taylor
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).