diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a0b92c9af7e..c892de94bc7 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,17 @@ +2007-01-08 Richard Guenther + + * tree-ssa-ccp.c (maybe_fold_offset_to_array_ref): Use type + of offset to build the index. + * tree-pretty-print.c (dump_generic_node): Don't build negated + const just for printing. + * c-pretty-print.c (pp_c_integer_constant): Likewise. + * builtins.c (fold_builtin_int_roundingfn): Check if result + fits the type by using force_fit_type and comparing the result. + * predict.c (predict_loops): Use compare_tree_int for comparison. + * tree.c (build_int_cst): Fall back to integer_type_node for + NULL_TREE type. + (build_int_cst_wide): Assert type is non-null. + 2007-01-08 Roberto Costa * tree-vrp.c (extract_range_from_cond_expr): New. diff --git a/gcc/builtins.c b/gcc/builtins.c index 6f79b2931bf..e97e3bb57cb 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -7602,9 +7602,11 @@ fold_builtin_int_roundingfn (tree fndecl, tree arglist) } REAL_VALUE_TO_INT (&lo, &hi, r); - result = build_int_cst_wide (NULL_TREE, lo, hi); - if (int_fits_type_p (result, itype)) - return fold_convert (itype, result); + result = build_int_cst_wide (itype, lo, hi); + result = force_fit_type (result, 0, false, false); + if (TREE_INT_CST_LOW (result) == lo + && TREE_INT_CST_HIGH (result) == hi) + return result; } } diff --git a/gcc/c-pretty-print.c b/gcc/c-pretty-print.c index 56b2b47a569..e7ca1246b35 100644 --- a/gcc/c-pretty-print.c +++ b/gcc/c-pretty-print.c @@ -810,17 +810,16 @@ pp_c_integer_constant (c_pretty_printer *pp, tree i) pp_wide_integer (pp, TREE_INT_CST_LOW (i)); else { + unsigned HOST_WIDE_INT low = TREE_INT_CST_LOW (i); + HOST_WIDE_INT high = TREE_INT_CST_HIGH (i); if (tree_int_cst_sgn (i) < 0) { pp_character (pp, '-'); - i = build_int_cst_wide (NULL_TREE, - -TREE_INT_CST_LOW (i), - ~TREE_INT_CST_HIGH (i) - + !TREE_INT_CST_LOW (i)); + high = ~high + !low; + low = -low; } sprintf (pp_buffer (pp)->digit_buffer, - HOST_WIDE_INT_PRINT_DOUBLE_HEX, - TREE_INT_CST_HIGH (i), TREE_INT_CST_LOW (i)); + HOST_WIDE_INT_PRINT_DOUBLE_HEX, high, low); pp_string (pp, pp_buffer (pp)->digit_buffer); } if (TYPE_UNSIGNED (type)) diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 5ec612c06ab..a31c8ace3df 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,8 @@ +2007-01-08 Richard Guenther + + * trans-io.c (transfer_array_desc): Use build_int_cst instead + of build_int_cstu. + 2007-01-08 Roger Sayle * trans-array.c (constant_array_constructor_p): New function to diff --git a/gcc/fortran/trans-io.c b/gcc/fortran/trans-io.c index b24a2f262bf..654c0fad807 100644 --- a/gcc/fortran/trans-io.c +++ b/gcc/fortran/trans-io.c @@ -1779,7 +1779,7 @@ transfer_array_desc (gfc_se * se, gfc_typespec * ts, tree addr_expr) if (ts->type == BT_CHARACTER) charlen_arg = se->string_length; else - charlen_arg = build_int_cstu (NULL_TREE, 0); + charlen_arg = build_int_cst (NULL_TREE, 0); kind_arg = build_int_cst (NULL_TREE, ts->kind); diff --git a/gcc/predict.c b/gcc/predict.c index 534258f39ce..61d8547def0 100644 --- a/gcc/predict.c +++ b/gcc/predict.c @@ -662,8 +662,7 @@ predict_loops (void) int probability; int max = PARAM_VALUE (PARAM_MAX_PREDICTED_ITERATIONS); if (host_integerp (niter, 1) - && tree_int_cst_lt (niter, - build_int_cstu (NULL_TREE, max - 1))) + && compare_tree_int (niter, max-1) == -1) { HOST_WIDE_INT nitercst = tree_low_cst (niter, 1) + 1; probability = ((REG_BR_PROB_BASE + nitercst / 2) diff --git a/gcc/tree-pretty-print.c b/gcc/tree-pretty-print.c index 7d895a1b4c7..d9d4b968a32 100644 --- a/gcc/tree-pretty-print.c +++ b/gcc/tree-pretty-print.c @@ -748,23 +748,20 @@ dump_generic_node (pretty_printer *buffer, tree node, int spc, int flags, else if (! host_integerp (node, 0)) { tree val = node; + unsigned HOST_WIDE_INT low = TREE_INT_CST_LOW (val); + HOST_WIDE_INT high = TREE_INT_CST_HIGH (val); if (tree_int_cst_sgn (val) < 0) { pp_character (buffer, '-'); - val = build_int_cst_wide (NULL_TREE, - -TREE_INT_CST_LOW (val), - ~TREE_INT_CST_HIGH (val) - + !TREE_INT_CST_LOW (val)); + high = ~high + !low; + low = -low; } /* Would "%x%0*x" or "%x%*0x" get zero-padding on all systems? */ - { - sprintf (pp_buffer (buffer)->digit_buffer, HOST_WIDE_INT_PRINT_DOUBLE_HEX, - TREE_INT_CST_HIGH (val), - TREE_INT_CST_LOW (val)); - pp_string (buffer, pp_buffer (buffer)->digit_buffer); - } + sprintf (pp_buffer (buffer)->digit_buffer, + HOST_WIDE_INT_PRINT_DOUBLE_HEX, high, low); + pp_string (buffer, pp_buffer (buffer)->digit_buffer); } else pp_wide_integer (buffer, TREE_INT_CST_LOW (node)); diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c index 0f02b8c8651..617a2cf6643 100644 --- a/gcc/tree-ssa-ccp.c +++ b/gcc/tree-ssa-ccp.c @@ -1608,7 +1608,7 @@ maybe_fold_offset_to_array_ref (tree base, tree offset, tree orig_type) || lrem || hrem) return NULL_TREE; - idx = build_int_cst_wide (NULL_TREE, lquo, hquo); + idx = build_int_cst_wide (TREE_TYPE (offset), lquo, hquo); } /* Assume the low bound is zero. If there is a domain type, get the diff --git a/gcc/tree.c b/gcc/tree.c index 71d221ee486..e3eb4be8b05 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -752,6 +752,10 @@ copy_list (tree list) tree build_int_cst (tree type, HOST_WIDE_INT low) { + /* Support legacy code. */ + if (!type) + type = integer_type_node; + return build_int_cst_wide (type, low, low < 0 ? -1 : 0); } @@ -864,8 +868,7 @@ build_int_cst_wide (tree type, unsigned HOST_WIDE_INT low, HOST_WIDE_INT hi) int ix = -1; int limit = 0; - if (!type) - type = integer_type_node; + gcc_assert (type); switch (TREE_CODE (type)) {