tree-ssa-structalias.c (solve_graph): When propagating to successors update the graph...
authorRichard Biener <rguenther@suse.de>
Thu, 17 Aug 2017 12:10:11 +0000 (12:10 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 17 Aug 2017 12:10:11 +0000 (12:10 +0000)
2017-08-17  Richard Biener  <rguenther@suse.de>

* tree-ssa-structalias.c (solve_graph): When propagating
to successors update the graphs succ edges and avoid duplicate work.

From-SVN: r251146

gcc/ChangeLog
gcc/tree-ssa-structalias.c

index 088f312c84326b2276a1f60da04ed8c91d6792d7..e9ece8939194d4de8334dbbbcb3c7f49b5b2b650 100644 (file)
@@ -1,3 +1,8 @@
+2017-08-17  Richard Biener  <rguenther@suse.de>
+
+       * tree-ssa-structalias.c (solve_graph): When propagating
+       to successors update the graphs succ edges and avoid duplicate work.
+
 2017-08-17  Maxim Ostapenko  <m.ostapenko@samsung.com>
 
        PR target/81861
index c95d1e3784bcc964f46b3092188b73c7153e7bb1..2cca970f1e5451442024960a2eabcac4ad192699 100644 (file)
@@ -2765,20 +2765,35 @@ solve_graph (constraint_graph_t graph)
                  unsigned eff_escaped_id = find (escaped_id);
 
                  /* Propagate solution to all successors.  */
+                 unsigned to_remove = ~0U;
                  EXECUTE_IF_IN_NONNULL_BITMAP (graph->succs[i],
                                                0, j, bi)
                    {
-                     bitmap tmp;
-                     bool flag;
-
+                     if (to_remove != ~0U)
+                       {
+                         bitmap_clear_bit (graph->succs[i], to_remove);
+                         to_remove = ~0U;
+                       }
                      unsigned int to = find (j);
-                     tmp = get_varinfo (to)->solution;
-                     flag = false;
-
+                     if (to != j)
+                       {
+                         /* Update the succ graph, avoiding duplicate
+                            work.  */
+                         to_remove = j;
+                         if (! bitmap_set_bit (graph->succs[i], to))
+                           continue;
+                         /* We eventually end up processing 'to' twice
+                            as it is undefined whether bitmap iteration
+                            iterates over bits set during iteration.
+                            Play safe instead of doing tricks.  */
+                       }
                      /* Don't try to propagate to ourselves.  */
                      if (to == i)
                        continue;
 
+                     bitmap tmp = get_varinfo (to)->solution;
+                     bool flag = false;
+
                      /* If we propagate from ESCAPED use ESCAPED as
                         placeholder.  */
                      if (i == eff_escaped_id)
@@ -2789,6 +2804,8 @@ solve_graph (constraint_graph_t graph)
                      if (flag)
                        bitmap_set_bit (changed, to);
                    }
+                 if (to_remove != ~0U)
+                   bitmap_clear_bit (graph->succs[i], to_remove);
                }
            }
        }