From patchwork Fri Nov 8 16:24:01 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Law X-Patchwork-Id: 289882 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 40DB42C00A6 for ; Sat, 9 Nov 2013 03:24:24 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; q= dns; s=default; b=uMsPi8h8b4EUedpnKF7i0R/XHQivPS6f+zhMQRFNtksmR4 ednKUCDc9u+hFJOaJW/lB5CRadOKH3QVsnE3/i7hvKmgM0xRq3Jw2Bq/KB2mf3JI r1okZgZKuU5NKsbf6LoM1Vezjwy9w3Zy0FrJzEencmIt3/hkMadLyOynKfIDI= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; s= default; bh=ZK7MKYhkHjDr3RCEVv1f9YaRC/Q=; b=UF7R5XRAJ2ratkYKZ2Be p2wjNRSh0gvEaHa4DTDcGjmhIu9roZIMskRod5Sf1MH/fmjuSOi7pqkZ0OyFBsvE EfVKQBYzwkmRFW37Uom+NiE4x2gYJkICOfvdX25ChPuyC8kuxewAb7MWq+ittGwe Wzed9O8Fi3fP8Iljs5iEGc4= Received: (qmail 27463 invoked by alias); 8 Nov 2013 16:24:11 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 27442 invoked by uid 89); 8 Nov 2013 16:24:10 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.8 required=5.0 tests=AWL, BAYES_00, RDNS_NONE, SPF_HELO_PASS autolearn=no version=3.3.2 X-HELO: mx1.redhat.com Received: from Unknown (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 08 Nov 2013 16:24:09 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rA8GO1pm016260 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 8 Nov 2013 11:24:02 -0500 Received: from stumpy.slc.redhat.com (ovpn-113-132.phx2.redhat.com [10.3.113.132]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id rA8GO15e027553 for ; Fri, 8 Nov 2013 11:24:01 -0500 Message-ID: <527D1021.1020508@redhat.com> Date: Fri, 08 Nov 2013 09:24:01 -0700 From: Jeff Law User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.0 MIME-Version: 1.0 To: gcc-patches Subject: [PATCH] Commonize repeated code into function X-IsSubscribed: yes This has been on my todo list for a little while now. Over time I've written the loop to delete a jump threading path several times. It's just 3 lines of code, but I hate repeating it all over the place. This pulls those trivial 3 lines into a function and calls it from the appropriate places. Bootstrapped and regression tested on x86_64-unknown-linux-gnu. Applied to the trunk. * tree-ssa-threadupdate.h (delete_thread_path): Declare. * tree-ssa-threadupdate.c (delete_thread_path): New function. (ssa_redirect_edges, thread_block_1): Use it. (thread_through_loop_header, mark_threaded_blocks): Likewise. (thread_through_all_blocks, register_jump_thread): Likewise. * tree-ssa-threadedge.c (thread_across_edge): Likewise. diff --git a/gcc/tree-ssa-threadedge.c b/gcc/tree-ssa-threadedge.c index 4cff16d..cd2b34a 100644 --- a/gcc/tree-ssa-threadedge.c +++ b/gcc/tree-ssa-threadedge.c @@ -1086,9 +1086,7 @@ thread_across_edge (gimple dummy_cond, } else { - for (unsigned int i = 0; i < path->length (); i++) - delete (*path)[i]; - path->release(); + delete_jump_thread_path (path); } } BITMAP_FREE (visited); diff --git a/gcc/tree-ssa-threadupdate.c b/gcc/tree-ssa-threadupdate.c index 1027191..24e7767 100644 --- a/gcc/tree-ssa-threadupdate.c +++ b/gcc/tree-ssa-threadupdate.c @@ -555,9 +555,7 @@ ssa_redirect_edges (struct redirection_data **slot, /* Go ahead and clear E->aux. It's not needed anymore and failure to clear it will cause all kinds of unpleasant problems later. */ - for (unsigned int i = 0; i < path->length (); i++) - delete (*path)[i]; - path->release (); + delete_jump_thread_path (path); e->aux = NULL; } @@ -703,9 +701,7 @@ thread_block_1 (basic_block bb, bool noloop_only, bool joiners) /* Since this case is not handled by our special code to thread through a loop header, we must explicitly cancel the threading request here. */ - for (unsigned int i = 0; i < path->length (); i++) - delete (*path)[i]; - path->release (); + delete_jump_thread_path (path); e->aux = NULL; continue; } @@ -1161,9 +1157,7 @@ thread_through_loop_header (struct loop *loop, bool may_peel_loop_headers) if (e->src->loop_father != e2->dest->loop_father && e2->dest != loop->header) { - for (unsigned int i = 0; i < path->length (); i++) - delete (*path)[i]; - path->release (); + delete_jump_thread_path (path); e->aux = NULL; } } @@ -1213,9 +1207,7 @@ fail: if (path) { - for (unsigned int i = 0; i < path->length (); i++) - delete (*path)[i]; - path->release (); + delete_jump_thread_path (path); e->aux = NULL; } } @@ -1310,9 +1302,7 @@ mark_threaded_blocks (bitmap threaded_blocks) if (e2 && !phi_args_equal_on_edges (e2, final_edge)) { - for (unsigned int i = 0; i < path->length (); i++) - delete (*path)[i]; - path->release (); + delete_jump_thread_path (path); e->aux = NULL; } } @@ -1336,9 +1326,7 @@ mark_threaded_blocks (bitmap threaded_blocks) if (e->aux) { vec *path = THREAD_PATH (e); - for (unsigned int i = 0; i < path->length (); i++) - delete (*path)[i]; - path->release (); + delete_jump_thread_path (path); e->aux = NULL; } } @@ -1395,9 +1383,7 @@ mark_threaded_blocks (bitmap threaded_blocks) || (path->last ()->type == EDGE_COPY_SRC_JOINER_BLOCK)) { - for (unsigned int i = 0; i < path->length (); i++) - delete (*path)[i]; - path->release (); + delete_jump_thread_path (path); e->aux = NULL; } break; @@ -1498,9 +1484,7 @@ thread_through_all_blocks (bool may_peel_loop_headers) { vec *path = THREAD_PATH (e); - for (unsigned int i = 0; i < path->length (); i++) - delete (*path)[i]; - path->release (); + delete_jump_thread_path (path); e->aux = NULL; } } @@ -1520,6 +1504,17 @@ thread_through_all_blocks (bool may_peel_loop_headers) return retval; } +/* Delete the jump threading path PATH. We have to explcitly delete + each entry in the vector, then the container. */ + +void +delete_jump_thread_path (vec *path) +{ + for (unsigned int i = 0; i < path->length (); i++) + delete (*path)[i]; + path->release(); +} + /* Dump a jump threading path, including annotations about each edge in the path. */ @@ -1565,9 +1560,7 @@ register_jump_thread (vec *path) { if (!dbg_cnt (registered_jump_thread)) { - for (unsigned int i = 0; i < path->length (); i++) - delete (*path)[i]; - path->release (); + delete_jump_thread_path (path); return; } @@ -1583,9 +1576,7 @@ register_jump_thread (vec *path) dump_jump_thread_path (dump_file, *path); } - for (unsigned int i = 0; i < path->length (); i++) - delete (*path)[i]; - path->release (); + delete_jump_thread_path (path); return; } diff --git a/gcc/tree-ssa-threadupdate.h b/gcc/tree-ssa-threadupdate.h index f84c02e..4617b9c 100644 --- a/gcc/tree-ssa-threadupdate.h +++ b/gcc/tree-ssa-threadupdate.h @@ -42,4 +42,5 @@ public: }; extern void register_jump_thread (vec *); +extern void delete_jump_thread_path (vec *); #endif