]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Avoid PHI node re-allocation in loop copying
authorRichard Biener <rguenther@suse.de>
Wed, 8 Jan 2025 14:12:30 +0000 (15:12 +0100)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 9 Jan 2025 12:58:29 +0000 (13:58 +0100)
duplicate_loop_body_to_header_edge redirects the original loop entry
edge to the loop copy header and the copied loop exit to the old
loop header.  But it does so in the order that requires temporary
space for an extra edge on the original loop header, causing
unnecessary re-allocations.  The following avoids this by swapping
the order of the redirects.

* cfgloopmanip.cc (duplicate_loop_body_to_header_edge): When
copying to the header edge first redirect the entry to the
new loop and then the exit to the old to avoid PHI node
re-allocation.

gcc/cfgloopmanip.cc

index 534e556e1e4e7ce96843eb276d23b78c583ede5a..17bcf9f4acc4f592209a0909353495491bfd333c 100644 (file)
@@ -1447,9 +1447,9 @@ duplicate_loop_body_to_header_edge (class loop *loop, edge e,
        }
       else
        {
+         redirect_edge_and_branch_force (e, new_bbs[0]);
          redirect_edge_and_branch_force (new_spec_edges[SE_LATCH],
                                          loop->header);
-         redirect_edge_and_branch_force (e, new_bbs[0]);
          set_immediate_dominator (CDI_DOMINATORS, new_bbs[0], e->src);
          e = new_spec_edges[SE_LATCH];
        }