From: Richard Biener Date: Thu, 27 Feb 2020 12:42:56 +0000 (+0100) Subject: tree-optimization/93953 - avoid reference into hash-map X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e840185b31e40466e1575507200e1600e2343454;p=gcc.git tree-optimization/93953 - avoid reference into hash-map When possibly expanding a hash-map avoid keeping a reference to an entry. 2020-02-27 Richard Biener PR tree-optimization/93953 * tree-vect-slp.c (slp_copy_subtree): Avoid keeping a reference to the hash-map entry. * gcc.dg/pr93953.c: New testcase. --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b17d255ac8a..97419847b62 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2020-02-27 Richard Biener + + PR tree-optimization/93953 + * tree-vect-slp.c (slp_copy_subtree): Avoid keeping a reference + to the hash-map entry. + 2020-02-27 Andrew Stubbs * config/gcn/gcn.md (mov): Add transformations for BI subregs. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3cc13f91949..fa18a159687 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2020-02-27 Richard Biener + + PR tree-optimization/93953 + * gcc.dg/pr93953.c: New testcase. + 2020-02-27 Jakub Jelinek PR c/93949 diff --git a/gcc/testsuite/gcc.dg/pr93953.c b/gcc/testsuite/gcc.dg/pr93953.c new file mode 100644 index 00000000000..bf85c146cd9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr93953.c @@ -0,0 +1,17 @@ +/* PR tree-optimization/93953 */ +/* { dg-do compile } */ +/* { dg-options "-O3 --param=ggc-min-expand=0 --param=ggc-min-heapsize=0" } */ + +int *b, c, e; +float d, g, f; + +void +foo (int l) +{ + for (; l; ++l) + { + float a = g > l; + d += a * b[4 * (l + c * e)]; + f += a * b[4 * (l + c * e) + 1]; + } +} diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c index c7ddd94b39f..9d17e3386fa 100644 --- a/gcc/tree-vect-slp.c +++ b/gcc/tree-vect-slp.c @@ -1764,11 +1764,12 @@ slp_copy_subtree (slp_tree node, hash_map &map) unsigned i; bool existed_p; - slp_tree © = map.get_or_insert (node, &existed_p); + slp_tree ©_ref = map.get_or_insert (node, &existed_p); if (existed_p) - return copy; + return copy_ref; - copy = XNEW (_slp_tree); + copy_ref = XNEW (_slp_tree); + slp_tree copy = copy_ref; memcpy (copy, node, sizeof (_slp_tree)); if (SLP_TREE_SCALAR_STMTS (node).exists ()) {