This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [C++] Handle && || ! for simd vectors


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]