tree-optimization/97347 - fix another SLP constant insertion issue
authorRichard Biener <rguenther@suse.de>
Fri, 9 Oct 2020 08:19:38 +0000 (10:19 +0200)
committerRichard Biener <rguenther@suse.de>
Fri, 9 Oct 2020 09:28:15 +0000 (11:28 +0200)
Just use edge insertion which will appropriately handle the situation
from botan.

2020-10-09  Richard Biener  <rguenther@suse.de>

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.

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

diff --git a/gcc/testsuite/g++.dg/vect/pr97347.cc b/gcc/testsuite/g++.dg/vect/pr97347.cc
new file mode 100644 (file)
index 0000000..6a9116c
--- /dev/null
@@ -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()));
+}
index 77ea4d0eb5163085d27cf5e556b36465ce49336b..479c3eeaec7c926d99f7fe89d32eecab108ecf58 100644 (file)
@@ -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);