[PATCH] tree-optimization/93953 - avoid reference into hash-map
Richard Biener
rguenther@suse.de
Thu Feb 27 10:49:00 GMT 2020
When possibly expanding a hash-map avoid keeping a reference to an
entry.
Bootstrap and regtest running on x86_64-unknown-linux-gnu.
Richard.
2020-02-27 Richard Biener <rguenther@suse.de>
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.
---
gcc/testsuite/gcc.dg/pr93953.c | 17 +++++++++++++++++
gcc/tree-vect-slp.c | 7 ++++---
2 files changed, 21 insertions(+), 3 deletions(-)
create mode 100644 gcc/testsuite/gcc.dg/pr93953.c
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<slp_tree, slp_tree> &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 ())
{
--
2.16.4
More information about the Gcc-patches
mailing list