From: Richard Biener Date: Fri, 9 Oct 2020 08:19:38 +0000 (+0200) Subject: tree-optimization/97347 - fix another SLP constant insertion issue X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=5d708c6315e0fc57992cda7b466a5a9877ced4e3;p=gcc.git tree-optimization/97347 - fix another SLP constant insertion issue Just use edge insertion which will appropriately handle the situation from botan. 2020-10-09 Richard Biener PR tree-optimization/97347 * tree-vect-slp.c (vect_create_constant_vectors): Use edge insertion when inserting on the fallthru edge, appropriately insert at the start of BBs when inserting after PHIs. * g++.dg/vect/pr97347.cc: New testcase. --- diff --git a/gcc/testsuite/g++.dg/vect/pr97347.cc b/gcc/testsuite/g++.dg/vect/pr97347.cc new file mode 100644 index 00000000000..6a9116c412a --- /dev/null +++ b/gcc/testsuite/g++.dg/vect/pr97347.cc @@ -0,0 +1,41 @@ +// { dg-do compile } +// { dg-require-effective-target c++11 } + +inline namespace __cxx11 {} +typedef int size_t; +class MessageAuthenticationCode; +class __uniq_ptr_impl { + struct _Ptr { + using type = MessageAuthenticationCode *; + }; +public: + using pointer = _Ptr::type; +}; +class unique_ptr { +public: + using pointer = __uniq_ptr_impl::pointer; + unique_ptr(pointer); +}; +namespace __cxx11 { +class basic_string { +public: + basic_string(char *); + ~basic_string(); +}; +} // namespace __cxx11 +class MessageAuthenticationCode {}; +class SCAN_Name { +public: + SCAN_Name(basic_string); + size_t arg_as_integer(); +}; +class SipHash : public MessageAuthenticationCode { +public: + SipHash(size_t c, size_t d) : m_C(c), m_D(d) {} + size_t m_C, m_D; +}; +void create(basic_string algo_spec, char *s) { + basic_string provider = s; + SCAN_Name req(algo_spec); + unique_ptr(new SipHash(req.arg_as_integer(), req.arg_as_integer())); +} diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c index 77ea4d0eb51..479c3eeaec7 100644 --- a/gcc/tree-vect-slp.c +++ b/gcc/tree-vect-slp.c @@ -4145,9 +4145,17 @@ vect_create_constant_vectors (vec_info *vinfo, slp_tree op_node) { gimple_stmt_iterator gsi; if (gimple_code (insert_after->stmt) == GIMPLE_PHI) - gsi = gsi_after_labels (gimple_bb (insert_after->stmt)); + { + gsi = gsi_after_labels (gimple_bb (insert_after->stmt)); + gsi_insert_seq_before (&gsi, ctor_seq, + GSI_CONTINUE_LINKING); + } else if (!stmt_ends_bb_p (insert_after->stmt)) - gsi = gsi_for_stmt (insert_after->stmt); + { + gsi = gsi_for_stmt (insert_after->stmt); + gsi_insert_seq_after (&gsi, ctor_seq, + GSI_CONTINUE_LINKING); + } else { /* When we want to insert after a def where the @@ -4155,11 +4163,10 @@ vect_create_constant_vectors (vec_info *vinfo, slp_tree op_node) edge. */ edge e = find_fallthru_edge (gimple_bb (insert_after->stmt)->succs); - gcc_assert (single_pred_p (e->dest)); - gsi = gsi_after_labels (e->dest); + basic_block new_bb + = gsi_insert_seq_on_edge_immediate (e, ctor_seq); + gcc_assert (!new_bb); } - gsi_insert_seq_after (&gsi, ctor_seq, - GSI_CONTINUE_LINKING); } else vinfo->insert_seq_on_entry (NULL, ctor_seq);