From 934f135b967c7501be6e2e10a2c3c03c54a198d3 Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Thu, 21 Nov 2019 17:41:16 +0000 Subject: [PATCH] Add missing VECTOR_MODE_P checks (PR 92595) 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 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 | 7 ++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/vect/pr92595.cc | 32 ++++++++++++++++++++++++++++ gcc/tree-vect-stmts.c | 13 +++++++---- 4 files changed, 53 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/g++.dg/vect/pr92595.cc diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2aa4a78f12d..859dd7136c7 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2019-11-21 Richard Sandiford + + 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 * ipa-inline.c (update_callee_keys): Add parameter UPDATE_SINCE. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1ae64a6a28d..1f69d52fd1e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-11-21 Richard Sandiford + + PR tree-optimization/92595 + * g++.dg/vect/pr92595.cc: New test. + 2019-11-21 Srinath Parvathaneni * 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 index 00000000000..3d0b517036d --- /dev/null +++ b/gcc/testsuite/g++.dg/vect/pr92595.cc @@ -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 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 n; + o(); +}; +o::o() { n.l(); } diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c index 951c57f7f34..65c649d66f7 100644 --- a/gcc/tree-vect-stmts.c +++ b/gcc/tree-vect-stmts.c @@ -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) -- 2.30.2