From patchwork Wed Jul 14 20:53:59 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anatoly Sokolov X-Patchwork-Id: 58931 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 958AFB6EEF for ; Thu, 15 Jul 2010 06:54:09 +1000 (EST) Received: (qmail 16847 invoked by alias); 14 Jul 2010 20:54:08 -0000 Received: (qmail 16828 invoked by uid 22791); 14 Jul 2010 20:54:06 -0000 X-SWARE-Spam-Status: No, hits=2.0 required=5.0 tests=AWL, BAYES_40, KAM_THEBAT, RCVD_IN_DNSWL_NONE, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from contrabass.post.ru (HELO contrabass.post.ru) (85.21.78.5) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 14 Jul 2010 20:53:59 +0000 Received: from corbina.ru (mail.post.ru [195.14.50.16]) by contrabass.post.ru (Postfix) with ESMTP id A90BA8AD2; Thu, 15 Jul 2010 00:53:55 +0400 (MSD) Received: from [95.25.136.2] (account aesok@post.ru HELO Vista.corbina.ru) by corbina.ru (CommuniGate Pro SMTP 5.1.14) with ESMTPA id 232930532; Thu, 15 Jul 2010 00:53:55 +0400 Date: Thu, 15 Jul 2010 00:53:59 +0400 From: Anatoly Sokolov Message-ID: <126591474.20100715005359@post.ru> To: gcc-patches@gcc.gnu.org CC: Richard Guenther Subject: [PATCH] Use common tree nodes instead of call build_int_cst MIME-Version: 1.0 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 use pre-build tree nodes instead of call build_int_cst function when it is possible. Bootstrapped/regtested on x86_64-unknown-linux-gnu for c, c++ and ada. OK for mainline? * tree.h (enum tree_index): Add TI_INTEGER_THREE. (integer_three_node): Add. * tree.c (build_common_tree_nodes_2): Use integer_type_node insead of NULL_TREE in build_int_cst calls. Initialize the integer_three_node. * builtins.c (expand_builtin_prefetch): Use common tree nodes instead of call build_int_cst. * tree-ssa-sccvn.c (copy_reference_ops_from_ref): (Ditto.). * tree-ssa-loop-ivopts.c (idx_find_step): (Ditto.). (find_interesting_uses_address): (Ditto.). * tree-ssa-alias.c (ao_ref_init_from_ptr_and_size): (Ditto.). * tree-eh.c (lower_eh_constructs_2): (Ditto.). * tree-vect-loop.c (get_initial_def_for_induction ): (Ditto.). * c-typeck.c (really_start_incremental_init, push_init_level): (Ditto.). * expmed.c (expand_divmod): (Ditto.). * tree-mudflap.c (mx_register_decls): (Ditto.). * varasm.c (array_size_for_constructor): (Ditto.). * tree-ssa-loop-prefetch.c (issue_prefetch_ref): (Ditto.). * c-parser.c (c_parser_postfix_expression): (Ditto.). /cp * decl.c (integer_three_node): Remove. (cxx_init_decl_processing): Do not initialize the integer_three_node. cp-tree.h (integer_three_node): Remove. Anatoly. Index: gcc/tree.c =================================================================== --- gcc/tree.c (revision 162083) +++ gcc/tree.c (working copy) @@ -8969,9 +8969,10 @@ build_common_tree_nodes_2 (int short_double) { /* Define these next since types below may used them. */ - integer_zero_node = build_int_cst (NULL_TREE, 0); - integer_one_node = build_int_cst (NULL_TREE, 1); - integer_minus_one_node = build_int_cst (NULL_TREE, -1); + integer_zero_node = build_int_cst (integer_type_node, 0); + integer_one_node = build_int_cst (integer_type_node, 1); + integer_three_node = build_int_cst (integer_type_node, 3); + integer_minus_one_node = build_int_cst (integer_type_node, -1); size_zero_node = size_int (0); size_one_node = size_int (1); Index: gcc/tree.h =================================================================== --- gcc/tree.h (revision 162083) +++ gcc/tree.h (working copy) @@ -3526,6 +3526,7 @@ TI_INTEGER_ZERO, TI_INTEGER_ONE, + TI_INTEGER_THREE, TI_INTEGER_MINUS_ONE, TI_NULL_POINTER, @@ -3680,6 +3681,7 @@ #define integer_zero_node global_trees[TI_INTEGER_ZERO] #define integer_one_node global_trees[TI_INTEGER_ONE] +#define integer_three_node global_trees[TI_INTEGER_THREE] #define integer_minus_one_node global_trees[TI_INTEGER_MINUS_ONE] #define size_zero_node global_trees[TI_SIZE_ZERO] #define size_one_node global_trees[TI_SIZE_ONE] Index: gcc/builtins.c =================================================================== --- gcc/builtins.c (revision 162083) +++ gcc/builtins.c (working copy) @@ -1056,7 +1056,7 @@ if (nargs > 2) arg2 = CALL_EXPR_ARG (exp, 2); else - arg2 = build_int_cst (NULL_TREE, 3); + arg2 = integer_three_node; /* Argument 0 is an address. */ op0 = expand_expr (arg0, NULL_RTX, Pmode, EXPAND_NORMAL); Index: gcc/tree-ssa-sccvn.c =================================================================== --- gcc/tree-ssa-sccvn.c (revision 162083) +++ gcc/tree-ssa-sccvn.c (working copy) @@ -564,7 +564,7 @@ base = TMR_SYMBOL (ref) ? TMR_SYMBOL (ref) : TMR_BASE (ref); if (!base) - base = build_int_cst (ptr_type_node, 0); + base = null_pointer_node; memset (&temp, 0, sizeof (temp)); /* We do not care for spurious type qualifications. */ Index: gcc/cp/decl.c =================================================================== --- gcc/cp/decl.c (revision 162083) +++ gcc/cp/decl.c (working copy) @@ -169,9 +169,9 @@ /* -- end of C++ */ -/* A node for the integer constants 2, and 3. */ +/* A node for the integer constant 2. */ -tree integer_two_node, integer_three_node; +tree integer_two_node; /* Used only for jumps to as-yet undefined labels, since jumps to defined labels can have their validity checked immediately. */ @@ -3439,7 +3439,6 @@ java_boolean_type_node = record_builtin_java_type ("__java_boolean", -1); integer_two_node = build_int_cst (NULL_TREE, 2); - integer_three_node = build_int_cst (NULL_TREE, 3); record_builtin_type (RID_BOOL, "bool", boolean_type_node); truthvalue_type_node = boolean_type_node; Index: gcc/cp/cp-tree.h =================================================================== --- gcc/cp/cp-tree.h (revision 162083) +++ gcc/cp/cp-tree.h (working copy) @@ -4001,7 +4001,6 @@ /* For building calls to `delete'. */ extern GTY(()) tree integer_two_node; -extern GTY(()) tree integer_three_node; /* The number of function bodies which we are currently processing. (Zero if we are at namespace scope, one inside the body of a Index: gcc/tree-ssa-loop-ivopts.c =================================================================== --- gcc/tree-ssa-loop-ivopts.c (revision 162083) +++ gcc/tree-ssa-loop-ivopts.c (working copy) @@ -1418,7 +1418,7 @@ } else /* The step for pointer arithmetics already is 1 byte. */ - step = build_int_cst (sizetype, 1); + step = size_one_node; iv_base = iv->base; iv_step = iv->step; @@ -1611,7 +1611,7 @@ static void find_interesting_uses_address (struct ivopts_data *data, gimple stmt, tree *op_p) { - tree base = *op_p, step = build_int_cst (sizetype, 0); + tree base = *op_p, step = size_zero_node; struct iv *civ; struct ifs_ivopts_data ifs_ivopts_data; @@ -1669,7 +1669,7 @@ { ifs_ivopts_data.ivopts_data = data; ifs_ivopts_data.stmt = stmt; - ifs_ivopts_data.step = build_int_cst (sizetype, 0); + ifs_ivopts_data.step = size_zero_node; if (!for_each_index (&base, idx_find_step, &ifs_ivopts_data) || integer_zerop (ifs_ivopts_data.step)) goto fail; Index: gcc/tree-ssa-alias.c =================================================================== --- gcc/tree-ssa-alias.c (revision 162083) +++ gcc/tree-ssa-alias.c (working copy) @@ -517,7 +517,7 @@ else { ref->base = build2 (MEM_REF, char_type_node, - ptr, build_int_cst (ptr_type_node, 0)); + ptr, null_pointer_node); ref->offset = 0; } if (size Index: gcc/tree-eh.c =================================================================== --- gcc/tree-eh.c (revision 162083) +++ gcc/tree-eh.c (working copy) @@ -1877,7 +1877,7 @@ else { /* The user has dome something silly. Remove it. */ - rhs = build_int_cst (ptr_type_node, 0); + rhs = null_pointer_node; goto do_replace; } break; Index: gcc/tree-vect-loop.c =================================================================== --- gcc/tree-vect-loop.c (revision 162083) +++ gcc/tree-vect-loop.c (working copy) @@ -2608,7 +2608,7 @@ if (INTEGRAL_TYPE_P (scalar_type)) step_expr = build_int_cst (scalar_type, 0); else if (POINTER_TYPE_P (scalar_type)) - step_expr = build_int_cst (sizetype, 0); + step_expr = size_zero_node; else step_expr = build_real (scalar_type, dconst0); Index: gcc/c-typeck.c =================================================================== --- gcc/c-typeck.c (revision 162083) +++ gcc/c-typeck.c (working copy) @@ -6498,14 +6498,14 @@ /* Detect non-empty initializations of zero-length arrays. */ if (constructor_max_index == NULL_TREE && TYPE_SIZE (constructor_type)) - constructor_max_index = build_int_cst (NULL_TREE, -1); + constructor_max_index = integer_minus_one_node; /* constructor_max_index needs to be an INTEGER_CST. Attempts to initialize VLAs will cause a proper error; avoid tree checking errors as well by setting a safe value. */ if (constructor_max_index && TREE_CODE (constructor_max_index) != INTEGER_CST) - constructor_max_index = build_int_cst (NULL_TREE, -1); + constructor_max_index = integer_minus_one_node; constructor_index = convert (bitsizetype, @@ -6706,14 +6706,14 @@ /* Detect non-empty initializations of zero-length arrays. */ if (constructor_max_index == NULL_TREE && TYPE_SIZE (constructor_type)) - constructor_max_index = build_int_cst (NULL_TREE, -1); + constructor_max_index = integer_minus_one_node; /* constructor_max_index needs to be an INTEGER_CST. Attempts to initialize VLAs will cause a proper error; avoid tree checking errors as well by setting a safe value. */ if (constructor_max_index && TREE_CODE (constructor_max_index) != INTEGER_CST) - constructor_max_index = build_int_cst (NULL_TREE, -1); + constructor_max_index = integer_minus_one_node; constructor_index = convert (bitsizetype, Index: gcc/expmed.c =================================================================== --- gcc/expmed.c (revision 162083) +++ gcc/expmed.c (working copy) @@ -4191,10 +4191,8 @@ t2 = force_operand (gen_rtx_MINUS (compute_mode, op0, t1), NULL_RTX); - t3 = expand_shift - (RSHIFT_EXPR, compute_mode, t2, - build_int_cst (NULL_TREE, 1), - NULL_RTX,1); + t3 = expand_shift (RSHIFT_EXPR, compute_mode, t2, + integer_one_node, NULL_RTX,1); t4 = force_operand (gen_rtx_PLUS (compute_mode, t1, t3), NULL_RTX); @@ -4878,8 +4876,7 @@ } tem = plus_constant (op1, -1); tem = expand_shift (RSHIFT_EXPR, compute_mode, tem, - build_int_cst (NULL_TREE, 1), - NULL_RTX, 1); + integer_one_node, NULL_RTX, 1); do_cmp_and_jump (remainder, tem, LEU, compute_mode, label); expand_inc (quotient, const1_rtx); expand_dec (remainder, op1); @@ -4904,8 +4901,7 @@ abs_rem = expand_abs (compute_mode, remainder, NULL_RTX, 1, 0); abs_op1 = expand_abs (compute_mode, op1, NULL_RTX, 1, 0); tem = expand_shift (LSHIFT_EXPR, compute_mode, abs_rem, - build_int_cst (NULL_TREE, 1), - NULL_RTX, 1); + integer_one_node, NULL_RTX, 1); do_cmp_and_jump (tem, abs_op1, LTU, compute_mode, label); tem = expand_binop (compute_mode, xor_optab, op0, op1, NULL_RTX, 0, OPTAB_WIDEN); Index: gcc/tree-mudflap.c =================================================================== --- gcc/tree-mudflap.c (revision 162083) +++ gcc/tree-mudflap.c (working copy) @@ -1074,7 +1074,7 @@ unregister_fncall = gimple_build_call (mf_unregister_fndecl, 3, unregister_fncall_param, size, - build_int_cst (NULL_TREE, 3)); + integer_three_node); variable_name = mf_varname_tree (decl); @@ -1087,7 +1087,7 @@ register_fncall = gimple_build_call (mf_register_fndecl, 4, register_fncall_param, size, - build_int_cst (NULL_TREE, 3), + integer_three_node, variable_name); Index: gcc/varasm.c =================================================================== --- gcc/varasm.c (revision 162083) +++ gcc/varasm.c (working copy) @@ -4914,7 +4914,7 @@ tmp = TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (val))); i = size_binop (MINUS_EXPR, fold_convert (sizetype, max_index), fold_convert (sizetype, tmp)); - i = size_binop (PLUS_EXPR, i, build_int_cst (sizetype, 1)); + i = size_binop (PLUS_EXPR, i, size_one_node); /* Multiply by the array element unit size to find number of bytes. */ i = size_binop (MULT_EXPR, i, TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (val)))); Index: gcc/tree-ssa-loop-prefetch.c =================================================================== --- gcc/tree-ssa-loop-prefetch.c (revision 162083) +++ gcc/tree-ssa-loop-prefetch.c (working copy) @@ -1083,7 +1083,7 @@ addr_base = force_gimple_operand_gsi (&bsi, unshare_expr (addr_base), true, NULL, true, GSI_SAME_STMT); write_p = ref->write_p ? integer_one_node : integer_zero_node; - local = build_int_cst (integer_type_node, nontemporal ? 0 : 3); + local = nontemporal ? integer_zero_node : integer_three_node; for (ap = 0; ap < n_prefetches; ap++) { Index: gcc/c-parser.c =================================================================== --- gcc/c-parser.c (revision 162083) +++ gcc/c-parser.c (working copy) @@ -5847,9 +5847,8 @@ e1 = TYPE_MAIN_VARIANT (groktypename (t1, NULL, NULL)); e2 = TYPE_MAIN_VARIANT (groktypename (t2, NULL, NULL)); - expr.value = comptypes (e1, e2) - ? build_int_cst (NULL_TREE, 1) - : build_int_cst (NULL_TREE, 0); + expr.value + = comptypes (e1, e2) ? integer_one_node : integer_zero_node; } break; case RID_AT_SELECTOR: