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]

[PATCH, C++, PR70290] Fix type checks for vector conditional expr


Hi,

This patch makes an integer vector type to always be used for
type checks when building a vector conditional expression.
With no this patch we may get a type of vector comparison
which may have non-vector mode and different size in case
of scalar masks usage.

Bootstrapped and regetsted on x86_64-pc-linux-gnu.  OK for trunk?

Thanks,
Ilya
--
gcc/cp/

2016-03-21  Ilya Enkovich  <enkovich.gnu@gmail.com>

	* call.c (build_conditional_expr_1): Always use original
	condition type for vector type checks and build.

gcc/testsuite/

2016-03-21  Ilya Enkovich  <enkovich.gnu@gmail.com>

	* g++.dg/ext/pr70290.C: New test.


diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 1edbce8..d3a256c 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -4634,6 +4634,8 @@ build_conditional_expr_1 (location_t loc, tree arg1, tree arg2, tree arg3,
 
   if (VECTOR_INTEGER_TYPE_P (TREE_TYPE (arg1)))
     {
+      tree arg1_type = TREE_TYPE (arg1);
+
       /* If arg1 is another cond_expr choosing between -1 and 0,
 	 then we can use its comparison.  It may help to avoid
 	 additional comparison, produce more accurate diagnostics
@@ -4653,7 +4655,6 @@ build_conditional_expr_1 (location_t loc, tree arg1, tree arg2, tree arg3,
 	  || error_operand_p (arg3))
 	return error_mark_node;
 
-      tree arg1_type = TREE_TYPE (arg1);
       arg2_type = TREE_TYPE (arg2);
       arg3_type = TREE_TYPE (arg3);
 
diff --git a/gcc/testsuite/g++.dg/ext/pr70290.C b/gcc/testsuite/g++.dg/ext/pr70290.C
new file mode 100644
index 0000000..6de13ce
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/pr70290.C
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-mavx512vl" { target { i?86-*-* x86_64-*-* } } } */
+
+typedef int vec __attribute__((vector_size(32)));
+
+vec
+test1 (vec x,vec y)
+{
+  return (x < y) ? 1 : 0;
+}
+
+vec
+test2 (vec x,vec y)
+{
+  vec zero = { };
+  vec one = zero + 1;
+  return (x < y) ? one : zero;
+}


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