From patchwork Fri Oct 7 16:38:48 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kai Tietz X-Patchwork-Id: 118347 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 B0653B70C1 for ; Sat, 8 Oct 2011 03:39:10 +1100 (EST) Received: (qmail 14682 invoked by alias); 7 Oct 2011 16:39:06 -0000 Received: (qmail 14341 invoked by uid 22791); 7 Oct 2011 16:39:04 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, TW_TM X-Spam-Check-By: sourceware.org Received: from mail-vw0-f47.google.com (HELO mail-vw0-f47.google.com) (209.85.212.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 07 Oct 2011 16:38:49 +0000 Received: by vwe42 with SMTP id 42so3778314vwe.20 for ; Fri, 07 Oct 2011 09:38:48 -0700 (PDT) MIME-Version: 1.0 Received: by 10.52.31.41 with SMTP id x9mr3468923vdh.42.1318005528554; Fri, 07 Oct 2011 09:38:48 -0700 (PDT) Received: by 10.220.180.5 with HTTP; Fri, 7 Oct 2011 09:38:48 -0700 (PDT) Date: Fri, 7 Oct 2011 18:38:48 +0200 Message-ID: Subject: [patch tree-optimization]: 0 of 6 Improve reassoc for bitwise operations From: Kai Tietz To: GCC Patches Cc: Richard Guenther X-IsSubscribed: yes 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 Hello, This patch does rename break_up_subtract_bb to break_up_expr_bb, and it modifies build_and_add_sum so that unary expression can be created by it, too. The patch is a prerequisit of the following 6 additional patches. ChangeLog 2011-10-07 Kai Tietz * tree-ssa-reassoc.c (break_up_subtract_bb): Rename to (break_up_expr_bb): as function name. (build_and_add_sum): Add support for unary statement creation. Index: gcc/gcc/tree-ssa-reassoc.c =================================================================== --- gcc.orig/gcc/tree-ssa-reassoc.c +++ gcc/gcc/tree-ssa-reassoc.c @@ -44,6 +44,9 @@ along with GCC; see the file COPYING3. #include "params.h" #include "diagnostic-core.h" +/* Forwarders. */ +static gimple build_and_add_sum (tree, tree, tree, enum tree_code); + /* This is a simple global reassociation pass. It is, in part, based on the LLVM pass of the same name (They do some things more/less than we do, in different orders, etc). @@ -1018,8 +1021,8 @@ zero_one_operation (tree *def, enum tree while (1); } -/* Builds one statement performing OP1 OPCODE OP2 using TMPVAR for - the result. Places the statement after the definition of either +/* Builds one statement performing OP1 OPCODE OP2, or OPCODE OP1 using + TMPVAR for the result. Places the statement after the definition of either OP1 or OP2. Returns the new statement. */ static gimple @@ -1038,7 +1041,7 @@ build_and_add_sum (tree tmpvar, tree op1 /* Find an insertion place and insert. */ if (TREE_CODE (op1) == SSA_NAME) op1def = SSA_NAME_DEF_STMT (op1); - if (TREE_CODE (op2) == SSA_NAME) + if (op2 && TREE_CODE (op2) == SSA_NAME) op2def = SSA_NAME_DEF_STMT (op2); if ((!op1def || gimple_nop_p (op1def)) && (!op2def || gimple_nop_p (op2def))) @@ -2777,7 +2780,7 @@ can_reassociate_p (tree op) En passant, clear the GIMPLE visited flag on every statement. */ static void -break_up_subtract_bb (basic_block bb) +break_up_expr_bb (basic_block bb) { gimple_stmt_iterator gsi; basic_block son; @@ -2812,7 +2815,7 @@ break_up_subtract_bb (basic_block bb) for (son = first_dom_son (CDI_DOMINATORS, bb); son; son = next_dom_son (CDI_DOMINATORS, son)) - break_up_subtract_bb (son); + break_up_expr_bb (son); } /* Reassociate expressions in basic block BB and its post-dominator as @@ -2981,7 +2984,7 @@ debug_ops_vector (VEC (operand_entry_t, static void do_reassoc (void) { - break_up_subtract_bb (ENTRY_BLOCK_PTR); + break_up_expr_bb (ENTRY_BLOCK_PTR); reassociate_bb (EXIT_BLOCK_PTR); }