From patchwork Mon Oct 8 11:49:02 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 189999 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]) by ozlabs.org (Postfix) with SMTP id F359C2C030E for ; Mon, 8 Oct 2012 22:52:36 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1350301957; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Date: From:To:Subject:Message-ID:User-Agent:MIME-Version:Content-Type: Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:Sender:Delivered-To; bh=hHw/i4HB2JZOUTL7V0eU BraNagk=; b=vBe1+ayqkRYvovdhkj1U437jeMEYJdXKCIUz9y8mYT6bmZsCTE9H LUm+x0klS9WOqovWQWfcwnEXjM37zztejSAFjFMLSfqiWOm0WolcFwiN9FihZHFs 6cv4D/ucO6WJja/U+8UBWyOt0N6zBrzI5YChWZaJUebCD2eXuplRhs0= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Date:From:To:Subject:Message-ID:User-Agent:MIME-Version:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=MsE3WdZpDcndIXX6LoiB9zQrleCHtjAwI5fiH9/cGxKda2W7dRYwyF+HUbEnD5 wI+pEVRYBggoPPKdAyYseIFitEVNPkSm72Dau6XHbmN+DJETaC0KLI+e5Ms55tqB 8wjPQHEAFxut+/FDVVCorBGxVzFAFclZdKlYVuOC2P29E=; Received: (qmail 24665 invoked by alias); 8 Oct 2012 11:52:29 -0000 Received: (qmail 24656 invoked by uid 22791); 8 Oct 2012 11:52:27 -0000 X-SWARE-Spam-Status: No, hits=-6.5 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from cantor2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 08 Oct 2012 11:52:23 +0000 Received: from relay1.suse.de (unknown [195.135.220.254]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id 206D7A30EC for ; Mon, 8 Oct 2012 13:52:22 +0200 (CEST) Date: Mon, 8 Oct 2012 13:49:02 +0200 (CEST) From: Richard Guenther To: gcc-patches@gcc.gnu.org Subject: [PATCH] Remove my_rev_post_order_compute Message-ID: User-Agent: Alpine 2.00 (LNX 1167 2008-08-23) MIME-Version: 1.0 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 This replaces my_rev_post_order_compute in PRE by the already existing inverted_post_order_compute, with the necessary adjustments. Bootstrapped and tested on x86_64-unknown-linux-gnu, applied. Richard. 2012-10-08 Richard Guenther * tree-ssa-pre.c (postorder_num): New global. (compute_antic): Initialize all blocks and adjust for generic postorder. (my_rev_post_order_compute): Remove. (init_pre): Use inverted_post_order_compute. Index: gcc/tree-ssa-pre.c =================================================================== --- gcc/tree-ssa-pre.c (revision 192119) +++ gcc/tree-ssa-pre.c (working copy) @@ -430,6 +430,7 @@ typedef struct bb_bitmap_sets /* Basic block list in postorder. */ static int *postorder; +static int postorder_num; /* This structure is used to keep track of statistics on what optimization PRE was able to perform. */ @@ -2456,7 +2457,7 @@ compute_antic (void) has_abnormal_preds = sbitmap_alloc (last_basic_block); sbitmap_zero (has_abnormal_preds); - FOR_EACH_BB (block) + FOR_ALL_BB (block) { edge_iterator ei; edge e; @@ -2480,9 +2481,7 @@ compute_antic (void) } /* At the exit block we anticipate nothing. */ - ANTIC_IN (EXIT_BLOCK_PTR) = bitmap_set_new (); BB_VISITED (EXIT_BLOCK_PTR) = 1; - PA_IN (EXIT_BLOCK_PTR) = bitmap_set_new (); changed_blocks = sbitmap_alloc (last_basic_block + 1); sbitmap_ones (changed_blocks); @@ -2496,7 +2495,7 @@ compute_antic (void) for PA ANTIC computation. */ num_iterations++; changed = false; - for (i = n_basic_blocks - NUM_FIXED_BLOCKS - 1; i >= 0; i--) + for (i = postorder_num - 1; i >= 0; i--) { if (TEST_BIT (changed_blocks, postorder[i])) { @@ -2525,7 +2524,7 @@ compute_antic (void) fprintf (dump_file, "Starting iteration %d\n", num_iterations); num_iterations++; changed = false; - for (i = n_basic_blocks - NUM_FIXED_BLOCKS - 1 ; i >= 0; i--) + for (i = postorder_num - 1 ; i >= 0; i--) { if (TEST_BIT (changed_blocks, postorder[i])) { @@ -4593,78 +4592,6 @@ remove_dead_inserted_code (void) BITMAP_FREE (worklist); } -/* Compute a reverse post-order in *POST_ORDER. If INCLUDE_ENTRY_EXIT is - true, then then ENTRY_BLOCK and EXIT_BLOCK are included. Returns - the number of visited blocks. */ - -static int -my_rev_post_order_compute (int *post_order, bool include_entry_exit) -{ - edge_iterator *stack; - int sp; - int post_order_num = 0; - sbitmap visited; - - if (include_entry_exit) - post_order[post_order_num++] = EXIT_BLOCK; - - /* Allocate stack for back-tracking up CFG. */ - stack = XNEWVEC (edge_iterator, n_basic_blocks + 1); - sp = 0; - - /* Allocate bitmap to track nodes that have been visited. */ - visited = sbitmap_alloc (last_basic_block); - - /* None of the nodes in the CFG have been visited yet. */ - sbitmap_zero (visited); - - /* Push the last edge on to the stack. */ - stack[sp++] = ei_start (EXIT_BLOCK_PTR->preds); - - while (sp) - { - edge_iterator ei; - basic_block src; - basic_block dest; - - /* Look at the edge on the top of the stack. */ - ei = stack[sp - 1]; - src = ei_edge (ei)->src; - dest = ei_edge (ei)->dest; - - /* Check if the edge source has been visited yet. */ - if (src != ENTRY_BLOCK_PTR && ! TEST_BIT (visited, src->index)) - { - /* Mark that we have visited the destination. */ - SET_BIT (visited, src->index); - - if (EDGE_COUNT (src->preds) > 0) - /* Since the SRC node has been visited for the first - time, check its predecessors. */ - stack[sp++] = ei_start (src->preds); - else - post_order[post_order_num++] = src->index; - } - else - { - if (ei_one_before_end_p (ei) && dest != EXIT_BLOCK_PTR) - post_order[post_order_num++] = dest->index; - - if (!ei_one_before_end_p (ei)) - ei_next (&stack[sp - 1]); - else - sp--; - } - } - - if (include_entry_exit) - post_order[post_order_num++] = ENTRY_BLOCK; - - free (stack); - sbitmap_free (visited); - return post_order_num; -} - /* Initialize data structures used by PRE. */ @@ -4686,9 +4613,8 @@ init_pre (void) connect_infinite_loops_to_exit (); memset (&pre_stats, 0, sizeof (pre_stats)); - - postorder = XNEWVEC (int, n_basic_blocks - NUM_FIXED_BLOCKS); - my_rev_post_order_compute (postorder, false); + postorder = XNEWVEC (int, n_basic_blocks); + postorder_num = inverted_post_order_compute (postorder); alloc_aux_for_blocks (sizeof (struct bb_bitmap_sets));