]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
shrink-wrap: Once more PRs 67778, 68634, and now 68909
authorSegher Boessenkool <segher@kernel.crashing.org>
Fri, 8 Jan 2016 03:58:40 +0000 (04:58 +0100)
committerSegher Boessenkool <segher@gcc.gnu.org>
Fri, 8 Jan 2016 03:58:40 +0000 (04:58 +0100)
If a candidate PRE cannot get the prologue because a block BB is
reachable from it, but PRE does not dominate BB, we try again with the
dominators of PRE.  That "try again" needs to again consider BB though,
we aren't done with it.

PR rtl-optimization/67778
PR rtl-optimization/68634
PR rtl-optimization/68909
* shrink-wrap.c (try_shrink_wrapping): Add comment.  Don't pop
block from the stack until done with it.  Remove a superfluous
bitmap set.  Remove a superfluous bitmap test.

From-SVN: r232148

gcc/ChangeLog
gcc/shrink-wrap.c

index 73315996c08fcd495ecc28984a0b7bb9244973de..44a2e01c6732fd2029c4b1b7843b04bebb99ae7b 100644 (file)
@@ -1,3 +1,12 @@
+2016-01-08  Segher Boessenkool  <segher@kernel.crashing.org>
+
+       PR rtl-optimization/67778
+       PR rtl-optimization/68634
+       PR rtl-optimization/68909
+       * shrink-wrap.c (try_shrink_wrapping): Add comment.  Don't pop
+       block from the stack until done with it.  Remove a superfluous
+       bitmap set.  Remove a superfluous bitmap test.
+
 2016-01-07  Martin Sebor  <msebor@redhat.com>
 
        PR c/68966
index e51bd361d8daf6acd5192c43758c6b987cef0fb8..84abd6b783bf6acdad18a0d9f84e361568f679d5 100644 (file)
@@ -750,9 +750,21 @@ try_shrink_wrapping (edge *entry_edge, bitmap_head *bb_with,
 
   /* If we can move PRO back without having to duplicate more blocks, do so.
      We do this because putting the prologue earlier is better for scheduling.
+
      We can move back to a block PRE if every path from PRE will eventually
      need a prologue, that is, PRO is a post-dominator of PRE.  PRE needs
-     to dominate every block reachable from itself.  */
+     to dominate every block reachable from itself.  We keep in BB_TMP a
+     bitmap of the blocks reachable from PRE that we already found, and in
+     VEC a stack of those we still need to consider.
+
+     Any block reachable from PRE is also reachable from all predecessors
+     of PRE, so if we find we need to move PRE back further we can leave
+     everything not considered so far on the stack.  Any block dominated
+     by PRE is also dominated by all other dominators of PRE, so anything
+     found good for some PRE does not need to be reconsidered later.
+
+     We don't need to update BB_WITH because none of the new blocks found
+     can jump to a block that does not need the prologue.  */
 
   if (pro != entry)
     {
@@ -775,18 +787,15 @@ try_shrink_wrapping (edge *entry_edge, bitmap_head *bb_with,
          bool ok = true;
          while (!vec.is_empty ())
            {
-             basic_block bb = vec.pop ();
-             bitmap_set_bit (bb_tmp, pre->index);
-
-             if (!dominated_by_p (CDI_DOMINATORS, bb, pre))
+             if (!dominated_by_p (CDI_DOMINATORS, vec.last (), pre))
                {
                  ok = false;
                  break;
                }
 
+             basic_block bb = vec.pop ();
              FOR_EACH_EDGE (e, ei, bb->succs)
-               if (!bitmap_bit_p (bb_with, e->dest->index)
-                   && bitmap_set_bit (bb_tmp, e->dest->index))
+               if (bitmap_set_bit (bb_tmp, e->dest->index))
                  vec.quick_push (e->dest);
            }