From d99d10ca756add0d0e00fc54d635b5d31b050f73 Mon Sep 17 00:00:00 2001 From: rsandifo Date: Tue, 10 Dec 2013 18:06:04 +0000 Subject: [PATCH] Remove INT_CST_LT and INT_CST_LE. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/wide-int@205867 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog.wide-int | 41 ++++++++++++++++++++++++----------------- gcc/c-family/c-common.c | 8 ++++---- gcc/c-family/cilk.c | 2 +- gcc/cp/call.c | 4 ++-- gcc/cp/class.c | 26 +++++++++++++------------- gcc/cp/decl.c | 2 +- gcc/fold-const.c | 2 +- gcc/java/expr.c | 2 +- gcc/targhooks.c | 2 +- gcc/tree-ssa-uninit.c | 8 ++++---- gcc/tree-vrp.c | 2 +- gcc/tree.c | 21 ++------------------- gcc/tree.h | 34 +++++++++++++++++++++++++++++----- 13 files changed, 84 insertions(+), 70 deletions(-) diff --git a/gcc/ChangeLog.wide-int b/gcc/ChangeLog.wide-int index 116f4546219..b5f88b2c5b0 100644 --- a/gcc/ChangeLog.wide-int +++ b/gcc/ChangeLog.wide-int @@ -250,7 +250,7 @@ tree_int_cst_min_precision and real_from_integer. (fold_negate_const): Use wide-int interfaces. (fold_abs_const): Likewise. - (fold_relational_const): Remove dead INT_CST_LT_UNSIGNED. + (fold_relational_const): Use tree_int_cst_lt. (round_up_loc): Use wide-int interfaces. * genemit.c (gen_exp): Add CONST_WIDE_INT case. @@ -487,7 +487,7 @@ * targhooks.h (can_use_doloop_if_innermost): Take widest_ints rather than double_ints. * targhooks.c - (default_cxx_get_cookie_size): Uses INT_CST_LT rather than + (default_cxx_get_cookie_size): Use tree_int_cst_lt rather than INT_CST_LT_UNSIGNED. (can_use_doloop_if_innermost): Take widest_ints rather than double_ints. @@ -562,9 +562,9 @@ (build_type_attribute_qual_variant): Use wide_int interfaces. (type_hash_eq): Likewise (tree_int_cst_equal): Likewise. - (tree_int_cst_lt): Likewise. + (tree_int_cst_lt): Delete. (tree_int_cst_compare): Likewise. - (tree_fits_shwi_p): Likewise. + (tree_fits_shwi_p): Use wide_int interfaces. (tree_fits_uhwi_p): Likewise. (tree_int_cst_sign_bit): Likewise. (tree_int_cst_sgn): Likewise. @@ -572,8 +572,9 @@ (simple_cst_equal): Use wide_int interfaces. (compare_tree_int): Likewise. (iterative_hash_expr): Likewise. - (int_fits_type_p): Likewise. - (get_type_static_bounds): Likewise. + (int_fits_type_p): Likewise. Use tree_int_cst_lt rather than + INT_CST_LT. + (get_type_static_bounds): Use wide_int interfaces. (tree_int_cst_elt_check_failed): New. (build_common_tree_nodes): Reordered to set prec before filling in value. @@ -619,8 +620,7 @@ (TREE_INT_CST_EXT_NUNITS): Likewise. (TREE_INT_CST_OFFSET_NUNITS): Likewise. (TREE_INT_CST_ELT): Likewise. - (INT_CST_LT): Use wide-int interfaces. - (INT_CST_LE): New. + (INT_CST_LT): Delete. (tree_int_cst_elt_check): New (two forms). (type_code_size): Update comment. (make_int_cst_stat, make_int_cst): New. @@ -629,6 +629,9 @@ (force_fit_type_double): Delete. (build_int_cstu): Replace with out-of-line function. (build_int_cst_wide): Delete. + (tree_int_cst_lt): Define inline. + (tree_int_cst_le): New. + (tree_int_cst_compare): Define inline. (tree_int_cst_min_precision): Take a signop rather than a bool. (wi::int_traits ): New. (wi::int_traits ): New. @@ -801,7 +804,8 @@ * tree-ssa-structalias.c (get_constraint_for_ptr_offset): Use wide-int interfaces. * tree-ssa-uninit.c - (is_value_included_in): Use wide-int interfaces. + (is_value_included_in): Use wide-int interfaces, tree_int_cst_lt + and tree_int_cst_le. * tree-streamer-in.c (unpack_ts_base_value_fields): Use wide-int interfaces. (streamer_alloc_tree): Likewise. @@ -827,8 +831,8 @@ * tree-vect-patterns.c (vect_recog_divmod_pattern): Use wide-int interfaces. * tree-vrp.c: Include wide-int.h. - (operand_less_p): Use wide-int interfaces. - (extract_range_from_assert): Likewise. + (operand_less_p): Use wide-int interfaces and tree_int_cst_lt. + (extract_range_from_assert): Use wide-int interfaces. (vrp_int_const_binop): Likewise. (zero_nonzero_bits_from_vr): Take wide_int pointers rather than double_int pointers. @@ -900,8 +904,8 @@ c-family: (ADA_HOST_WIDE_INT_PRINT_DOUBLE_HEX): Remove. (dump_generic_ada_node): Use wide-int interfaces. * c-common.c: Include wide-int-print.h. - (shorten_compare): Use wide-int interfaces. - (pointer_int_sum): Likewise. + (shorten_compare): Use wide-int interfaces and tree_int_cst_lt. + (pointer_int_sum): Use wide-int interfaces. (c_common_nodes_and_builtins): Use make_int_cst. (match_case_to_enum_1): Use tree_fits_uhwi_p and tree_fits_shwi_p. (handle_alloc_size_attribute): Use wide-int interfaces. @@ -917,21 +921,24 @@ c-family: * c-pretty-print.c: Include wide-int.h. (pp_c_integer_constant): Use wide-int interfaces. * cilk.c - (declare_one_free_variable): Use INT_CST_LT instead of + (declare_one_free_variable): Use tree_int_cst_lt instead of INT_CST_LT_UNSIGNED. cp: * call.c: Include wide-int.h. - (type_passed_as): Use INT_CST_LT instead of INT_CST_LT_UNSIGNED. + (type_passed_as): Use tree_int_cst_lt instead of INT_CST_LT_UNSIGNED. (convert_for_arg_passing): Likewise. * class.c: Include wide-int.h. - (end_of_class): Use INT_CST_LT instead of INT_CST_LT_UNSIGNED. + (walk_subobject_offsets): Use tree_int_cst_lt instead of INT_CST_LT. + (end_of_class): Use tree_int_cst_lt instead of INT_CST_LT_UNSIGNED. (include_empty_classes): Likewise + (layout_class_type): Use tree_int_cst_lt instead of INT_CST_LT. * cvt.c: Include wide-int.h. (ignore_overflows): Use wide_int_to_tree. * decl.c: Include wide-int.h. (check_array_designated_initializer): Use wide-int interfaces. + (compute_array_index_type): Use tree_int_cst_lt instead of INT_CST_LT. (finish_enum_value_list): Use signop. (build_enumerator): Use wide-int interfaces. * init.c: Include wide-int.h. @@ -982,7 +989,7 @@ java: * expr.c: Include wide-int.h. (build_newarray): Remove bogus "== INTEGER_CST". (expand_java_pushc): Use real_from_integer. - (build_field_ref): Use INT_CST_LT instead of INT_CST_LT_UNSIGNED. + (build_field_ref): Use tree_int_cst_lt instead of INT_CST_LT_UNSIGNED. * jcf-parse.c: Include wide-int.h. (get_constant): Use wide-int interfaces. diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index c0fc8bea293..da4837c1dfe 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -4123,10 +4123,10 @@ shorten_compare (tree *op0_ptr, tree *op1_ptr, tree *restype_ptr, maxval = convert (*restype_ptr, maxval); } - min_gt = INT_CST_LT (primop1, minval); - max_gt = INT_CST_LT (primop1, maxval); - min_lt = INT_CST_LT (minval, primop1); - max_lt = INT_CST_LT (maxval, primop1); + min_gt = tree_int_cst_lt (primop1, minval); + max_gt = tree_int_cst_lt (primop1, maxval); + min_lt = tree_int_cst_lt (minval, primop1); + max_lt = tree_int_cst_lt (maxval, primop1); val = 0; /* This used to be a switch, but Genix compiler can't handle that. */ diff --git a/gcc/c-family/cilk.c b/gcc/c-family/cilk.c index ab3f121f601..13b27f1787b 100644 --- a/gcc/c-family/cilk.c +++ b/gcc/c-family/cilk.c @@ -666,7 +666,7 @@ declare_one_free_variable (const void *var0, void **map0, /* Maybe promote to int. */ if (INTEGRAL_TYPE_P (var_type) && COMPLETE_TYPE_P (var_type) - && INT_CST_LT (TYPE_SIZE (var_type), TYPE_SIZE (integer_type_node))) + && tree_int_cst_lt (TYPE_SIZE (var_type), TYPE_SIZE (integer_type_node))) arg_type = integer_type_node; else arg_type = var_type; diff --git a/gcc/cp/call.c b/gcc/cp/call.c index ec99995ddd8..b0b1a61cb24 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -6496,7 +6496,7 @@ type_passed_as (tree type) else if (targetm.calls.promote_prototypes (type) && INTEGRAL_TYPE_P (type) && COMPLETE_TYPE_P (type) - && INT_CST_LT (TYPE_SIZE (type), TYPE_SIZE (integer_type_node))) + && tree_int_cst_lt (TYPE_SIZE (type), TYPE_SIZE (integer_type_node))) type = integer_type_node; return type; @@ -6536,7 +6536,7 @@ convert_for_arg_passing (tree type, tree val, tsubst_flags_t complain) else if (targetm.calls.promote_prototypes (type) && INTEGRAL_TYPE_P (type) && COMPLETE_TYPE_P (type) - && INT_CST_LT (TYPE_SIZE (type), TYPE_SIZE (integer_type_node))) + && tree_int_cst_lt (TYPE_SIZE (type), TYPE_SIZE (integer_type_node))) val = cp_perform_integral_promotions (val, complain); if ((complain & tf_warning) && warn_suggest_attribute_format) diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 6b2efbf43cb..7520f72f680 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -3742,7 +3742,7 @@ walk_subobject_offsets (tree type, /* If this OFFSET is bigger than the MAX_OFFSET, then we should stop. */ - if (max_offset && INT_CST_LT (max_offset, offset)) + if (max_offset && tree_int_cst_lt (max_offset, offset)) return 0; if (type == error_mark_node) @@ -3899,8 +3899,8 @@ walk_subobject_offsets (tree type, for (index = size_zero_node; /* G++ 3.2 had an off-by-one error here. */ (abi_version_at_least (2) - ? !INT_CST_LT (TYPE_MAX_VALUE (domain), index) - : INT_CST_LT (index, TYPE_MAX_VALUE (domain))); + ? !tree_int_cst_lt (TYPE_MAX_VALUE (domain), index) + : tree_int_cst_lt (index, TYPE_MAX_VALUE (domain))); index = size_binop (PLUS_EXPR, index, size_one_node)) { r = walk_subobject_offsets (TREE_TYPE (type), @@ -3916,7 +3916,7 @@ walk_subobject_offsets (tree type, /* If this new OFFSET is bigger than the MAX_OFFSET, then there's no point in iterating through the remaining elements of the array. */ - if (max_offset && INT_CST_LT (max_offset, offset)) + if (max_offset && tree_int_cst_lt (max_offset, offset)) break; } } @@ -5830,7 +5830,7 @@ end_of_class (tree t, int include_virtuals_p) continue; offset = end_of_base (base_binfo); - if (INT_CST_LT (result, offset)) + if (tree_int_cst_lt (result, offset)) result = offset; } @@ -5840,7 +5840,7 @@ end_of_class (tree t, int include_virtuals_p) vec_safe_iterate (vbases, i, &base_binfo); i++) { offset = end_of_base (base_binfo); - if (INT_CST_LT (result, offset)) + if (tree_int_cst_lt (result, offset)) result = offset; } @@ -5920,7 +5920,7 @@ include_empty_classes (record_layout_info rli) CLASSTYPE_AS_BASE (rli->t) != NULL_TREE); rli_size = rli_size_unit_so_far (rli); if (TREE_CODE (rli_size) == INTEGER_CST - && INT_CST_LT (rli_size, eoc)) + && tree_int_cst_lt (rli_size, eoc)) { if (!abi_version_at_least (2)) /* In version 1 of the ABI, the size of a class that ends with @@ -6036,7 +6036,7 @@ layout_class_type (tree t, tree *virtuals_p) type, then there are some special rules for allocating it. */ if (DECL_C_BIT_FIELD (field) - && INT_CST_LT (TYPE_SIZE (type), DECL_SIZE (field))) + && tree_int_cst_lt (TYPE_SIZE (type), DECL_SIZE (field))) { unsigned int itk; tree integer_type; @@ -6047,10 +6047,10 @@ layout_class_type (tree t, tree *virtuals_p) bits as additional padding. */ for (itk = itk_char; itk != itk_none; ++itk) if (integer_types[itk] != NULL_TREE - && (INT_CST_LT (size_int (MAX_FIXED_MODE_SIZE), - TYPE_SIZE (integer_types[itk])) - || INT_CST_LT (DECL_SIZE (field), - TYPE_SIZE (integer_types[itk])))) + && (tree_int_cst_lt (size_int (MAX_FIXED_MODE_SIZE), + TYPE_SIZE (integer_types[itk])) + || tree_int_cst_lt (DECL_SIZE (field), + TYPE_SIZE (integer_types[itk])))) break; /* ITK now indicates a type that is too large for the @@ -6066,7 +6066,7 @@ layout_class_type (tree t, tree *virtuals_p) 3.2 always created a padding field, even if it had zero width. */ if (!abi_version_at_least (2) - || INT_CST_LT (TYPE_SIZE (integer_type), DECL_SIZE (field))) + || tree_int_cst_lt (TYPE_SIZE (integer_type), DECL_SIZE (field))) { if (abi_version_at_least (2) && TREE_CODE (t) == UNION_TYPE) /* In a union, the padding field must have the full width diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 8e0546e0bef..1092a4354e4 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -8316,7 +8316,7 @@ compute_array_index_type (tree name, tree size, tsubst_flags_t complain) constant_expression_error (size); /* An array must have a positive number of elements. */ - if (INT_CST_LT (size, integer_zero_node)) + if (tree_int_cst_lt (size, integer_zero_node)) { if (!(complain & tf_error)) return error_mark_node; diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 7ea6470ac99..a0d8e917d68 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -16409,7 +16409,7 @@ fold_relational_const (enum tree_code code, tree type, tree op0, tree op1) if (code == EQ_EXPR) result = tree_int_cst_equal (op0, op1); else - result = INT_CST_LT (op0, op1); + result = tree_int_cst_lt (op0, op1); } else return NULL_TREE; diff --git a/gcc/java/expr.c b/gcc/java/expr.c index 7ae852f5276..179bdad70f2 100644 --- a/gcc/java/expr.c +++ b/gcc/java/expr.c @@ -1718,7 +1718,7 @@ build_field_ref (tree self_value, tree self_class, tree name) tree field_offset = byte_position (field_decl); if (! page_size) page_size = size_int (4096); - check = ! INT_CST_LT (field_offset, page_size); + check = !tree_int_cst_lt (field_offset, page_size); } if (base_type != TREE_TYPE (self_value)) diff --git a/gcc/targhooks.c b/gcc/targhooks.c index 5b914e7df41..1e2b85fd574 100644 --- a/gcc/targhooks.c +++ b/gcc/targhooks.c @@ -290,7 +290,7 @@ default_cxx_get_cookie_size (tree type) sizetype_size = size_in_bytes (sizetype); type_align = size_int (TYPE_ALIGN_UNIT (type)); - if (INT_CST_LT (type_align, sizetype_size)) + if (tree_int_cst_lt (type_align, sizetype_size)) cookie_size = sizetype_size; else cookie_size = type_align; diff --git a/gcc/tree-ssa-uninit.c b/gcc/tree-ssa-uninit.c index 0f11a43d398..e456e26ae61 100644 --- a/gcc/tree-ssa-uninit.c +++ b/gcc/tree-ssa-uninit.c @@ -857,11 +857,11 @@ is_value_included_in (tree val, tree boundary, enum tree_code cmpc) if (cmpc == EQ_EXPR) result = tree_int_cst_equal (val, boundary); else if (cmpc == LT_EXPR) - result = INT_CST_LT (val, boundary); + result = tree_int_cst_lt (val, boundary); else { gcc_assert (cmpc == LE_EXPR); - result = INT_CST_LE (val, boundary); + result = tree_int_cst_le (val, boundary); } } else @@ -869,12 +869,12 @@ is_value_included_in (tree val, tree boundary, enum tree_code cmpc) if (cmpc == EQ_EXPR) result = tree_int_cst_equal (val, boundary); else if (cmpc == LT_EXPR) - result = INT_CST_LT (val, boundary); + result = tree_int_cst_lt (val, boundary); else { gcc_assert (cmpc == LE_EXPR); result = (tree_int_cst_equal (val, boundary) - || INT_CST_LT (val, boundary)); + || tree_int_cst_lt (val, boundary)); } } diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index 77254d83c1a..46585086b4a 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -1151,7 +1151,7 @@ operand_less_p (tree val, tree val2) { /* LT is folded faster than GE and others. Inline the common case. */ if (TREE_CODE (val) == INTEGER_CST && TREE_CODE (val2) == INTEGER_CST) - return INT_CST_LT (val, val2); + return tree_int_cst_lt (val, val2); else { tree tcmp; diff --git a/gcc/tree.c b/gcc/tree.c index 99128992431..8fa75425949 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -6951,23 +6951,6 @@ tree_int_cst_equal (const_tree t1, const_tree t2) return 0; } -/* Nonzero if integer constants T1 and T2 represent values that satisfy <. - The precise way of comparison depends on their data type. */ - -int -tree_int_cst_lt (const_tree t1, const_tree t2) -{ - return INT_CST_LT (t1, t2); -} - -/* Returns -1 if T1 < T2, 0 if T1 == T2, and 1 if T1 > T2. */ - -int -tree_int_cst_compare (const_tree t1, const_tree t2) -{ - return wi::cmps (wi::to_widest (t1), wi::to_widest (t2)); -} - /* Return true if T is an INTEGER_CST whose numerical value (extended according to TYPE_UNSIGNED) fits in a signed HOST_WIDE_INT. */ @@ -8557,7 +8540,7 @@ retry: /* Check if c >= type_low_bound. */ if (type_low_bound && TREE_CODE (type_low_bound) == INTEGER_CST) { - if (INT_CST_LT (c, type_low_bound)) + if (tree_int_cst_lt (c, type_low_bound)) return false; ok_for_low_bound = true; } @@ -8567,7 +8550,7 @@ retry: /* Check if c <= type_high_bound. */ if (type_high_bound && TREE_CODE (type_high_bound) == INTEGER_CST) { - if (INT_CST_LT (type_high_bound, c)) + if (tree_int_cst_lt (type_high_bound, c)) return false; ok_for_high_bound = true; } diff --git a/gcc/tree.h b/gcc/tree.h index 45470b737cc..e8909c60136 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -895,9 +895,6 @@ extern void omp_clause_range_check_failed (const_tree, const char *, int, #define TREE_INT_CST_LOW(NODE) \ ((unsigned HOST_WIDE_INT) TREE_INT_CST_ELT (NODE, 0)) -#define INT_CST_LT(A, B) (wi::lts_p (wi::to_widest (A), wi::to_widest (B))) -#define INT_CST_LE(A, B) (wi::les_p (wi::to_widest (A), wi::to_widest (B))) - #define TREE_REAL_CST_PTR(NODE) (REAL_CST_CHECK (NODE)->real_cst.real_cst_ptr) #define TREE_REAL_CST(NODE) (*TREE_REAL_CST_PTR (NODE)) @@ -3642,8 +3639,7 @@ extern tree chain_index (int, tree); extern int attribute_list_equal (const_tree, const_tree); extern int attribute_list_contained (const_tree, const_tree); extern int tree_int_cst_equal (const_tree, const_tree); -extern int tree_int_cst_lt (const_tree, const_tree); -extern int tree_int_cst_compare (const_tree, const_tree); + extern bool tree_fits_shwi_p (const_tree) #ifndef ENABLE_TREE_CHECKING ATTRIBUTE_PURE /* tree_fits_shwi_p is pure only when checking is disabled. */ @@ -4654,6 +4650,34 @@ wi::max_value (const_tree type) return max_value (TYPE_PRECISION (type), TYPE_SIGN (type)); } +/* Return true if INTEGER_CST T1 is less than INTEGER_CST T2, + extending both according to their respective TYPE_SIGNs. */ + +inline bool +tree_int_cst_lt (const_tree t1, const_tree t2) +{ + return wi::lts_p (wi::to_widest (t1), wi::to_widest (t2)); +} + +/* Return true if INTEGER_CST T1 is less than or equal to INTEGER_CST T2, + extending both according to their respective TYPE_SIGNs. */ + +inline bool +tree_int_cst_le (const_tree t1, const_tree t2) +{ + return wi::les_p (wi::to_widest (t1), wi::to_widest (t2)); +} + +/* Returns -1 if T1 < T2, 0 if T1 == T2, and 1 if T1 > T2. T1 and T2 + are both INTEGER_CSTs and their values are extended according to their + respective TYPE_SIGNs. */ + +inline int +tree_int_cst_compare (const_tree t1, const_tree t2) +{ + return wi::cmps (wi::to_widest (t1), wi::to_widest (t2)); +} + /* FIXME - These declarations belong in builtins.h, expr.h and emit-rtl.h, but none of these files are allowed to be included from front ends. They should be split in two. One suitable for the FEs, the other suitable -- 2.11.4.GIT