Fix bb-reorder problem with degenerate cond_jump (PR68182)
authorSegher Boessenkool <segher@gcc.gnu.org>
Mon, 9 Nov 2015 03:57:19 +0000 (04:57 +0100)
committerSegher Boessenkool <segher@gcc.gnu.org>
Mon, 9 Nov 2015 03:57:19 +0000 (04:57 +0100)
The code mistakenly thinks any cond_jump has two successors.  This is
not true if both destinations are the same, as can happen with weird
patterns as in the PR.

PR rtl-optimization/68182
* gcc/bb-reorder.c (reorder_basic_blocks_simple): Treat a conditional
branch with only one successor just like unconditional branches.

From-SVN: r229983

gcc/ChangeLog
gcc/bb-reorder.c

index 6401c437ed20000c72c41ccd46b11e1ada13bca0..dcb6d55ca6b8b89625c733926e53edade009de91 100644 (file)
@@ -1,4 +1,10 @@
-2015-11-08  Jeff Law <jeff@redhat.com>
+2015-11-09  Segher Boessenkool  <segher@kernel.crashing.org>
+
+       PR rtl-optimization/68182
+       * gcc/bb-reorder.c (reorder_basic_blocks_simple): Treat a conditional
+       branch with only one successor just like unconditional branches.
+
+2015-11-08  Jeff Law  <jeff@redhat.com>
 
        * tree-ssa-threadupdate.c (register_jump_thraed): Assert that a
        non-FSM path has no edges marked with EDGE_DFS_BACK.
index 5f1c2ccc6cbf4c4d27b1bf74a628b93d5f7054e5..950b1a1089d82832de5bce3163617a59e4df8c39 100644 (file)
@@ -2304,7 +2304,9 @@ reorder_basic_blocks_simple (void)
       if (JUMP_P (end) && extract_asm_operands (end))
        continue;
 
-      if (any_condjump_p (end))
+      if (single_succ_p (bb))
+       edges[n++] = EDGE_SUCC (bb, 0);
+      else if (any_condjump_p (end))
        {
          edge e0 = EDGE_SUCC (bb, 0);
          edge e1 = EDGE_SUCC (bb, 1);
@@ -2315,8 +2317,6 @@ reorder_basic_blocks_simple (void)
          edges[n++] = e0;
          edges[n++] = e1;
        }
-      else if (single_succ_p (bb))
-       edges[n++] = EDGE_SUCC (bb, 0);
     }
 
   /* Sort the edges, the most desirable first.  When optimizing for size