From patchwork Thu Nov 29 13:48:14 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 202752 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 2F7042C0089 for ; Fri, 30 Nov 2012 00:52:33 +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=1354801954; 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=79PGMCGjoMhSFJGROX8y ARU6PPQ=; b=p9MqEz+cXlBnmdKo8YvndY2s8t7YM3kywQ+h7Vc3tI2GY9TGMe02 rvFqiKLvxD59HOobPLrCi0vrknJyUJbcRepOgLRWPICMsPOi3ti/2WmZVIdM+Vs+ mpXTt49aLNKpYD3N1LGTqoPKNg7KN2YIouQe5yjKc7JHKZnmeYqblWw= 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=kZtmHb6Vd871dGQw7vYaA7gYaO72jUSEkiFx3RoxbwtMi4Tbu0kammqDFR3/5R h4AOJVv1KGjCnwerVb2fRUIy7LKCBiXEH5hzciR3oXTbsa33AYvrtKTJl60NWGEH qLb5ndIxvPXXBsVAjtJT9qqovb1+X4+0qghuZ3IU4nI14=; Received: (qmail 5406 invoked by alias); 29 Nov 2012 13:52:27 -0000 Received: (qmail 5393 invoked by uid 22791); 29 Nov 2012 13:52:25 -0000 X-SWARE-Spam-Status: No, hits=-4.8 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, SUBJ_ALL_CAPS 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; Thu, 29 Nov 2012 13:52:20 +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 0ABD2A24CA for ; Thu, 29 Nov 2012 14:52:19 +0100 (CET) Date: Thu, 29 Nov 2012 14:48:14 +0100 (CET) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] PRE TLC 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 When working on PR55124 I noticed we do some useless work in PRE. This cleans it up and makes it more obvious what we do in compute_avail. Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk. Richard. 2012-11-29 Richard Biener * tree-ssa-pre.c (get_expr_value_id): Do not add expr to the set of value expressions here. (add_to_exp_gen, make_values_for_phi): Fold into ... (compute_avail): ... here, and avoid useless work. Dump avail sets in processing order. (do_pre): Do not dump avail sets here. Index: gcc/tree-ssa-pre.c =================================================================== --- gcc/tree-ssa-pre.c (revision 193932) +++ gcc/tree-ssa-pre.c (working copy) @@ -612,28 +612,28 @@ bitmap_set_new (void) static unsigned int get_expr_value_id (pre_expr expr) { + unsigned int id; switch (expr->kind) { case CONSTANT: - { - unsigned int id; - id = get_constant_value_id (PRE_EXPR_CONSTANT (expr)); - if (id == 0) - { - id = get_or_alloc_constant_value_id (PRE_EXPR_CONSTANT (expr)); - add_to_value (id, expr); - } - return id; - } + id = get_or_alloc_constant_value_id (PRE_EXPR_CONSTANT (expr)); + break; case NAME: - return VN_INFO (PRE_EXPR_NAME (expr))->value_id; + id = VN_INFO (PRE_EXPR_NAME (expr))->value_id; + break; case NARY: - return PRE_EXPR_NARY (expr)->value_id; + id = PRE_EXPR_NARY (expr)->value_id; + break; case REFERENCE: - return PRE_EXPR_REFERENCE (expr)->value_id; + id = PRE_EXPR_REFERENCE (expr)->value_id; + break; default: gcc_unreachable (); } + /* ??? We cannot assert that expr has a value-id (it can be 0), because + we assign value-ids only to expressions that have a result + in set_hashtable_value_ids. */ + return id; } /* Return a SCCVN valnum (SSA name or constant) for the PRE value-id VAL. */ @@ -3624,48 +3624,6 @@ insert (void) } -/* Add OP to EXP_GEN (block), and possibly to the maximal set. */ - -static void -add_to_exp_gen (basic_block block, tree op) -{ - pre_expr result; - - if (TREE_CODE (op) == SSA_NAME && ssa_undefined_value_p (op)) - return; - - result = get_or_alloc_expr_for_name (op); - bitmap_value_insert_into_set (EXP_GEN (block), result); -} - -/* Create value ids for PHI in BLOCK. */ - -static void -make_values_for_phi (gimple phi, basic_block block) -{ - tree result = gimple_phi_result (phi); - unsigned i; - - /* We have no need for virtual phis, as they don't represent - actual computations. */ - if (virtual_operand_p (result)) - return; - - pre_expr e = get_or_alloc_expr_for_name (result); - add_to_value (get_expr_value_id (e), e); - bitmap_value_insert_into_set (AVAIL_OUT (block), e); - bitmap_insert_into_set (PHI_GEN (block), e); - for (i = 0; i < gimple_phi_num_args (phi); ++i) - { - tree arg = gimple_phi_arg_def (phi, i); - if (TREE_CODE (arg) == SSA_NAME) - { - e = get_or_alloc_expr_for_name (arg); - add_to_value (get_expr_value_id (e), e); - } - } -} - /* Compute the AVAIL set for all basic blocks. This function performs value numbering of the statements in each basic @@ -3703,6 +3661,14 @@ compute_avail (void) bitmap_value_insert_into_set (AVAIL_OUT (ENTRY_BLOCK_PTR), e); } + if (dump_file && (dump_flags & TDF_DETAILS)) + { + print_bitmap_set (dump_file, TMP_GEN (ENTRY_BLOCK_PTR), + "tmp_gen", ENTRY_BLOCK); + print_bitmap_set (dump_file, AVAIL_OUT (ENTRY_BLOCK_PTR), + "avail_out", ENTRY_BLOCK); + } + /* Allocate the worklist. */ worklist = XNEWVEC (basic_block, n_basic_blocks); @@ -3731,7 +3697,19 @@ compute_avail (void) /* Generate values for PHI nodes. */ for (gsi = gsi_start_phis (block); !gsi_end_p (gsi); gsi_next (&gsi)) - make_values_for_phi (gsi_stmt (gsi), block); + { + tree result = gimple_phi_result (gsi_stmt (gsi)); + + /* We have no need for virtual phis, as they don't represent + actual computations. */ + if (virtual_operand_p (result)) + continue; + + pre_expr e = get_or_alloc_expr_for_name (result); + add_to_value (get_expr_value_id (e), e); + bitmap_value_insert_into_set (AVAIL_OUT (block), e); + bitmap_insert_into_set (PHI_GEN (block), e); + } BB_MAY_NOTRETURN (block) = 0; @@ -3775,7 +3753,12 @@ compute_avail (void) continue; FOR_EACH_SSA_TREE_OPERAND (op, stmt, iter, SSA_OP_USE) - add_to_exp_gen (block, op); + { + if (ssa_undefined_value_p (op)) + continue; + pre_expr e = get_or_alloc_expr_for_name (op); + bitmap_value_insert_into_set (EXP_GEN (block), e); + } switch (gimple_code (stmt)) { @@ -3911,6 +3894,18 @@ compute_avail (void) } } + if (dump_file && (dump_flags & TDF_DETAILS)) + { + print_bitmap_set (dump_file, EXP_GEN (block), + "exp_gen", block->index); + print_bitmap_set (dump_file, PHI_GEN (block), + "phi_gen", block->index); + print_bitmap_set (dump_file, TMP_GEN (block), + "tmp_gen", block->index); + print_bitmap_set (dump_file, AVAIL_OUT (block), + "avail_out", block->index); + } + /* Put the dominator children of BLOCK on the worklist of blocks to compute available sets for. */ for (son = first_dom_son (CDI_DOMINATORS, block); @@ -4667,22 +4662,6 @@ do_pre (void) /* Collect and value number expressions computed in each basic block. */ compute_avail (); - if (dump_file && (dump_flags & TDF_DETAILS)) - { - basic_block bb; - FOR_ALL_BB (bb) - { - print_bitmap_set (dump_file, EXP_GEN (bb), - "exp_gen", bb->index); - print_bitmap_set (dump_file, PHI_GEN (bb), - "phi_gen", bb->index); - print_bitmap_set (dump_file, TMP_GEN (bb), - "tmp_gen", bb->index); - print_bitmap_set (dump_file, AVAIL_OUT (bb), - "avail_out", bb->index); - } - } - /* Insert can get quite slow on an incredibly large number of basic blocks due to some quadratic behavior. Until this behavior is fixed, don't run it when he have an incredibly large number of