From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16468 invoked by alias); 31 Mar 2011 18:46:10 -0000 Received: (qmail 16455 invoked by uid 22791); 31 Mar 2011 18:46:08 -0000 X-SWARE-Spam-Status: No, hits=-1.6 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 31 Mar 2011 18:46:01 +0000 Received: (qmail 7428 invoked from network); 31 Mar 2011 18:45:59 -0000 Received: from unknown (HELO ?192.168.1.66?) (vries@127.0.0.2) by mail.codesourcery.com with ESMTPA; 31 Mar 2011 18:45:59 -0000 Message-ID: <4D94CBDD.9060304@codesourcery.com> Date: Thu, 31 Mar 2011 18:56:00 -0000 From: Tom de Vries User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.14) Gecko/20110223 Lightning/1.0b2 Thunderbird/3.1.8 MIME-Version: 1.0 To: gcc-patches@gcc.gnu.org, ebotcazou@libertysurf.fr Subject: [PATCH, PR43920, 9/9] Cross-jumping - Allow both directions. References: <4D94C603.7080505@codesourcery.com> <4D94C88B.4020206@codesourcery.com> In-Reply-To: <4D94C88B.4020206@codesourcery.com> Content-Type: multipart/mixed; boundary="------------040206060402050209090500" Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2011-03/txt/msg02258.txt.bz2 This is a multi-part message in MIME format. --------------040206060402050209090500 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-length: 305 Allow crossjumping in both directions. Crossjump was assumed to be symmetric, and therefore only applied on edges e1,e2 and not on e2,e1. Now given both the fallthru fix and the regnotes fix, crossjumping is not symmetrical anymore, and we allow both directions (but not by testing twice). Thanks, - Tom --------------040206060402050209090500 Content-Type: text/x-patch; name="9_crossjump-backward-ml.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="9_crossjump-backward-ml.patch" Content-length: 2710 diff -u gcc/cfgcleanup.c gcc/cfgcleanup.c --- gcc/cfgcleanup.c (working copy) +++ gcc/cfgcleanup.c (working copy) @@ -69,7 +69,7 @@ information; we should run df_analyze to enable more opportunities. */ static bool block_was_dirty; -static bool try_crossjump_to_edge (int, edge, edge); +static bool try_crossjump_to_edge (int, edge, edge, enum replace_direction); static bool try_crossjump_bb (int, basic_block); static bool outgoing_edges_match (int, basic_block, basic_block); static enum replace_direction old_insns_match_p (int, rtx, rtx); @@ -1695,15 +1695,17 @@ /* E1 and E2 are edges with the same destination block. Search their predecessors for common code. If found, redirect control flow from - (maybe the middle of) E1->SRC to (maybe the middle of) E2->SRC. */ + (maybe the middle of) E1->SRC to (maybe the middle of) E2->SRC (dir_forward), + or the other way around (dir_backward). DIR specifies the allowed + replacement direction. */ static bool -try_crossjump_to_edge (int mode, edge e1, edge e2) +try_crossjump_to_edge (int mode, edge e1, edge e2, + enum replace_direction dir) { int nmatch; basic_block src1 = e1->src, src2 = e2->src; basic_block redirect_to, redirect_from, to_remove; basic_block osrc1, osrc2, redirect_edges_to, tmp; - enum replace_direction dir; rtx newpos1, newpos2; edge s; edge_iterator ei; @@ -1757,8 +1759,7 @@ return false; /* ... and part the second. */ - dir = dir_forward; nmatch = flow_find_cross_jump (src1, src2, &newpos1, &newpos2, &dir); osrc1 = src1; osrc2 = src2; @@ -1767,5 +1768,15 @@ if (newpos2 != NULL_RTX) src2 = BLOCK_FOR_INSN (newpos2); + if (dir == dir_backward) + { +#define SWAP(T, X, Y) do { T tmp = (X); (X) = (Y); (Y) = tmp; } while (0) + SWAP (basic_block, osrc1, osrc2); + SWAP (basic_block, src1, src2); + SWAP (edge, e1, e2); + SWAP (rtx, newpos1, newpos2); +#undef SWAP + } + /* Don't proceed with the crossjump unless we found a sufficient number of matching instructions or the 'from' block was totally matched @@ -2020,7 +2031,7 @@ || (fallthru->src->flags & BB_MODIFIED))) continue; - if (try_crossjump_to_edge (mode, e, fallthru)) + if (try_crossjump_to_edge (mode, e, fallthru, dir_forward)) { changed = true; ix = 0; @@ -2068,7 +2079,9 @@ || (e2->src->flags & BB_MODIFIED))) continue; - if (try_crossjump_to_edge (mode, e, e2)) + /* Both e and e2 are not fallthru edges, so we can crossjump in either + direction. */ + if (try_crossjump_to_edge (mode, e, e2, dir_both)) { changed = true; ix = 0; --------------040206060402050209090500--