diff options
author | Richard Kenner <kenner@vlsi1.ultra.nyu.edu> | 2000-03-07 11:41:32 +0000 |
---|---|---|
committer | Richard Kenner <kenner@gcc.gnu.org> | 2000-03-07 06:41:32 -0500 |
commit | 05bccae2efd712562a20afadfc2889d87323e7ca (patch) | |
tree | eedf389b906e1f6d1fda0e405c46b8b47fb6d064 /gcc/expr.c | |
parent | ddf0fc6c9f1eb8747c9cf6b69e48f11f779632d2 (diff) | |
download | gcc-05bccae2efd712562a20afadfc2889d87323e7ca.zip gcc-05bccae2efd712562a20afadfc2889d87323e7ca.tar.gz gcc-05bccae2efd712562a20afadfc2889d87323e7ca.tar.bz2 |
tree.h (INT_CST_LT, [...]): Remove unneeded casts.
* tree.h (INT_CST_LT, INT_CST_LT_UNSIGNED): Remove unneeded casts.
(struct tree_int_cst): int_cst_low is now unsigned HOST_WIDE_INT.
(attribute_hash_list, type_hash_canon): hashcode is now unsigned.
(type_hash_lookup, type_hash_add, type_hash_list): Likewise.
(min_precision): Result is unsignd.
(add_double, neg_double, mul_double): Low word is unsigned.
(lshift_double, rshift_double, lrotate_double): Likewise.
(rrotate_double, div_and_round_double): Likewise.
(tree_floor_log2, compare_tree_int): New functions.
(preserve_rtl_expr_temps): New declaration.
* c-common.c (declare_hidden_char_array): Use compare_tree_int.
(decl_attributes): Use tree_log2 to find alignment.
Check for TREE_INT_CST_HIGH for format args.
(min_precision): Now unsigned.
Use tree_floor_log2.
(truthvalue_conversion): Delete long-disabled code.
* c-decl.c (finish_struct): Clean up tests on field width.
(finish_function): Use compare_tree_int.
* c-pragma.c (handle_pragma_token): Use tree_log2 for alignment.
* c-typeck.c (comptypes): Use tree_int_cst_equal.
(default_conversion, digest_init): Use compare_tree_int.
(build_binary_op): Use integer_all_onesp and compare_tree_int.
Fix type errors in forming masks.
* calls.c (initialize_argument_information): Use compare_tree_int.
* dbxout.c (dbxout_type): Cast TREE_INT_CST_LOW to HOST_WIDE_INT.
* except.c (expand_eh_region_start_tree): Use compare_tree_int.
* expr.c (is_zeros_p, case INTEGER_CST): Use integer_zerop.
(store_field): Use compare_tree_int.
(expand_expr, case CONSTRUCTOR): Use TYPE_SIZE_UNIT.
(expand_expr, case ARRAY_REF): Use compare_tree_int.
(do_jump, case BIT_AND_EXPR): Use tree_floor_log2.
(do_store_flag): Use compare_tree_int.
* fold-const.c (encode, decode): Low part is always unsigned.
(force_fit_type, add_double, neg_double, mul_double): Likewise.
(lshift_double, rshift_double, lrotate_double): Likewise.
(rrotate_double, div_and_round_double, int_const_binop): Likewise.
(fold_convert): Use compare_tree_int.
(operand_equal_p, case INTEGER_CST): Use tree_int_cst_equal.
(invert_truthvalue, case INTEGER_CST): Likewise.
(fold): Use compare_tree_int; add casts for unsigned TREE_INT_CST_LOW.
* mkdeps.c (deps_dummy_targets): Make I unsigned.
* rtl.h (add_double, neg_double, mul_double): Low words are unsigned.
(lshift_double, rshift_double, lrotate_double, rrotate_double):
Likewise.
* stmt.c (expand_decl): Use compare_tree_int and mode_for_size_tree.
(expand_end_case): Use compare_tree_int.
(estimate_case_costs): Cast TREE_INT_CST_LOW to HOST_WIDE_INT.
* stor-layout.c (mode_for_size_tree): Use compare_tree_int.
(layout_decl): Likewise.
(layout_record, layout_union): Make sizes unsigned.
(layout_type, case VOID_TYPE): TYPE_SIZE must be bitsizetype.
(layout_type, case QUAL_UNION_TYPE): Use compare_tree_int.
* tree.c (struct type_hash): hashcode is unsigned.
(build_type_attribute_variant, type_hash_list): Likewise.
(type_hash_lookup, type_hash_add, type_hash_canon): Likewise.
(attribute_hash_list, build_array_type, build_method_type): Likewise.
(build_complex_type): Likewise.
(real_value_from_int_cst): Remove unneeded casts.
(integer_all_onesp): Add casts.
(tree_floor_log2, compare_tree_int): New functions.
(build_index_type): Use tree_int_cst_sgn.
* varasm.c (assemble_variable): Use compare_tree_int.
* ch/actions.c (chill_convert_for_assignment): INDEX is unsigned
HOST_WIDE_INT.
* ch/ch-tree.h (DECL_NESTING_LEVEL): Use TREE_INT_CST_HIGH
since unsigned.
* ch/except.c (chill_handle_on_labels): ALTERNATIVE is unsigned.
Use compare_tree_int.
(expand_goto_except_cleanup): Likewise.
* cp/class.c (dfs_modify_vtables): I is now unsigned.
(check_bitfield_decl): Use tree_int_cst_sgn and compare_tree_int.
(build_base_field): Add casts of TREE_INT_CST_LOW to HOST_WIDE_INT.
* cp/error.c (dump_expr): Cast TREE_INT_CST_HIGH to unsigned.
* cp/init.c (build_vec_init): Cast TREE_INT_CST_LOW to HOST_WIDE_INT.
* cp/method.c (build_overload_int): Cast TREE_INT_CST_HIGH to unsigned.
* cp/typeck.c (build_binary_op, case TRUNC_DIV_EXPR):
Call integer_all_onesp.
* cp/typeck2.c (process_init_constructor): Use compare_tree_int.
* f/com.c (ffecom_f2c_set_lio_code_): Use compare_tree_int.
(ffecom_sym_transform_, ffecom_transform_common_): Likewise.
(ffecom_transform_equiv_): Likewise.
* java/decl.c (emit_init_test_initialization): Mark KEY as unused.
* java/expr.c (build_newarray): Cast TREE_INT_CST_LOW to HOST_WIDE_INT.
(build_anewarray): Likewise.
* java/parse.y (patch_newarray): Likewise.
* java/parse.c: Regenerated.
From-SVN: r32383
Diffstat (limited to 'gcc/expr.c')
-rw-r--r-- | gcc/expr.c | 137 |
1 files changed, 69 insertions, 68 deletions
@@ -3979,7 +3979,7 @@ is_zeros_p (exp) return is_zeros_p (TREE_OPERAND (exp, 0)); case INTEGER_CST: - return TREE_INT_CST_LOW (exp) == 0 && TREE_INT_CST_HIGH (exp) == 0; + return integer_zerop (exp); case COMPLEX_CST: return @@ -4317,14 +4317,15 @@ store_constructor (exp, target, align, cleared, size) { tree lo_index = TREE_OPERAND (index, 0); tree hi_index = TREE_OPERAND (index, 1); + if (TREE_CODE (lo_index) != INTEGER_CST || TREE_CODE (hi_index) != INTEGER_CST) { need_to_clear = 1; break; } - this_node_count = TREE_INT_CST_LOW (hi_index) - - TREE_INT_CST_LOW (lo_index) + 1; + this_node_count = (TREE_INT_CST_LOW (hi_index) + - TREE_INT_CST_LOW (lo_index) + 1); } else this_node_count = 1; @@ -4594,8 +4595,8 @@ store_constructor (exp, target, align, cleared, size) ? nbits != 1 : (TREE_CODE (TREE_VALUE (elt)) != INTEGER_CST || TREE_CODE (TREE_PURPOSE (elt)) != INTEGER_CST - || (TREE_INT_CST_LOW (TREE_VALUE (elt)) - - TREE_INT_CST_LOW (TREE_PURPOSE (elt)) + 1 + || ((HOST_WIDE_INT) TREE_INT_CST_LOW (TREE_VALUE (elt)) + - (HOST_WIDE_INT) TREE_INT_CST_LOW (TREE_PURPOSE (elt)) + 1 != nbits)))) clear_storage (target, expr_size (exp), TYPE_ALIGN (type) / BITS_PER_UNIT); @@ -4777,10 +4778,9 @@ store_field (target, bitsize, bitpos, mode, exp, value_mode, /* If the RHS and field are a constant size and the size of the RHS isn't the same size as the bitfield, we must use bitfield operations. */ - || ((bitsize >= 0 - && TREE_CODE (TYPE_SIZE (TREE_TYPE (exp))) == INTEGER_CST) - && (TREE_INT_CST_HIGH (TYPE_SIZE (TREE_TYPE (exp))) != 0 - || TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (exp))) != bitsize))) + || (bitsize >= 0 + && TREE_CODE (TYPE_SIZE (TREE_TYPE (exp))) == INTEGER_CST + && compare_tree_int (TYPE_SIZE (TREE_TYPE (exp)), bitsize) != 0)) { rtx temp = expand_expr (exp, NULL_RTX, VOIDmode, 0); @@ -6008,8 +6008,7 @@ expand_expr (exp, target, tmode, modifier) case INTEGER_CST: return immed_double_const (TREE_INT_CST_LOW (exp), - TREE_INT_CST_HIGH (exp), - mode); + TREE_INT_CST_HIGH (exp), mode); case CONST_DECL: return expand_expr (DECL_INITIAL (exp), target, VOIDmode, @@ -6333,9 +6332,10 @@ expand_expr (exp, target, tmode, modifier) && ((mode == BLKmode && ! (target != 0 && safe_from_p (target, exp, 1))) || TREE_ADDRESSABLE (exp) - || (TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST - && (!MOVE_BY_PIECES_P - (TREE_INT_CST_LOW (TYPE_SIZE (type))/BITS_PER_UNIT, + || (TREE_CODE (TYPE_SIZE_UNIT (type)) == INTEGER_CST + && TREE_INT_CST_HIGH (TYPE_SIZE_UNIT (type)) == 0 + && (! MOVE_BY_PIECES_P + (TREE_INT_CST_LOW (TYPE_SIZE_UNIT (type)), TYPE_ALIGN (type) / BITS_PER_UNIT)) && ! mostly_zeros_p (exp)))) || (modifier == EXPAND_INITIALIZER && TREE_CONSTANT (exp))) @@ -6385,18 +6385,17 @@ expand_expr (exp, target, tmode, modifier) tree exp2; tree index; tree string = string_constant (exp1, &index); - int i; /* Try to optimize reads from const strings. */ if (string && TREE_CODE (string) == STRING_CST && TREE_CODE (index) == INTEGER_CST - && !TREE_INT_CST_HIGH (index) - && (i = TREE_INT_CST_LOW (index)) < TREE_STRING_LENGTH (string) + && compare_tree_int (index, TREE_STRING_LENGTH (string)) < 0 && GET_MODE_CLASS (mode) == MODE_INT && GET_MODE_SIZE (mode) == 1 && modifier != EXPAND_MEMORY_USE_WO) - return GEN_INT (TREE_STRING_POINTER (string)[i]); + return + GEN_INT (TREE_STRING_POINTER (string)[TREE_INT_CST_LOW (index)]); op0 = expand_expr (exp1, NULL_RTX, VOIDmode, EXPAND_SUM); op0 = memory_address (mode, op0); @@ -6481,31 +6480,33 @@ expand_expr (exp, target, tmode, modifier) if (TREE_CODE (array) == STRING_CST && TREE_CODE (index) == INTEGER_CST - && !TREE_INT_CST_HIGH (index) - && (i = TREE_INT_CST_LOW (index)) < TREE_STRING_LENGTH (array) + && compare_tree_int (index, TREE_STRING_LENGTH (array)) < 0 && GET_MODE_CLASS (mode) == MODE_INT && GET_MODE_SIZE (mode) == 1) - return GEN_INT (TREE_STRING_POINTER (array)[i]); + return + GEN_INT (TREE_STRING_POINTER (array)[TREE_INT_CST_LOW (index)]); /* If this is a constant index into a constant array, just get the value from the array. Handle both the cases when we have an explicit constructor and when our operand is a variable that was declared const. */ - if (TREE_CODE (array) == CONSTRUCTOR && ! TREE_SIDE_EFFECTS (array)) + if (TREE_CODE (array) == CONSTRUCTOR && ! TREE_SIDE_EFFECTS (array) + && TREE_CODE (index) == INTEGER_CST + && 0 > compare_tree_int (index, + list_length (CONSTRUCTOR_ELTS + (TREE_OPERAND (exp, 0))))) { - if (TREE_CODE (index) == INTEGER_CST - && TREE_INT_CST_HIGH (index) == 0) - { - tree elem = CONSTRUCTOR_ELTS (TREE_OPERAND (exp, 0)); - - i = TREE_INT_CST_LOW (index); - while (elem && i--) - elem = TREE_CHAIN (elem); - if (elem) - return expand_expr (fold (TREE_VALUE (elem)), target, - tmode, ro_modifier); - } + tree elem; + + for (elem = CONSTRUCTOR_ELTS (TREE_OPERAND (exp, 0)), + i = TREE_INT_CST_LOW (index); + elem != 0 && i != 0; i--, elem = TREE_CHAIN (elem)) + ; + + if (elem) + return expand_expr (fold (TREE_VALUE (elem)), target, + tmode, ro_modifier); } else if (optimize >= 1 @@ -6517,22 +6518,22 @@ expand_expr (exp, target, tmode, modifier) { tree init = DECL_INITIAL (array); - i = TREE_INT_CST_LOW (index); if (TREE_CODE (init) == CONSTRUCTOR) { tree elem = CONSTRUCTOR_ELTS (init); - while (elem - && !tree_int_cst_equal (TREE_PURPOSE (elem), index)) - elem = TREE_CHAIN (elem); + for (elem = CONSTRUCTOR_ELTS (init); + ! tree_int_cst_equal (TREE_PURPOSE (elem), index); + elem = TREE_CHAIN (elem)) + ; + if (elem) return expand_expr (fold (TREE_VALUE (elem)), target, tmode, ro_modifier); } else if (TREE_CODE (init) == STRING_CST - && TREE_INT_CST_HIGH (index) == 0 - && (TREE_INT_CST_LOW (index) - < TREE_STRING_LENGTH (init))) + && 0 > compare_tree_int (index, + TREE_STRING_LENGTH (init))) return (GEN_INT (TREE_STRING_POINTER (init)[TREE_INT_CST_LOW (index)])); @@ -6763,10 +6764,8 @@ expand_expr (exp, target, tmode, modifier) || ((bitsize >= 0 && (TREE_CODE (TYPE_SIZE (TREE_TYPE (exp))) == INTEGER_CST) - && ((TREE_INT_CST_HIGH (TYPE_SIZE (TREE_TYPE (exp))) - != 0) - || (TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (exp))) - != bitsize)))))) + && 0 != compare_tree_int (TYPE_SIZE (TREE_TYPE (exp)), + bitsize))))) || (modifier != EXPAND_CONST_ADDRESS && modifier != EXPAND_INITIALIZER && mode == BLKmode @@ -8153,8 +8152,8 @@ expand_expr (exp, target, tmode, modifier) || TREE_CODE (rhs) == BIT_AND_EXPR) && TREE_OPERAND (rhs, 0) == lhs && TREE_CODE (TREE_OPERAND (rhs, 1)) == COMPONENT_REF - && TREE_INT_CST_LOW (DECL_SIZE (TREE_OPERAND (lhs, 1))) == 1 - && TREE_INT_CST_LOW (DECL_SIZE (TREE_OPERAND (TREE_OPERAND (rhs, 1), 1))) == 1) + && integer_onep (DECL_SIZE (TREE_OPERAND (lhs, 1))) + && integer_onep (DECL_SIZE (TREE_OPERAND (TREE_OPERAND (rhs, 1), 1)))) { rtx label = gen_label_rtx (); @@ -8539,20 +8538,20 @@ expand_expr_unaligned (exp, palign) we have an explicit constructor and when our operand is a variable that was declared const. */ - if (TREE_CODE (array) == CONSTRUCTOR && ! TREE_SIDE_EFFECTS (array)) + if (TREE_CODE (array) == CONSTRUCTOR && ! TREE_SIDE_EFFECTS (array) + && 0 > compare_tree_int (index, + list_length (CONSTRUCTOR_ELTS + (TREE_OPERAND (exp, 0))))) { - if (TREE_CODE (index) == INTEGER_CST - && TREE_INT_CST_HIGH (index) == 0) - { - tree elem = CONSTRUCTOR_ELTS (TREE_OPERAND (exp, 0)); - - i = TREE_INT_CST_LOW (index); - while (elem && i--) - elem = TREE_CHAIN (elem); - if (elem) - return expand_expr_unaligned (fold (TREE_VALUE (elem)), - palign); - } + tree elem; + + for (elem = CONSTRUCTOR_ELTS (TREE_OPERAND (exp, 0)), + i = TREE_INT_CST_LOW (index); + elem != 0 && i != 0; i--, elem = TREE_CHAIN (elem)) + ; + + if (elem) + return expand_expr_unaligned (fold (TREE_VALUE (elem)), palign); } else if (optimize >= 1 @@ -8564,14 +8563,15 @@ expand_expr_unaligned (exp, palign) { tree init = DECL_INITIAL (array); - i = TREE_INT_CST_LOW (index); if (TREE_CODE (init) == CONSTRUCTOR) { - tree elem = CONSTRUCTOR_ELTS (init); + tree elem; + + for (elem = CONSTRUCTOR_ELTS (init); + ! tree_int_cst_equal (TREE_PURPOSE (elem), index); + elem = TREE_CHAIN (elem)) + ; - while (elem - && !tree_int_cst_equal (TREE_PURPOSE (elem), index)) - elem = TREE_CHAIN (elem); if (elem) return expand_expr_unaligned (fold (TREE_VALUE (elem)), palign); @@ -9289,7 +9289,7 @@ do_jump (exp, if_false_label, if_true_label) if (! SLOW_BYTE_ACCESS && TREE_CODE (TREE_OPERAND (exp, 1)) == INTEGER_CST && TYPE_PRECISION (TREE_TYPE (exp)) <= HOST_BITS_PER_WIDE_INT - && (i = floor_log2 (TREE_INT_CST_LOW (TREE_OPERAND (exp, 1)))) >= 0 + && (i = tree_floor_log2 (TREE_OPERAND (exp, 1))) >= 0 && (mode = mode_for_size (i + 1, MODE_INT, 0)) != BLKmode && (type = type_for_mode (mode, 1)) != 0 && TYPE_PRECISION (type) < TYPE_PRECISION (TREE_TYPE (exp)) @@ -10204,8 +10204,9 @@ do_store_flag (exp, target, mode, only_cheap) if (TREE_CODE (inner) == RSHIFT_EXPR && TREE_CODE (TREE_OPERAND (inner, 1)) == INTEGER_CST && TREE_INT_CST_HIGH (TREE_OPERAND (inner, 1)) == 0 - && (bitnum + TREE_INT_CST_LOW (TREE_OPERAND (inner, 1)) - < TYPE_PRECISION (type))) + && bitnum < TYPE_PRECISION (type) + && 0 > compare_tree_int (TREE_OPERAND (inner, 1), + bitnum - TYPE_PRECISION (type))) { bitnum += TREE_INT_CST_LOW (TREE_OPERAND (inner, 1)); inner = TREE_OPERAND (inner, 0); |