This is something Richi pointed out. I didn't think it was a big deal and didn't want to unnecessarily complicate the code like I did for jump threading to avoid a little bit of block copying.

As it turns out avoiding the copying in path splitting is trivial, so trivial we actually get to remove a bit of code.

To ensure this got tested, I put split-paths back into -O2 for my bootstrap & regression tested. It, of course, passed just fine.

Installed on the trunk.

Jeff
commit ed304c35af7050ab30585fd0ad6ed968dfac73c1
Author: Jeff Law <l...@redhat.com>
Date:   Tue Dec 22 14:48:12 2015 -0700

    [PATCH] Avoid unnecessary block copying in path splitting
    
        * gimple-ssa-split-paths.c (split_paths): Avoid unnecessary block
        copying.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 73ab7d4..5e1e819 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2015-12-22  Jeff Law  <l...@redhat.com>
+
+       * gimple-ssa-split-paths.c (split_paths): Avoid unnecessary block
+       copying.
+
 2015-12-22  Jakub Jelinek  <ja...@redhat.com>
 
        PR c++/67376
diff --git a/gcc/gimple-ssa-split-paths.c b/gcc/gimple-ssa-split-paths.c
index 540fdf3..294a1af 100644
--- a/gcc/gimple-ssa-split-paths.c
+++ b/gcc/gimple-ssa-split-paths.c
@@ -192,9 +192,10 @@ split_paths ()
 
       /* BB is the merge point for an IF-THEN-ELSE we want to transform.
 
-        Essentially we want to create two duplicates of BB and append
-        a duplicate to the THEN and ELSE clauses.  This will split the
-        path leading to the latch.  BB will be unreachable and removed.  */
+        Essentially we want to create a duplicate of bb and redirect the
+        first predecessor of BB to the duplicate (leaving the second
+        predecessor as is.  This will split the path leading to the latch
+        re-using BB to avoid useless copying.  */
       if (bb && is_feasible_trace (bb))
        {
          if (dump_file && (dump_flags & TDF_DETAILS))
@@ -202,9 +203,7 @@ split_paths ()
                     "Duplicating join block %d into predecessor paths\n",
                     bb->index);
          basic_block pred0 = EDGE_PRED (bb, 0)->src;
-         basic_block pred1 = EDGE_PRED (bb, 1)->src;
          transform_duplicate (pred0, bb);
-         transform_duplicate (pred1, bb);
          changed = true;
        }
     }

Reply via email to