]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
* tree-ssa-threadupdate.c (thread_through_all_blocks): Do not jump
authoraldyh <aldyh@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 11 Jul 2018 16:25:58 +0000 (16:25 +0000)
committeraldyh <aldyh@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 11 Jul 2018 16:25:58 +0000 (16:25 +0000)
thread twice from the same starting edge.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@262559 138bc75d-0d04-0410-961f-82ee72b054a4

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

index d239863dc4db178eb5f51e74884557714006ac08..ce4315b23acf7b6a9903cc308b3597aa4702cdf1 100644 (file)
@@ -1,3 +1,8 @@
+2018-07-11  Aldy Hernandez  <aldyh@redhat.com>
+
+        * tree-ssa-threadupdate.c (thread_through_all_blocks): Do not jump
+       thread twice from the same starting edge.
+
 2018-07-11  Aldy Hernandez  <aldyh@redhat.com>
 
        * vr-values.c (gimple_stmt_nonzero_p): Abstract common code to...
index 17f9b89d6a79df4ef3e22ebcfcc8118b852ef59e..8080dff76d0800af8221ddbb6ec0c66a212ac458 100644 (file)
@@ -2428,6 +2428,7 @@ thread_through_all_blocks (bool may_peel_loop_headers)
   unsigned int i;
   struct loop *loop;
   auto_bitmap threaded_blocks;
+  hash_set<edge> visited_starting_edges;
 
   if (!paths.exists ())
     {
@@ -2473,10 +2474,17 @@ thread_through_all_blocks (bool may_peel_loop_headers)
          continue;
        }
 
-      /* Do not jump-thread twice from the same block.  */
-      if (bitmap_bit_p (threaded_blocks, entry->src->index)
-         /* We may not want to realize this jump thread path
-            for various reasons.  So check it first.  */
+      /* Do not jump-thread twice from the same starting edge.
+
+        Previously we only checked that we weren't threading twice
+        from the same BB, but that was too restrictive.  Imagine a
+        path that starts from GIMPLE_COND(x_123 == 0,...), where both
+        edges out of this conditional yield paths that can be
+        threaded (for example, both lead to an x_123==0 or x_123!=0
+        conditional further down the line.  */
+      if (visited_starting_edges.contains (entry)
+         /* We may not want to realize this jump thread path for
+            various reasons.  So check it first.  */
          || !valid_jump_thread_path (path))
        {
          /* Remove invalid FSM jump-thread paths.  */
@@ -2496,7 +2504,7 @@ thread_through_all_blocks (bool may_peel_loop_headers)
        {
          /* We do not update dominance info.  */
          free_dominance_info (CDI_DOMINATORS);
-         bitmap_set_bit (threaded_blocks, entry->src->index);
+         visited_starting_edges.add (entry);
          retval = true;
          thread_stats.num_threaded_edges++;
        }
@@ -2514,7 +2522,7 @@ thread_through_all_blocks (bool may_peel_loop_headers)
       edge entry = (*path)[0]->e;
 
       /* Do not jump-thread twice from the same block.  */
-      if (bitmap_bit_p (threaded_blocks, entry->src->index))
+      if (visited_starting_edges.contains (entry))
        {
          delete_jump_thread_path (path);
          paths.unordered_remove (i);
@@ -2523,8 +2531,6 @@ thread_through_all_blocks (bool may_peel_loop_headers)
        i++;
     }
 
-  bitmap_clear (threaded_blocks);
-
   mark_threaded_blocks (threaded_blocks);
 
   initialize_original_copy_tables ();