tree-vect-stmts.c (vectorizable_mask_load_store): Check types of stored value and...
authorIlya Enkovich <enkovich.gnu@gmail.com>
Fri, 13 Nov 2015 06:50:18 +0000 (06:50 +0000)
committerIlya Enkovich <ienkovich@gcc.gnu.org>
Fri, 13 Nov 2015 06:50:18 +0000 (06:50 +0000)
gcc/

* tree-vect-stmts.c (vectorizable_mask_load_store): Check
types of stored value and storage are compatible.

gcc/testsuite/

* g++.dg/vect/simd-mask-store-bool.cc: New test.

From-SVN: r230289

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/vect/simd-mask-store-bool.cc [new file with mode: 0644]
gcc/tree-vect-stmts.c

index 8e472b02bf8a4351e202a31c0844f215d5c4a5f6..34afa9a9e8a7f5a22a605c4ed4b2a0f02a3ecada 100644 (file)
@@ -1,3 +1,8 @@
+2015-11-13  Ilya Enkovich  <enkovich.gnu@gmail.com>
+
+       * tree-vect-stmts.c (vectorizable_mask_load_store): Check
+       types of stored value and storage are compatible.
+
 2015-11-13  Andris Pavenis  <andris.pavenis@iki.fi>
 
        * gcc.c (POST_LINK_SPEC): Define if not already defined.
index 409020aaab9f5b5f21e7fb7f63c140aff67b1500..60b50873dab5f8bd3ddc3f1a7dff1754dbc869d6 100644 (file)
@@ -1,3 +1,7 @@
+2015-11-13  Ilya Enkovich  <enkovich.gnu@gmail.com>
+
+       * g++.dg/vect/simd-mask-store-bool.cc: New test.
+
 2015-11-13  David Malcolm  <dmalcolm@redhat.com>
 
        PR driver/67613
diff --git a/gcc/testsuite/g++.dg/vect/simd-mask-store-bool.cc b/gcc/testsuite/g++.dg/vect/simd-mask-store-bool.cc
new file mode 100644 (file)
index 0000000..c5f0458
--- /dev/null
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target vect_condition } */
+/* { dg-additional-options "-mavx512bw" { target { i?86-*-* x86_64-*-* } } } */
+
+#define N 1024
+
+int a[N], b[N], c[N];
+bool d[N];
+
+void
+test (void)
+{
+  int i;
+#pragma omp simd safelen(64)
+  for (i = 0; i < N; i++)
+    if (a[i] > 0)
+      d[i] = b[i] > c[i];
+}
index cfe30e067ea7f838eb1186e26edb0b1dbfdb17d8..7870b29eab55e5e6ef54483cf7fd8b08e0769ff9 100644 (file)
@@ -1688,6 +1688,7 @@ vectorizable_mask_load_store (gimple *stmt, gimple_stmt_iterator *gsi,
   bool nested_in_vect_loop = nested_in_vect_loop_p (loop, stmt);
   struct data_reference *dr = STMT_VINFO_DATA_REF (stmt_info);
   tree vectype = STMT_VINFO_VECTYPE (stmt_info);
+  tree rhs_vectype = NULL_TREE;
   tree mask_vectype;
   tree elem_type;
   gimple *new_stmt;
@@ -1757,6 +1758,13 @@ vectorizable_mask_load_store (gimple *stmt, gimple_stmt_iterator *gsi,
   if (!mask_vectype)
     return false;
 
+  if (is_store)
+    {
+      tree rhs = gimple_call_arg (stmt, 3);
+      if (!vect_is_simple_use (rhs, loop_vinfo, &def_stmt, &dt, &rhs_vectype))
+       return false;
+    }
+
   if (STMT_VINFO_GATHER_SCATTER_P (stmt_info))
     {
       gimple *def_stmt;
@@ -1790,16 +1798,11 @@ vectorizable_mask_load_store (gimple *stmt, gimple_stmt_iterator *gsi,
   else if (!VECTOR_MODE_P (TYPE_MODE (vectype))
           || !can_vec_mask_load_store_p (TYPE_MODE (vectype),
                                          TYPE_MODE (mask_vectype),
-                                         !is_store))
+                                         !is_store)
+          || (rhs_vectype
+              && !useless_type_conversion_p (vectype, rhs_vectype)))
     return false;
 
-  if (is_store)
-    {
-      tree rhs = gimple_call_arg (stmt, 3);
-      if (!vect_is_simple_use (rhs, loop_vinfo, &def_stmt, &dt))
-       return false;
-    }
-
   if (!vec_stmt) /* transformation not required.  */
     {
       STMT_VINFO_TYPE (stmt_info) = call_vec_info_type;