re PR middle-end/59285 (gcc.dg/builtin-unreachable-6.c:17:1: internal compiler error...
authorJeff Law <law@redhat.com>
Wed, 8 Jan 2014 05:56:31 +0000 (22:56 -0700)
committerJeff Law <law@gcc.gnu.org>
Wed, 8 Jan 2014 05:56:31 +0000 (22:56 -0700)
        PR middle-end/59285
        * ifcvt.c (merge_if_block): If we are merging a block with more than
        one successor with a block with no successors, remove any BARRIER
        after the second block.

From-SVN: r206417

gcc/ChangeLog
gcc/ifcvt.c

index 179ddd4..0e828f3 100644 (file)
@@ -1,3 +1,10 @@
+2014-01-07  Jeff Law  <law@redhat.com>
+
+       PR middle-end/59285
+       * ifcvt.c (merge_if_block): If we are merging a block with more than
+       one successor with a block with no successors, remove any BARRIER
+       after the second block.
+
 2014-01-07  Dan Xio Qiang <ziyan01@163.com>
 
        * hw-doloop.c (reorg_loops): Release the bitmap obstack.
index aaed2d0..0afcfc3 100644 (file)
@@ -3153,6 +3153,20 @@ merge_if_block (struct ce_if_block * ce_info)
 
   if (then_bb)
     {
+      /* If THEN_BB has no successors, then there's a BARRIER after it.
+        If COMBO_BB has more than one successor (THEN_BB), then that BARRIER
+        is no longer needed, and in fact it is incorrect to leave it in
+        the insn stream.  */
+      if (EDGE_COUNT (then_bb->succs) == 0
+         && EDGE_COUNT (combo_bb->succs) > 1)
+       {
+         rtx end = NEXT_INSN (BB_END (then_bb));
+         while (end && NOTE_P (end) && !NOTE_INSN_BASIC_BLOCK_P (end))
+           end = NEXT_INSN (end);
+
+         if (end && BARRIER_P (end))
+           delete_insn (end);
+       }
       merge_blocks (combo_bb, then_bb);
       num_true_changes++;
     }
@@ -3162,6 +3176,20 @@ merge_if_block (struct ce_if_block * ce_info)
      get their addresses taken.  */
   if (else_bb)
     {
+      /* If ELSE_BB has no successors, then there's a BARRIER after it.
+        If COMBO_BB has more than one successor (ELSE_BB), then that BARRIER
+        is no longer needed, and in fact it is incorrect to leave it in
+        the insn stream.  */
+      if (EDGE_COUNT (else_bb->succs) == 0
+         && EDGE_COUNT (combo_bb->succs) > 1)
+       {
+         rtx end = NEXT_INSN (BB_END (else_bb));
+         while (end && NOTE_P (end) && !NOTE_INSN_BASIC_BLOCK_P (end))
+           end = NEXT_INSN (end);
+
+         if (end && BARRIER_P (end))
+           delete_insn (end);
+       }
       merge_blocks (combo_bb, else_bb);
       num_true_changes++;
     }