ifcvt.c (find_if_case_1): Avoid creating an empty forwarder block...
authorRoger Sayle <roger@eyesopen.com>
Wed, 5 Jan 2005 01:45:00 +0000 (01:45 +0000)
committerRoger Sayle <sayle@gcc.gnu.org>
Wed, 5 Jan 2005 01:45:00 +0000 (01:45 +0000)
* ifcvt.c (find_if_case_1): Avoid creating an empty forwarder block,
if deleting the then-block allows the test-block to fallthru to the
else-block.

From-SVN: r92919

gcc/ChangeLog
gcc/ifcvt.c

index 2d8e69aa278172613d0f03d3a8b80095eb8d5c3b..03365eac92d1f80b49dd62946ec98ebc8f61c5a0 100644 (file)
@@ -1,3 +1,9 @@
+2005-01-04  Roger Sayle  <roger@eyesopen.com>
+
+       * ifcvt.c (find_if_case_1): Avoid creating an empty forwarder block,
+       if deleting the then-block allows the test-block to fallthru to the
+       else-block.
+
 2005-01-04  Andrew Pinski  <pinskia@physics.uc.edu>
 
        PR c/19152
index 98fbd667a01ac2dca65c09259a75ae4e41487000..75932b37e46e07173a81902537fefa5cff20ad52 100644 (file)
@@ -2927,7 +2927,21 @@ find_if_case_1 (basic_block test_bb, edge then_edge, edge else_edge)
              else_bb->global_live_at_start,
              then_bb->global_live_at_end);
 
-  new_bb = redirect_edge_and_branch_force (FALLTHRU_EDGE (test_bb), else_bb);
+
+  /* We can avoid creating a new basic block if then_bb is immediately
+     followed by else_bb, i.e. deleting then_bb allows test_bb to fall
+     thru to else_bb.  */
+
+  if (then_bb->next_bb == else_bb
+      && then_bb->prev_bb == test_bb)
+    {
+      redirect_edge_succ (FALLTHRU_EDGE (test_bb), else_bb);
+      new_bb = 0;
+    }
+  else
+    new_bb = redirect_edge_and_branch_force (FALLTHRU_EDGE (test_bb),
+                                             else_bb);
+
   then_bb_index = then_bb->index;
   delete_basic_block (then_bb);