On Tue, 10 Dec 2013, Richard Sandiford wrote: > As Richard requested, this patch removes INT_CST_LT in favour of > tree_int_cst_lt and renames INT_CST_LE in a similar way. I made > both of them inline since the idea is that wi::l[te]s_p should already > do the expensive stuff out-of-line. I also moved tree_int_cst_cmp in > the same way for consistency. > > Tested on x86_64-linux-gnu. OK to install?
Ok with using +inline bool +tree_int_cst_lt (const_tree t1, const_tree t2) (note dropping the 'static') Thanks, Richard. > Thanks, > Richard > > > Index: gcc/ChangeLog.wide-int > =================================================================== > --- gcc/ChangeLog.wide-int 2013-12-09 20:08:46.560192095 +0000 > +++ gcc/ChangeLog.wide-int 2013-12-09 20:21:33.072009792 +0000 > @@ -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,8 @@ > (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_min_precision): Take a signop rather than a bool. > (wi::int_traits <const_tree>): New. > (wi::int_traits <tree>): New. > @@ -801,7 +803,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 +830,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 +903,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 +920,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 +988,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. > > Index: gcc/c-family/c-common.c > =================================================================== > --- gcc/c-family/c-common.c 2013-12-09 20:08:46.560192095 +0000 > +++ gcc/c-family/c-common.c 2013-12-09 20:21:33.074009806 +0000 > @@ -4123,10 +4123,10 @@ shorten_compare (tree *op0_ptr, tree *op > 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. */ > Index: gcc/c-family/cilk.c > =================================================================== > --- gcc/c-family/cilk.c 2013-12-09 20:08:46.560192095 +0000 > +++ gcc/c-family/cilk.c 2013-12-09 20:21:33.074009806 +0000 > @@ -666,7 +666,7 @@ declare_one_free_variable (const void *v > > /* 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; > Index: gcc/cp/call.c > =================================================================== > --- gcc/cp/call.c 2013-12-09 20:08:46.560192095 +0000 > +++ gcc/cp/call.c 2013-12-09 20:21:33.075009814 +0000 > @@ -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 > 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) > Index: gcc/cp/class.c > =================================================================== > --- gcc/cp/class.c 2013-12-09 20:08:46.560192095 +0000 > +++ gcc/cp/class.c 2013-12-09 20:21:33.077009829 +0000 > @@ -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_virtua > 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_virtua > 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_inf > 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 *virtual > 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 *virtual > 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 *virtual > 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 > Index: gcc/cp/decl.c > =================================================================== > --- gcc/cp/decl.c 2013-12-09 20:08:46.560192095 +0000 > +++ gcc/cp/decl.c 2013-12-09 20:21:33.079009844 +0000 > @@ -8316,7 +8316,7 @@ compute_array_index_type (tree name, tre > 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; > Index: gcc/fold-const.c > =================================================================== > --- gcc/fold-const.c 2013-12-09 20:08:46.560192095 +0000 > +++ gcc/fold-const.c 2013-12-09 20:21:33.081009859 +0000 > @@ -16409,7 +16409,7 @@ fold_relational_const (enum tree_code co > 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; > Index: gcc/java/expr.c > =================================================================== > --- gcc/java/expr.c 2013-12-09 20:08:46.560192095 +0000 > +++ gcc/java/expr.c 2013-12-09 20:21:33.082009866 +0000 > @@ -1718,7 +1718,7 @@ build_field_ref (tree self_value, tree s > 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)) > Index: gcc/targhooks.c > =================================================================== > --- gcc/targhooks.c 2013-12-09 20:08:46.560192095 +0000 > +++ gcc/targhooks.c 2013-12-09 20:21:33.082009866 +0000 > @@ -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; > Index: gcc/tree-ssa-uninit.c > =================================================================== > --- gcc/tree-ssa-uninit.c 2013-12-09 20:08:46.560192095 +0000 > +++ gcc/tree-ssa-uninit.c 2013-12-09 20:21:33.083009874 +0000 > @@ -857,11 +857,11 @@ is_value_included_in (tree val, tree bou > 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 bou > 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)); > } > } > > Index: gcc/tree-vrp.c > =================================================================== > --- gcc/tree-vrp.c 2013-12-09 20:08:46.560192095 +0000 > +++ gcc/tree-vrp.c 2013-12-09 20:21:33.084009881 +0000 > @@ -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; > Index: gcc/tree.c > =================================================================== > --- gcc/tree.c 2013-12-09 20:08:46.560192095 +0000 > +++ gcc/tree.c 2013-12-09 20:21:33.085009889 +0000 > @@ -6951,23 +6951,6 @@ tree_int_cst_equal (const_tree t1, const > 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 @@ int_fits_type_p (const_tree c, const_tre > /* 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 @@ int_fits_type_p (const_tree c, const_tre > /* 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; > } > Index: gcc/tree.h > =================================================================== > --- gcc/tree.h 2013-12-09 20:08:46.560192095 +0000 > +++ gcc/tree.h 2013-12-09 20:27:59.647887423 +0000 > @@ -895,9 +895,6 @@ #define TREE_INT_CST_ELT(NODE, I) TREE_I > #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. */ > + > +static 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. */ > + > +static 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. */ > + > +static 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 > > -- Richard Biener <rguent...@suse.de> SUSE / SUSE Labs SUSE LINUX Products GmbH - Nuernberg - AG Nuernberg - HRB 16746 GF: Jeff Hawn, Jennifer Guild, Felix Imend"orffer