From: Eric Botcazou Date: Sun, 18 Apr 2010 21:49:29 +0000 (+0000) Subject: fold-const.c (fold_comparison): Use ssizetype. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=3b9e5d953c6c8f977035b600242efb26084d25be;p=gcc.git fold-const.c (fold_comparison): Use ssizetype. 2010-04-18  Eric Botcazou   * fold-const.c (fold_comparison): Use ssizetype. * gimple-fold.c (maybe_fold_offset_to_array_ref): Likewise. * ipa-prop.c (ipa_modify_call_arguments): Use sizetype. * tree-loop-distribution.c (build_size_arg_loc): Likewise. * tree-object-size.c (compute_object_sizes): Use size_type_node. * tree.h (initialize_sizetypes): Remove parameter. (build_common_tree_nodes): Remove second parameter. * stor-layout.c (initialize_sizetypes): Remove parameter. Always create an unsigned type. (set_sizetype): Assert that the passed type is unsigned and simplify. * tree.c (build_common_tree_nodes): Remove second parameter. Adjust call to initialize_sizetypes. * c-decl.c (c_init_decl_processing): Remove second argument in call to build_common_tree_nodes. cp/ * decl.c (cxx_init_decl_processing): Remove second argument in call to build_common_tree_nodes. java/ * decl.c (java_init_decl_processing): Remove argument in call to initialize_sizetypes fortran/ * f95-lang.c (gfc_init_decl_processing): Remove second argument in call to build_common_tree_nodes. ada/ * gcc-interface/misc.c (gnat_init): Remove second argument in call to build_common_tree_nodes. lto/ * lto-lang.c (lto_init): Remove second argument in call to build_common_tree_nodes. From-SVN: r158496 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 024b7e66c1b..2490cb2b0e4 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,21 @@ +2010-04-18 Eric Botcazou + + * fold-const.c (fold_comparison): Use ssizetype. + * gimple-fold.c (maybe_fold_offset_to_array_ref): Likewise. + * ipa-prop.c (ipa_modify_call_arguments): Use sizetype. + * tree-loop-distribution.c (build_size_arg_loc): Likewise. + * tree-object-size.c (compute_object_sizes): Use size_type_node. + + * tree.h (initialize_sizetypes): Remove parameter. + (build_common_tree_nodes): Remove second parameter. + * stor-layout.c (initialize_sizetypes): Remove parameter. + Always create an unsigned type. + (set_sizetype): Assert that the passed type is unsigned and simplify. + * tree.c (build_common_tree_nodes): Remove second parameter. + Adjust call to initialize_sizetypes. + * c-decl.c (c_init_decl_processing): Remove second argument in call to + build_common_tree_nodes. + 2010-04-18 Matthias Klose * gcc.c (main): Search for liblto_plugin.so with mode R_OK. diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index ee70230c08e..76aa31591c1 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,8 @@ +2010-04-18 Eric Botcazou + + * gcc-interface/misc.c (gnat_init): Remove second argument in call to + build_common_tree_nodes. + 2010-04-18 Ozkan Sezer * gsocket.h: Make sure that winsock2.h is included before windows.h. diff --git a/gcc/ada/gcc-interface/misc.c b/gcc/ada/gcc-interface/misc.c index b54598c4f97..41c61853c70 100644 --- a/gcc/ada/gcc-interface/misc.c +++ b/gcc/ada/gcc-interface/misc.c @@ -391,7 +391,7 @@ gnat_init (void) /* Do little here, most of the standard declarations are set up after the front-end has been run. Use the same `char' as C, this doesn't really matter since we'll use the explicit `unsigned char' for Character. */ - build_common_tree_nodes (flag_signed_char, false); + build_common_tree_nodes (flag_signed_char); /* In Ada, we use the unsigned type corresponding to the width of Pmode as SIZETYPE. In most cases when ptr_mode and Pmode differ, C will use the diff --git a/gcc/c-decl.c b/gcc/c-decl.c index bf8555715b0..230b4aada94 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -3454,7 +3454,7 @@ c_init_decl_processing (void) using preprocessed headers. */ input_location = BUILTINS_LOCATION; - build_common_tree_nodes (flag_signed_char, false); + build_common_tree_nodes (flag_signed_char); c_common_nodes_and_builtins (); diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 6a11a946300..0c59a92d3e3 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2010-04-18 Eric Botcazou + + * decl.c (cxx_init_decl_processing): Remove second argument in call to + build_common_tree_nodes. + 2010-04-14 Jason Merrill PR c++/36625 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 32aeda2b18b..c31aa5ccefc 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -3358,7 +3358,7 @@ cxx_init_decl_processing (void) tree void_ftype; tree void_ftype_ptr; - build_common_tree_nodes (flag_signed_char, false); + build_common_tree_nodes (flag_signed_char); /* Create all the identifiers we need. */ initialize_predefined_identifiers (); diff --git a/gcc/fold-const.c b/gcc/fold-const.c index c1af8248a39..85f9cd1fd91 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -8695,24 +8695,19 @@ fold_comparison (location_t loc, enum tree_code code, tree type, && ((code == EQ_EXPR || code == NE_EXPR) || POINTER_TYPE_OVERFLOW_UNDEFINED)) { - tree signed_size_type_node; - signed_size_type_node = signed_type_for (size_type_node); - /* By converting to signed size type we cover middle-end pointer arithmetic which operates on unsigned pointer types of size type size and ARRAY_REF offsets which are properly sign or zero extended from their type in case it is narrower than size type. */ if (offset0 == NULL_TREE) - offset0 = build_int_cst (signed_size_type_node, 0); + offset0 = build_int_cst (ssizetype, 0); else - offset0 = fold_convert_loc (loc, signed_size_type_node, - offset0); + offset0 = fold_convert_loc (loc, ssizetype, offset0); if (offset1 == NULL_TREE) - offset1 = build_int_cst (signed_size_type_node, 0); + offset1 = build_int_cst (ssizetype, 0); else - offset1 = fold_convert_loc (loc, signed_size_type_node, - offset1); + offset1 = fold_convert_loc (loc, ssizetype, offset1); if (code != EQ_EXPR && code != NE_EXPR diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 377fe183f51..61297f9f12c 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,12 +1,17 @@ +2010-04-18 Eric Botcazou + + * f95-lang.c (gfc_init_decl_processing): Remove second argument in call + to build_common_tree_nodes. + 2010-04-17 Steven G. Kargl - PR fortran/31538 - * fortran/trans-array.c (gfc_conv_ss_startstride): Remove the use of - gfc_msg_bounds by using 'Array bound mismatch' directly. - (gfc_trans_dummy_array_bias): Remove the use of gfc_msg_bounds. Reword - error message to include the mismatch in the extent of array bound. - * fortran/trans.c: Remove gfc_msg_bounds. It is only used in one place. - * fortran/trans.h: Remove extern definition of gfc_msg_bounds. + PR fortran/31538 + * fortran/trans-array.c (gfc_conv_ss_startstride): Remove the use of + gfc_msg_bounds by using 'Array bound mismatch' directly. + (gfc_trans_dummy_array_bias): Remove the use of gfc_msg_bounds. Reword + error message to include the mismatch in the extent of array bound. + * fortran/trans.c: Remove gfc_msg_bounds. It is only used in one place. + * fortran/trans.h: Remove extern definition of gfc_msg_bounds. 2010-04-17 Jerry DeLisle diff --git a/gcc/fortran/f95-lang.c b/gcc/fortran/f95-lang.c index 5d2846c8890..96ff8bb2ef3 100644 --- a/gcc/fortran/f95-lang.c +++ b/gcc/fortran/f95-lang.c @@ -542,7 +542,7 @@ gfc_init_decl_processing (void) /* Build common tree nodes. char_type_node is unsigned because we only use it for actual characters, not for INTEGER(1). Also, we want double_type_node to actually have double precision. */ - build_common_tree_nodes (false, false); + build_common_tree_nodes (false); /* x86_64 mingw32 has a sizetype of "unsigned long long", most other hosts have a sizetype of "unsigned long". Therefore choose the correct size in mostly target independent way. */ diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c index 270475c0c6c..ab076348be0 100644 --- a/gcc/gimple-fold.c +++ b/gcc/gimple-fold.c @@ -159,7 +159,7 @@ maybe_fold_offset_to_array_ref (location_t loc, tree base, tree offset, return NULL_TREE; /* Use signed size type for intermediate computation on the index. */ - idx_type = signed_type_for (size_type_node); + idx_type = ssizetype; /* If OFFSET and ELT_OFFSET are zero, we don't care about the size of the element type (so we can use the alignment if it's not constant). diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c index c6d58b1d452..ec9f63d89a7 100644 --- a/gcc/ipa-prop.c +++ b/gcc/ipa-prop.c @@ -1700,7 +1700,7 @@ ipa_modify_call_arguments (struct cgraph_edge *cs, gimple stmt, if (!useless_type_conversion_p (ptrtype, TREE_TYPE (expr))) expr = fold_convert (ptrtype, expr); expr = fold_build2 (POINTER_PLUS_EXPR, ptrtype, expr, - build_int_cst (size_type_node, + build_int_cst (sizetype, adj->offset / BITS_PER_UNIT)); if (!adj->by_ref) expr = fold_build1 (INDIRECT_REF, adj->type, expr); diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index f1a60807436..b88bd1974ed 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,3 +1,8 @@ +2010-04-18 Eric Botcazou + + * decl.c (java_init_decl_processing): Remove argument in call to + initialize_sizetypes + 2010-04-07 Jakub Jelinek * exception.cc (_Jv_Throw): Avoid set but not used warning. diff --git a/gcc/java/decl.c b/gcc/java/decl.c index c593b53df5c..4cd4d9668dc 100644 --- a/gcc/java/decl.c +++ b/gcc/java/decl.c @@ -579,7 +579,7 @@ java_init_decl_processing (void) TREE_TYPE (error_mark_node) = error_mark_node; /* Create sizetype first - needed for other types. */ - initialize_sizetypes (false); + initialize_sizetypes (); byte_type_node = make_signed_type (8); pushdecl (build_decl (BUILTINS_LOCATION, diff --git a/gcc/lto/ChangeLog b/gcc/lto/ChangeLog index 20b89d69761..464a2ef28c3 100644 --- a/gcc/lto/ChangeLog +++ b/gcc/lto/ChangeLog @@ -1,3 +1,8 @@ +2010-04-18 Eric Botcazou + + * lto-lang.c (lto_init): Remove second argument in call to + build_common_tree_nodes. + 2010-04-16 Rainer Orth * lto-elf.c [!HAVE_ELF_GETSHDRSTRNDX] (elf_getshdrstrndx): New diff --git a/gcc/lto/lto-lang.c b/gcc/lto/lto-lang.c index 05577a29371..aea5ab22d35 100644 --- a/gcc/lto/lto-lang.c +++ b/gcc/lto/lto-lang.c @@ -1039,7 +1039,7 @@ lto_init (void) linemap_add (line_table, LC_RENAME, 0, NULL, 0); /* Create the basic integer types. */ - build_common_tree_nodes (flag_signed_char, /*signed_sizetype=*/false); + build_common_tree_nodes (flag_signed_char); /* Share char_type_node with whatever would be the default for the target. char_type_node will be used for internal types such as diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c index 46ac3339803..151092c06a4 100644 --- a/gcc/stor-layout.c +++ b/gcc/stor-layout.c @@ -2214,37 +2214,35 @@ make_accum_type (int precision, int unsignedp, int satp) value to enable integer types to be created. */ void -initialize_sizetypes (bool signed_p) +initialize_sizetypes (void) { tree t = make_node (INTEGER_TYPE); int precision = GET_MODE_BITSIZE (SImode); SET_TYPE_MODE (t, SImode); TYPE_ALIGN (t) = GET_MODE_ALIGNMENT (SImode); - TYPE_USER_ALIGN (t) = 0; TYPE_IS_SIZETYPE (t) = 1; - TYPE_UNSIGNED (t) = !signed_p; + TYPE_UNSIGNED (t) = 1; TYPE_SIZE (t) = build_int_cst (t, precision); TYPE_SIZE_UNIT (t) = build_int_cst (t, GET_MODE_SIZE (SImode)); TYPE_PRECISION (t) = precision; - /* Set TYPE_MIN_VALUE and TYPE_MAX_VALUE. */ - set_min_and_max_values_for_integral_type (t, precision, !signed_p); + set_min_and_max_values_for_integral_type (t, precision, true); sizetype = t; bitsizetype = build_distinct_type_copy (t); } -/* Make sizetype a version of TYPE, and initialize *sizetype - accordingly. We do this by overwriting the stub sizetype and - bitsizetype nodes created by initialize_sizetypes. This makes sure - that (a) anything stubby about them no longer exists, (b) any - INTEGER_CSTs created with such a type, remain valid. */ +/* Make sizetype a version of TYPE, and initialize *sizetype accordingly. + We do this by overwriting the stub sizetype and bitsizetype nodes created + by initialize_sizetypes. This makes sure that (a) anything stubby about + them no longer exists and (b) any INTEGER_CSTs created with such a type, + remain valid. */ void set_sizetype (tree type) { - tree t; + tree t, max; int oprecision = TYPE_PRECISION (type); /* The *bitsizetype types use a precision that avoids overflows when calculating signed sizes / offsets in bits. However, when @@ -2257,11 +2255,11 @@ set_sizetype (tree type) if (precision > HOST_BITS_PER_WIDE_INT * 2) precision = HOST_BITS_PER_WIDE_INT * 2; - gcc_assert (TYPE_UNSIGNED (type) == TYPE_UNSIGNED (sizetype)); + /* sizetype must be an unsigned type. */ + gcc_assert (TYPE_UNSIGNED (type)); t = build_distinct_type_copy (type); - /* We do want to use sizetype's cache, as we will be replacing that - type. */ + /* We want to use sizetype's cache, as we will be replacing that type. */ TYPE_CACHED_VALUES (t) = TYPE_CACHED_VALUES (sizetype); TYPE_CACHED_VALUES_P (t) = TYPE_CACHED_VALUES_P (sizetype); TREE_TYPE (TYPE_CACHED_VALUES (t)) = type; @@ -2273,10 +2271,17 @@ set_sizetype (tree type) TYPE_MAIN_VARIANT (sizetype) = sizetype; TYPE_CANONICAL (sizetype) = sizetype; + /* sizetype is unsigned but we need to fix TYPE_MAX_VALUE so that it is + sign-extended in a way consistent with force_fit_type. */ + max = TYPE_MAX_VALUE (sizetype); + TYPE_MAX_VALUE (sizetype) + = build_int_cst_wide_type (sizetype, + TREE_INT_CST_LOW (max), + TREE_INT_CST_HIGH (max)); + t = make_node (INTEGER_TYPE); TYPE_NAME (t) = get_identifier ("bit_size_type"); - /* We do want to use bitsizetype's cache, as we will be replacing that - type. */ + /* We want to use bitsizetype's cache, as we will be replacing that type. */ TYPE_CACHED_VALUES (t) = TYPE_CACHED_VALUES (bitsizetype); TYPE_CACHED_VALUES_P (t) = TYPE_CACHED_VALUES_P (bitsizetype); TYPE_PRECISION (t) = precision; @@ -2288,36 +2293,13 @@ set_sizetype (tree type) TYPE_MAIN_VARIANT (bitsizetype) = bitsizetype; TYPE_CANONICAL (bitsizetype) = bitsizetype; - if (TYPE_UNSIGNED (type)) - { - fixup_unsigned_type (bitsizetype); - ssizetype = make_signed_type (oprecision); - TYPE_IS_SIZETYPE (ssizetype) = 1; - sbitsizetype = make_signed_type (precision); - TYPE_IS_SIZETYPE (sbitsizetype) = 1; - } - else - { - fixup_signed_type (bitsizetype); - ssizetype = sizetype; - sbitsizetype = bitsizetype; - } - - /* If SIZETYPE is unsigned, we need to fix TYPE_MAX_VALUE so that - it is sign extended in a way consistent with force_fit_type. */ - if (TYPE_UNSIGNED (type)) - { - tree orig_max, new_max; + fixup_unsigned_type (bitsizetype); - orig_max = TYPE_MAX_VALUE (sizetype); - - /* Build a new node with the same values, but a different type. - Sign extend it to ensure consistency. */ - new_max = build_int_cst_wide_type (sizetype, - TREE_INT_CST_LOW (orig_max), - TREE_INT_CST_HIGH (orig_max)); - TYPE_MAX_VALUE (sizetype) = new_max; - } + /* Create the signed variants of *sizetype. */ + ssizetype = make_signed_type (oprecision); + TYPE_IS_SIZETYPE (ssizetype) = 1; + sbitsizetype = make_signed_type (precision); + TYPE_IS_SIZETYPE (sbitsizetype) = 1; } /* TYPE is an integral type, i.e., an INTEGRAL_TYPE, ENUMERAL_TYPE diff --git a/gcc/tree-loop-distribution.c b/gcc/tree-loop-distribution.c index 384e43c770c..fbab7db9676 100644 --- a/gcc/tree-loop-distribution.c +++ b/gcc/tree-loop-distribution.c @@ -227,12 +227,9 @@ build_size_arg_loc (location_t loc, tree nb_iter, tree op, gimple_seq *stmt_list) { gimple_seq stmts; - tree x; - - x = fold_build2_loc (loc, MULT_EXPR, size_type_node, - fold_convert_loc (loc, size_type_node, nb_iter), - fold_convert_loc (loc, size_type_node, - TYPE_SIZE_UNIT (TREE_TYPE (op)))); + tree x = size_binop_loc (loc, MULT_EXPR, + fold_convert_loc (loc, sizetype, nb_iter), + TYPE_SIZE_UNIT (TREE_TYPE (op))); x = force_gimple_operand (x, &stmts, true, NULL); gimple_seq_add_seq (stmt_list, stmts); diff --git a/gcc/tree-object-size.c b/gcc/tree-object-size.c index 135342d58b0..2892e84600c 100644 --- a/gcc/tree-object-size.c +++ b/gcc/tree-object-size.c @@ -1203,7 +1203,8 @@ compute_object_sizes (void) result = fold_convert (size_type_node, integer_minus_one_node); else if (object_size_type < 4) - result = size_zero_node; + result = fold_convert (size_type_node, + integer_zero_node); } } diff --git a/gcc/tree.c b/gcc/tree.c index 6ac13186675..0eab137863b 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -8747,12 +8747,12 @@ make_or_reuse_accum_type (unsigned size, int unsignedp, int satp) this function to select one of the types as sizetype. */ void -build_common_tree_nodes (bool signed_char, bool signed_sizetype) +build_common_tree_nodes (bool signed_char) { error_mark_node = make_node (ERROR_MARK); TREE_TYPE (error_mark_node) = error_mark_node; - initialize_sizetypes (signed_sizetype); + initialize_sizetypes (); /* Define both `signed char' and `unsigned char'. */ signed_char_type_node = make_signed_type (CHAR_TYPE_SIZE); diff --git a/gcc/tree.h b/gcc/tree.h index ee6f1a4f598..d900dc08638 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -3967,7 +3967,7 @@ extern tree make_unsigned_type (int); extern tree signed_or_unsigned_type_for (int, tree); extern tree signed_type_for (tree); extern tree unsigned_type_for (tree); -extern void initialize_sizetypes (bool); +extern void initialize_sizetypes (void); extern void set_sizetype (tree); extern void fixup_unsigned_type (tree); extern tree build_pointer_type_for_mode (tree, enum machine_mode, bool); @@ -4981,7 +4981,7 @@ extern int real_onep (const_tree); extern int real_twop (const_tree); extern int real_minus_onep (const_tree); extern void init_ttree (void); -extern void build_common_tree_nodes (bool, bool); +extern void build_common_tree_nodes (bool); extern void build_common_tree_nodes_2 (int); extern void build_common_builtin_nodes (void); extern tree build_nonstandard_integer_type (unsigned HOST_WIDE_INT, int);