This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [C++] Handle && || ! for simd vectors
- From: Marc Glisse <marc dot glisse at inria dot fr>
- To: Jason Merrill <jason at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Sat, 4 Oct 2014 01:49:30 +0200 (CEST)
- Subject: Re: [C++] Handle && || ! for simd vectors
- Authentication-results: sourceware.org; auth=none
- References: <alpine dot DEB dot 2 dot 02 dot 1408171502350 dot 13887 at stedding dot saclay dot inria dot fr> <542D95C2 dot 10608 at redhat dot com>
On Thu, 2 Oct 2014, Jason Merrill wrote:
OK.
Thanks. While committing, I noticed that I restricted ! to integer
vectors, whereas it seems to work just fine with scalar floats, so it
would make sense to extend it to float vectors. Tested on
x86_64-linux-gnu.
2014-10-04 Marc Glisse <marc.glisse@inria.fr>
gcc/cp/
* typeck.c (cp_build_unary_op) [TRUTH_NOT_EXPR]: Accept float vectors.
gcc/testsuite/
* g++.dg/ext/vector9.C: Test ! with float vectors.
--
Marc Glisse
Index: gcc/cp/typeck.c
===================================================================
--- gcc/cp/typeck.c (revision 215876)
+++ gcc/cp/typeck.c (working copy)
@@ -5716,21 +5716,21 @@ cp_build_unary_op (enum tree_code code,
errstring = _("wrong type argument to conjugation");
else if (!noconvert)
{
arg = cp_default_conversion (arg, complain);
if (arg == error_mark_node)
return error_mark_node;
}
break;
case TRUTH_NOT_EXPR:
- if (VECTOR_INTEGER_TYPE_P (TREE_TYPE (arg)))
+ if (VECTOR_TYPE_P (TREE_TYPE (arg)))
return cp_build_binary_op (input_location, EQ_EXPR, arg,
build_zero_cst (TREE_TYPE (arg)), complain);
arg = perform_implicit_conversion (boolean_type_node, arg,
complain);
val = invert_truthvalue_loc (input_location, arg);
if (arg != error_mark_node)
return val;
errstring = _("in argument to unary !");
break;
Index: gcc/testsuite/g++.dg/ext/vector9.C
===================================================================
--- gcc/testsuite/g++.dg/ext/vector9.C (revision 215876)
+++ gcc/testsuite/g++.dg/ext/vector9.C (working copy)
@@ -1,10 +1,11 @@
// PR c++/34891
typedef float v4f __attribute__((vector_size(8)));
typedef int v4i __attribute__((vector_size(8)));
void foo()
{
v4f v;
!(v4i)v;
+ !v;
}