Add missing VECTOR_MODE_P checks (PR 92595)
authorRichard Sandiford <richard.sandiford@arm.com>
Thu, 21 Nov 2019 17:41:16 +0000 (17:41 +0000)
committerRichard Sandiford <rsandifo@gcc.gnu.org>
Thu, 21 Nov 2019 17:41:16 +0000 (17:41 +0000)
This patch fixes some cases in which we weren't checking whether we had
a vector mode before calling related_vector_mode or before making vector
optab queries.

2019-11-21  Richard Sandiford  <richard.sandiford@arm.com>

gcc/
PR tree-optimization/92595
* tree-vect-stmts.c (get_group_load_store_type): Add a VECTOR_MODE_P
check.
(vectorizable_store, vectorizable_load): Likewise.

gcc/testsuite/
PR tree-optimization/92595
* g++.dg/vect/pr92595.cc: New test.

From-SVN: r278590

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

index 2aa4a78f12d74190034795914a4be957c32e108b..859dd7136c7eca4cfe6664e8f03b07d25060b2e5 100644 (file)
@@ -1,3 +1,10 @@
+2019-11-21  Richard Sandiford  <richard.sandiford@arm.com>
+
+       PR tree-optimization/92595
+       * tree-vect-stmts.c (get_group_load_store_type): Add a VECTOR_MODE_P
+       check.
+       (vectorizable_store, vectorizable_load): Likewise.
+
 2019-11-21  Jan Hubicka  <jh@suse.cz>
 
        * ipa-inline.c (update_callee_keys): Add parameter UPDATE_SINCE.
index 1ae64a6a28d60d3f3dd5222a1c9c3f2b90df76bb..1f69d52fd1e8ee62f5ecf9afe9aeb3ba70e12639 100644 (file)
@@ -1,3 +1,8 @@
+2019-11-21  Richard Sandiford  <richard.sandiford@arm.com>
+
+       PR tree-optimization/92595
+       * g++.dg/vect/pr92595.cc: New test.
+
 2019-11-21  Srinath Parvathaneni  <srinath.parvathaneni@arm.com>
 
        * gcc.target/arm/acle/crc_hf_1.c: Modify the compiler options directive
diff --git a/gcc/testsuite/g++.dg/vect/pr92595.cc b/gcc/testsuite/g++.dg/vect/pr92595.cc
new file mode 100644 (file)
index 0000000..3d0b517
--- /dev/null
@@ -0,0 +1,32 @@
+// { dg-do compile }
+// { dg-require-effective-target c++11 }
+// { dg-additional-options "-O3" }
+// { dg-additional-options "-O3 -m32 -mno-sse" { target { i?86-*-* x86_64-*-* } } }
+
+void *operator new(__SIZE_TYPE__, void *a) { return a; }
+class b {
+public:
+  using c = int *;
+  c e();
+  c h();
+};
+template <typename d> class j : b {
+public:
+  void l() {
+    for (auto f = h(), g = e(); f != g; ++f)
+      new (f) d();
+  }
+};
+class m {
+public:
+  enum i {};
+  struct C {
+    i : 8;
+    i k : 8;
+  };
+};
+class o {
+  j<m::C> n;
+  o();
+};
+o::o() { n.l(); }
index 951c57f7f3480a70d245ae4a8bb91098a2d87186..65c649d66f765bd4559a8f4e8c0729b680e37ef6 100644 (file)
@@ -2308,6 +2308,7 @@ get_group_load_store_type (stmt_vec_info stmt_info, tree vectype, bool slp,
                  || alignment_support_scheme == dr_unaligned_supported)
              && known_eq (nunits, (group_size - gap) * 2)
              && known_eq (nunits, group_size)
+             && VECTOR_MODE_P (TYPE_MODE (vectype))
              && related_vector_mode (TYPE_MODE (vectype), elmode,
                                      group_size - gap).exists (&vmode)
              && (convert_optab_handler (vec_init_optab,
@@ -7822,8 +7823,9 @@ vectorizable_store (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi,
                 of vector elts directly.  */
              scalar_mode elmode = SCALAR_TYPE_MODE (elem_type);
              machine_mode vmode;
-             if (!related_vector_mode (TYPE_MODE (vectype), elmode,
-                                       group_size).exists (&vmode)
+             if (!VECTOR_MODE_P (TYPE_MODE (vectype))
+                 || !related_vector_mode (TYPE_MODE (vectype), elmode,
+                                          group_size).exists (&vmode)
                  || (convert_optab_handler (vec_extract_optab,
                                             TYPE_MODE (vectype), vmode)
                      == CODE_FOR_nothing))
@@ -7840,6 +7842,7 @@ vectorizable_store (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi,
                     element extracts from the original vector type and
                     element size stores.  */
                  if (int_mode_for_size (lsize, 0).exists (&elmode)
+                     && VECTOR_MODE_P (TYPE_MODE (vectype))
                      && related_vector_mode (TYPE_MODE (vectype), elmode,
                                              lnunits).exists (&vmode)
                      && (convert_optab_handler (vec_extract_optab,
@@ -8922,8 +8925,9 @@ vectorizable_load (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi,
                 vector elts directly.  */
              scalar_mode elmode = SCALAR_TYPE_MODE (TREE_TYPE (vectype));
              machine_mode vmode;
-             if (related_vector_mode (TYPE_MODE (vectype), elmode,
-                                      group_size).exists (&vmode)
+             if (VECTOR_MODE_P (TYPE_MODE (vectype))
+                 && related_vector_mode (TYPE_MODE (vectype), elmode,
+                                         group_size).exists (&vmode)
                  && (convert_optab_handler (vec_init_optab,
                                             TYPE_MODE (vectype), vmode)
                      != CODE_FOR_nothing))
@@ -8947,6 +8951,7 @@ vectorizable_load (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi,
                  /* If we can't construct such a vector fall back to
                     element loads of the original vector type.  */
                  if (int_mode_for_size (lsize, 0).exists (&elmode)
+                     && VECTOR_MODE_P (TYPE_MODE (vectype))
                      && related_vector_mode (TYPE_MODE (vectype), elmode,
                                              lnunits).exists (&vmode)
                      && (convert_optab_handler (vec_init_optab, vmode, elmode)