GCC Middle and Back End API Reference
|
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "backend.h"
#include "target.h"
#include "rtl.h"
#include "tree.h"
#include "gimple.h"
#include "predict.h"
#include "memmodel.h"
#include "tm_p.h"
#include "tree-ssa-operands.h"
#include "optabs-query.h"
#include "cgraph.h"
#include "diagnostic-core.h"
#include "flags.h"
#include "alias.h"
#include "fold-const.h"
#include "fold-const-call.h"
#include "stor-layout.h"
#include "calls.h"
#include "tree-iterator.h"
#include "expr.h"
#include "intl.h"
#include "langhooks.h"
#include "tree-eh.h"
#include "gimplify.h"
#include "tree-dfa.h"
#include "builtins.h"
#include "generic-match.h"
#include "gimple-iterator.h"
#include "gimple-fold.h"
#include "tree-into-ssa.h"
#include "md5.h"
#include "case-cfn-macros.h"
#include "stringpool.h"
#include "tree-vrp.h"
#include "tree-ssanames.h"
#include "selftest.h"
#include "attribs.h"
#include "tree-vector-builder.h"
#include "vec-perm-indices.h"
#include "asan.h"
#include "gimple-range.h"
Data Structures | |
struct | contains_label_data |
Namespaces | |
namespace | inchash |
Macros | |
#define | INCLUDE_ALGORITHM |
#define | OP_SAME(N) |
#define | OP_SAME_WITH_NULL(N) |
#define | LOGICAL_OP_NON_SHORT_CIRCUIT |
#define | START_FOLD_INIT |
#define | END_FOLD_INIT |
#define | tree_expr_nonnegative_warnv_p(X, Y) |
#define | RECURSE(X) |
#define | integer_valued_real_p(X) |
#define | RECURSE(X) |
Enumerations | |
enum | comparison_code { COMPCODE_FALSE = 0 , COMPCODE_LT = 1 , COMPCODE_EQ = 2 , COMPCODE_LE = 3 , COMPCODE_GT = 4 , COMPCODE_LTGT = 5 , COMPCODE_GE = 6 , COMPCODE_ORD = 7 , COMPCODE_UNORD = 8 , COMPCODE_UNLT = 9 , COMPCODE_UNEQ = 10 , COMPCODE_UNLE = 11 , COMPCODE_UNGT = 12 , COMPCODE_NE = 13 , COMPCODE_UNGE = 14 , COMPCODE_TRUE = 15 } |
Variables | |
int | folding_initializer = 0 |
bool | folding_cxx_constexpr = false |
static int | fold_deferring_overflow_warnings |
static const char * | fold_deferred_overflow_warning |
static enum warn_strict_overflow_code | fold_deferred_overflow_code |
static operand_compare | default_compare_instance |
#define END_FOLD_INIT |
Referenced by fold_binary_initializer_loc(), fold_build1_initializer_loc(), fold_build2_initializer_loc(), fold_build_call_array_initializer_loc(), and fold_init().
#define INCLUDE_ALGORITHM |
Fold a constant sub-tree into a single node for C-compiler Copyright (C) 1987-2024 Free Software Foundation, Inc. This file is part of GCC. GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GCC; see the file COPYING3. If not see <http://www.gnu.org/licenses/>.
The entry points in this file are fold, size_int_wide and size_binop. fold takes a tree as argument and returns a simplified tree. size_binop takes a tree code for an arithmetic operation and two operands that are trees, and produces a tree for the result, assuming the type comes from `sizetype'. size_int takes an integer value, and creates a tree constant with type from `sizetype'. Note: Since the folders get called on non-gimple code as well as gimple code, we need to handle GIMPLE tuples as well as their corresponding tree equivalents.
#define integer_valued_real_p | ( | X | ) |
#define LOGICAL_OP_NON_SHORT_CIRCUIT |
Referenced by fold_range_test(), and fold_truth_andor().
#define OP_SAME | ( | N | ) |
Referenced by operand_compare::operand_equal_p().
#define OP_SAME_WITH_NULL | ( | N | ) |
Referenced by operand_compare::operand_equal_p().
#define RECURSE | ( | X | ) |
Referenced by integer_valued_real_binary_p(), integer_valued_real_call_p(), integer_valued_real_invalid_p(), integer_valued_real_single_p(), integer_valued_real_unary_p(), tree_binary_nonnegative_warnv_p(), tree_call_nonnegative_warnv_p(), tree_invalid_nonnegative_warnv_p(), tree_single_nonnegative_warnv_p(), and tree_unary_nonnegative_warnv_p().
#define RECURSE | ( | X | ) |
#define START_FOLD_INIT |
Perform constant folding and related simplification of initializer expression EXPR. These behave identically to "fold_buildN" but ignore potential run-time traps and exceptions that fold must preserve.
Referenced by fold_binary_initializer_loc(), fold_build1_initializer_loc(), fold_build2_initializer_loc(), fold_build_call_array_initializer_loc(), and fold_init().
#define tree_expr_nonnegative_warnv_p | ( | X, | |
Y ) |
Referenced by create_iv(), fold_binary_loc(), tree_binary_nonzero_warnv_p(), and tree_expr_nonnegative_p().
enum comparison_code |
The following constants represent a bit based encoding of GCC's comparison operators. This encoding simplifies transformations on relational comparison operators, such as AND and OR.
int address_compare | ( | tree_code | code, |
tree | type, | ||
tree | op0, | ||
tree | op1, | ||
tree & | base0, | ||
tree & | base1, | ||
poly_int64 & | off0, | ||
poly_int64 & | off1, | ||
bool | generic ) |
Helper function for address compare simplifications in match.pd. OP0 and OP1 are ADDR_EXPR operands being compared by CODE. TYPE is the type of comparison operands. BASE0, BASE1, OFF0 and OFF1 are set by the function. GENERIC is true if GENERIC folding and false for GIMPLE folding. Returns 0 if OP0 is known to be unequal to OP1 regardless of OFF{0,1}, 1 if bases are known to be equal and OP0 cmp OP1 depends on OFF0 cmp OFF1, and 2 if unknown.
References DECL_HAS_VALUE_EXPR_P, decl_in_symtab_p(), DECL_P, DECL_SIZE_UNIT, symtab_node::equal_address_to(), folding_cxx_constexpr, folding_initializer, poly_int< N, C >::force_shwi(), gcc_checking_assert, get_addr_base_and_unit_offset(), symtab_node::get_create(), gimple_assign_rhs1(), INTEGRAL_TYPE_P, poly_int< N, C >::is_constant(), is_global_var(), known_eq, known_ne, mem_ref_offset(), MIN, NULL_TREE, POINTER_TYPE_P, SSA_NAME_DEF_STMT, TREE_CODE, tree_fits_poly_int64_p(), TREE_OPERAND, TREE_STRING_LENGTH, TREE_STRING_POINTER, tree_to_poly_int64(), TREE_TYPE, TYPE_OVERFLOW_UNDEFINED, and VAR_P.
|
static |
Return nonzero if MASK represents a mask of SIZE ones in the low-order bit positions and MASK is SIGNED.
References wi::mask(), wi::to_wide(), TREE_TYPE, TYPE_PRECISION, TYPE_SIGN, and UNSIGNED.
Referenced by fold_truth_andor_1().
|
static |
Re-associate trees split by the above function. T1 and T2 are either expressions to associate or null. Return the new expression, if any. LOC is the location of the new expression. If we build an operation, do it in TYPE and with CODE.
References build2_loc(), fold_build2_loc(), fold_convert_loc(), gcc_assert, integer_zerop(), TREE_CODE, and TREE_OPERAND.
Referenced by fold_binary_loc().
Build an expression for the address of T.
References build_fold_addr_expr_with_type_loc(), build_pointer_type(), and TREE_TYPE.
Referenced by build_fold_addr_expr_with_type_loc(), create_task_copyfn(), expand_task_call(), expand_thunk(), fold_comparison(), fold_gimple_assign(), fold_unary_loc(), gimplify_addr_expr(), gimplify_cond_expr(), gimplify_expr(), gimplify_modify_expr_to_memcpy(), gimplify_modify_expr_to_memset(), gimplify_variable_sized_compare(), handle_simd_reference(), initialize_argument_information(), instrument_bool_enum_load(), instrument_builtin(), instrument_nonnull_arg(), instrument_nonnull_return(), lower_copyprivate_clauses(), lower_omp_critical(), lower_omp_for_scan(), lower_omp_scan(), lower_omp_single_copy(), lower_omp_target(), lower_omp_task_reductions(), lower_omp_taskreg(), lower_rec_input_clauses(), lower_reduction_clauses(), lower_send_clauses(), sanitize_unreachable_fn(), split_address_to_core_and_offset(), ubsan_build_overflow_builtin(), ubsan_expand_bounds_ifn(), ubsan_expand_null_ifn(), ubsan_expand_objsize_ifn(), ubsan_expand_ptr_ifn(), ubsan_expand_vptr_ifn(), and ubsan_instrument_float_cast().
Build an expression for the address of T. Folds away INDIRECT_REF to avoid confusing the gimplify process.
References build1_loc(), build_fold_addr_expr_loc(), convert_to_ptrofftype, fold_binary, fold_convert_loc(), INDIRECT_REF_P, integer_zerop(), TREE_CODE, TREE_OPERAND, and TREE_TYPE.
Referenced by build_fold_addr_expr_loc(), and stabilize_va_list_loc().
Builds an expression for an indirection through T, simplifying some cases.
References build1_loc(), fold_indirect_ref_1(), and TREE_TYPE.
Referenced by fold_binary_loc(), fold_builtin_addc_subc(), fold_builtin_arith_overflow(), fold_builtin_frexp(), fold_builtin_modf(), fold_builtin_sincos(), fold_indirect_ref_1(), gimplify_adjust_omp_clauses_1(), lower_copyprivate_clauses(), and optimize_stdarg_builtin().
Given a range, LOW, HIGH, and IN_P, an expression, EXP, and a result type, TYPE, return an expression to test if EXP is in (or out of, depending on IN_P) the range. Return 0 if the test couldn't be created.
References build_int_cst(), build_nonstandard_integer_type(), build_range_check(), const_binop(), exp(), fold_build2_loc(), fold_convert_loc(), FUNC_OR_METHOD_TYPE_P, integer_onep(), integer_zerop(), invert_truthvalue_loc(), wi::mask(), maskable_range_p(), NULL_TREE, omit_one_operand_loc(), operand_equal_p(), POINTER_TYPE_P, range_check_type(), signed_type_for(), targetm, wi::to_widest(), TREE_CODE, TREE_OVERFLOW, TREE_TYPE, TYPE_PRECISION, TYPE_UNSIGNED, and unsigned_type_for().
Referenced by build_range_check(), fold_range_test(), optimize_range_tests_to_bit_test(), and update_range_test().
Construct a vector of zero elements of vector type TYPE.
References build_vector_from_val(), fold_convert_const(), integer_zero_node, and TREE_TYPE.
Referenced by fold_convert_loc().
const char * c_getstr | ( | tree | str | ) |
Return a pointer to a NUL-terminated string corresponding to the expression STR referencing a constant string, possibly involving a constant offset. Return null if STR either doesn't reference a constant string or if it involves a nonconstant offset.
References getbyterep(), and NULL.
Referenced by expand_builtin_stpcpy_1(), expand_builtin_strncpy(), fold_builtin_strcspn(), fold_builtin_strpbrk(), fold_builtin_strspn(), fold_const_builtin_nan(), fold_const_call(), fold_const_call(), fold_const_call(), get_stridx(), gimple_fold_builtin_fprintf(), gimple_fold_builtin_fputs(), gimple_fold_builtin_printf(), gimple_fold_builtin_snprintf(), gimple_fold_builtin_snprintf_chk(), gimple_fold_builtin_sprintf(), gimple_fold_builtin_sprintf_chk(), gimple_fold_builtin_strcat(), gimple_fold_builtin_strcat_chk(), gimple_fold_builtin_strchr(), gimple_fold_builtin_strncat_chk(), gimple_fold_builtin_strstr(), and maybe_emit_sprintf_chk_warning().
bool can_min_p | ( | const_tree | arg1, |
const_tree | arg2, | ||
poly_wide_int & | res ) |
Returns true if we know who is smaller or equal, ARG1 or ARG2, and set the min value to RES.
References known_le, wi::to_poly_wide(), and wi::to_poly_widest().
Referenced by poly_int_binop().
Returns true if we can interpret the contents of a native encoding as TYPE.
References TREE_CODE.
Referenced by fold_ctor_reference(), fold_ternary_loc(), and native_interpret_aggregate().
tree combine_comparisons | ( | location_t | loc, |
enum tree_code | code, | ||
enum tree_code | lcode, | ||
enum tree_code | rcode, | ||
tree | truth_type, | ||
tree | ll_arg, | ||
tree | lr_arg ) |
Return a tree for the comparison which is the combination of doing the AND or OR (depending on CODE) of the two operations LCODE and RCODE on the identical operands LL_ARG and LR_ARG. Take into account the possibility of trapping if the mode has NaNs, and return NULL_TREE if this makes the transformation invalid.
References comparison_to_compcode(), COMPCODE_EQ, COMPCODE_FALSE, COMPCODE_LTGT, COMPCODE_NE, COMPCODE_ORD, compcode_to_comparison(), COMPCODE_TRUE, COMPCODE_UNORD, constant_boolean_node(), fold_build2_loc(), HONOR_NANS(), and NULL_TREE.
Referenced by and_comparisons_1(), fold_truth_andor_1(), and or_comparisons_1().
|
static |
Convert a comparison tree code from an enum tree_code representation into a compcode bit-based encoding. This function is the inverse of compcode_to_comparison.
References COMPCODE_EQ, COMPCODE_GE, COMPCODE_GT, COMPCODE_LE, COMPCODE_LT, COMPCODE_LTGT, COMPCODE_NE, COMPCODE_ORD, COMPCODE_UNEQ, COMPCODE_UNGE, COMPCODE_UNGT, COMPCODE_UNLE, COMPCODE_UNLT, COMPCODE_UNORD, and gcc_unreachable.
Referenced by combine_comparisons().
|
static |
Convert a compcode bit-based encoding of a comparison operator back to GCC's enum tree_code representation. This function is the inverse of comparison_to_compcode.
References COMPCODE_EQ, COMPCODE_GE, COMPCODE_GT, COMPCODE_LE, COMPCODE_LT, COMPCODE_LTGT, COMPCODE_NE, COMPCODE_ORD, COMPCODE_UNEQ, COMPCODE_UNGE, COMPCODE_UNGT, COMPCODE_UNLE, COMPCODE_UNLT, COMPCODE_UNORD, and gcc_unreachable.
Referenced by combine_comparisons().
Combine two constants ARG1 and ARG2 under operation CODE to produce a new constant. We assume ARG1 and ARG2 have the same data type, or at least are the same kind of constant and the same machine mode. Return zero if combining the constants is not allowed in the current operating mode.
References boolean_type_node, build_complex(), build_fixed(), build_real(), commutative_tree_code(), COMPLEX_FLOAT_TYPE_P, const_binop(), d1, d2, dconst0, do_mpc_arg2(), generic_wide_int< storage >::elt(), f1, f2, fixed_arithmetic(), FIXED_VALUE_TYPE, fold_abs_const(), fold_build2, fold_convert, folding_initializer, HONOR_SNANS(), i1, i2, int_const_binop(), integer_nonzerop(), MODE_COMPOSITE_P, MODE_HAS_INFINITIES, MODE_HAS_NANS, NULL_TREE, poly_int_tree_p(), real_arithmetic(), real_convert(), real_equal(), real_identical(), REAL_VALUE_ISINF, REAL_VALUE_ISNAN, REAL_VALUE_ISSIGNALING_NAN, REAL_VALUE_TYPE, simplify_const_binop(), STRIP_NOPS, wi::to_wide(), TREE_CODE, TREE_FIXED_CST, TREE_IMAGPART, TREE_OVERFLOW, TREE_REAL_CST, TREE_REALPART, TREE_TYPE, type(), TYPE_MODE, TYPE_SATURATING, generic_wide_int< storage >::ulow(), and vector_const_binop().
Referenced by attempt_builtin_copysign(), build_range_check(), const_binop(), const_binop(), decode_field_reference(), tree_switch_conversion::jump_table_cluster::emit(), extract_muldiv_1(), fold_binary_loc(), fold_const_fold_left(), fold_const_reduction(), fold_truth_andor_1(), generate_range_test(), gimple_resimplify2(), gimple_simplify(), maybe_warn_nonstring_arg(), optimize_bit_field_compare(), optimize_pow_to_exp(), unextend(), and valid_mask_for_fold_vec_perm_cst_p().
Overload that adds a TYPE parameter to be able to dispatch to fold_relational_const.
References tree_vector_builder::build(), build_complex(), build_vec_series(), const_binop(), CONSTANT_CLASS_P, fold_convert_const(), fold_relational_const(), force_fit_type(), gcc_assert, gcc_checking_assert, i, known_eq, NULL_TREE, poly_int_tree_p(), tcc_binary, tcc_comparison, wi::to_poly_offset(), TREE_CODE, TREE_CODE_CLASS, TREE_OVERFLOW, TREE_TYPE, TYPE_SATURATING, TYPE_VECTOR_SUBPARTS(), VECTOR_CST_ELT, and VECTOR_CST_NELTS.
Compute CODE ARG1 with resulting type TYPE with ARG1 being constant. Return zero if computing the constants is not possible.
References tree_vector_builder::build(), build_complex(), build_vector_from_val(), CASE_CONVERT, const_unop(), constant_boolean_node(), CONSTANT_CLASS_P, count, vector_builder< T, Shape, Derived >::encoded_nelts(), fold_abs_const(), fold_convert, fold_convert_const(), fold_negate_const(), fold_negate_expr(), fold_not_const(), fold_view_convert_expr(), gcc_assert, HONOR_SNANS(), i, integer_zerop(), known_eq, vector_builder< T, Shape, Derived >::new_unary_operation(), NULL_TREE, offset, POLY_INT_CST_P, poly_int_cst_value(), REAL_VALUE_ISSIGNALING_NAN, targetm, TREE_CODE, TREE_IMAGPART, TREE_REAL_CST, TREE_REALPART, TREE_TYPE, TYPE_ADDR_SPACE, TYPE_VECTOR_SUBPARTS(), UNKNOWN_LOCATION, VECTOR_CST_ELT, VECTOR_CST_NELTS, and wide_int_to_tree().
Referenced by const_unop(), tree_switch_conversion::jump_table_cluster::emit(), expand_vector_divmod(), fold_unary_loc(), gimple_resimplify1(), gimple_simplify(), match_uaddc_usubc(), optimize_atomic_bit_test_and(), vectorize_fold_left_reduction(), and visit_reference_op_load().
Return a node which has the indicated constant VALUE (either 0 or 1 for scalars or {-1,-1,..} or {0,0,...} for vectors), and is of the indicated TYPE.
References boolean_false_node, boolean_true_node, boolean_type_node, build_int_cst(), build_vector_from_val(), fold_convert, integer_one_node, integer_type_node, integer_zero_node, TREE_TYPE, and VECTOR_TYPE_P.
Referenced by associate_equivalences_with_edges(), combine_comparisons(), const_unop(), fold_binary_loc(), fold_binary_op_with_conditional_arg(), fold_comparison(), fold_relational_const(), fold_truth_andor_1(), fold_truth_not_expr(), fold_unary_loc(), optimize_bit_field_compare(), predicate_statements(), range_binop(), and record_edge_info().
Callback for walk_tree, looking for LABEL_EXPR. Return *TP if it is a LABEL_EXPR or CASE_LABEL_EXPR not inside of another SWITCH_EXPR; otherwise return NULL_TREE. Do not check the subtrees of GOTO_EXPR.
References contains_label_1(), contains_label_data::inside_switch_p, NULL_TREE, contains_label_data::pset, SWITCH_BODY, SWITCH_COND, TREE_CODE, and walk_tree.
Referenced by contains_label_1(), and contains_label_p().
Return whether the sub-tree ST contains a label which is accessible from outside the sub-tree.
References contains_label_1(), NULL_TREE, and walk_tree.
Referenced by fold_ternary_loc().
Return OFF converted to a pointer offset type suitable as offset for POINTER_PLUS_EXPR. Use location LOC for this conversion.
References fold_convert_loc(), ptrofftype_p(), sizetype, and TREE_TYPE.
Referenced by fold_build_pointer_plus_loc(), gimplify_self_mod_expr(), and omp_adjust_for_condition().
tree ctor_single_nonzero_element | ( | const_tree | t | ) |
Return the single non-zero element of a CONSTRUCTOR or NULL_TREE.
References CONSTRUCTOR_ELTS, integer_zerop(), NULL_TREE, real_zerop(), TREE_CODE, constructor_elt::value, and vec_safe_iterate().
|
static |
Subroutine for fold_truth_andor_1: decode a field reference. If EXP is a comparison reference, we return the innermost reference. *PBITSIZE is set to the number of bits in the reference, *PBITPOS is set to the starting bit number. If the innermost field can be completely contained in a mode-sized unit, *PMODE is set to that mode. Otherwise, it is set to VOIDmode. *PVOLATILEP is set to 1 if the any expression encountered is volatile; otherwise it is not changed. *PUNSIGNEDP is set to the signedness of the field. *PREVERSEP is set to the storage order of the field. *PMASK is set to the mask used. This is either contained in a BIT_AND_EXPR or derived from the width of the field. *PAND_MASK is set to the mask found in a BIT_AND_EXPR, if any. Return 0 if this is not a component reference or is one that we can't do anything with.
References AGGREGATE_TYPE_P, build_int_cst_type(), compare_tree_int(), const_binop(), CONVERT_EXPR_P, DECL_P, exp(), fold_build2_loc(), fold_convert_loc(), get_inner_reference(), INTEGRAL_TYPE_P, poly_int< N, C >::is_constant(), NULL_TREE, offset, REFERENCE_CLASS_P, size_int, STRIP_NOPS, TREE_CODE, TREE_OPERAND, TREE_TYPE, lang_hooks_for_types::type_for_size, TYPE_PRECISION, TYPE_SIZE, TYPE_UNSIGNED, and lang_hooks::types.
Referenced by fold_truth_andor_1().
Return true if binary operation OP distributes over addition in operand OPNO, with the other operand being held constant. OPNO counts from 1.
Referenced by vector_const_binop().
tree div_if_zero_remainder | ( | const_tree | arg1, |
const_tree | arg2 ) |
If ARG2 divides ARG1 with zero remainder, carries out the exact division and returns the quotient. Otherwise returns NULL_TREE.
References wi::multiple_of_p(), NULL_TREE, SIGNED, wi::to_widest(), TREE_TYPE, and wide_int_to_tree().
|
static |
ARG is a tree that is known to contain just arithmetic operations and comparisons. Evaluate the operations in the tree substituting NEW0 for any occurrence of OLD0 as an operand of a comparison and likewise for NEW1 and OLD1.
References eval_subst(), fold_build1_loc(), fold_build2_loc(), fold_build3_loc(), operand_equal_p(), tcc_binary, tcc_comparison, tcc_expression, tcc_unary, TREE_CODE, TREE_CODE_CLASS, TREE_OPERAND, and TREE_TYPE.
Referenced by eval_subst(), and fold_comparison().
If the real or vector real constant CST of type TYPE has an exact inverse, return it, else return NULL.
References tree_vector_builder::build(), build_real(), count, vector_builder< T, Shape, Derived >::encoded_nelts(), exact_real_inverse(), i, vector_builder< T, Shape, Derived >::new_unary_operation(), NULL_TREE, r, REAL_VALUE_TYPE, TREE_CODE, TREE_REAL_CST, TREE_TYPE, TYPE_MODE, and VECTOR_CST_ELT.
|
static |
Return EXPR_LOCATION of T if it is not UNKNOWN_LOCATION. Otherwise, return LOC.
References EXPR_LOCATION, and UNKNOWN_LOCATION.
Referenced by fold_ternary_loc(), and fold_truth_not_expr().
Return true if T is known not to be equal to an integer W.
References wi::bit_and_not(), cfun, irange::contains_p(), get_nonzero_bits(), get_range_query(), INTEGRAL_TYPE_P, wi::ne_p(), path_range_query::range_of_expr(), wi::to_wide(), TREE_CODE, TREE_TYPE, TYPE_PRECISION, vrange::undefined_p(), and wi::zext().
Referenced by tree_single_nonzero_warnv_p().
|
static |
T is an integer expression that is being multiplied, divided, or taken a modulus (CODE says which and what kind of divide or modulus) by a constant C. See if we can eliminate that operation by folding it with other operations already in T. WIDE_TYPE, if non-null, is a type that should be used for the computation if wider than our type. For example, if we are dividing (X * 8) + (Y * 16) by 4, we can return (X * 2) + (Y * 4). We must, however, be assured that either the original expression would not overflow or that overflow is undefined for the type in the language in question. If we return a non-null expression, it is an equivalent form of the original computation, but need not be in the original type. We set *STRICT_OVERFLOW_P to true if the return values depends on signed overflow being undefined. Otherwise we do not change *STRICT_OVERFLOW_P.
References extract_muldiv_1(), and NULL.
Referenced by extract_muldiv_1(), and fold_binary_loc().
|
static |
References absu_hwi(), BINARY_CLASS_P, build2(), CASE_CONVERT, COMPARISON_CLASS_P, const_binop(), EXPRESSION_CLASS_P, extract_muldiv(), fold_build1, fold_build2, fold_convert, GET_MODE_SIZE(), wi::gtu_p(), integer_minus_onep(), integer_zero_node, integer_zerop(), INTEGRAL_TYPE_P, wi::mul(), multiple_of_p(), wi::multiple_of_p(), negate_expr(), NULL_TREE, omit_one_operand, pow2p_hwi(), SCALAR_INT_TYPE_MODE, SIGNED, size_one_node, tcc_binary, tcc_unary, wi::to_wide(), TREE_CODE, TREE_CODE_CLASS, tree_fits_shwi_p(), tree_int_cst_sgn(), TREE_OPERAND, TREE_OVERFLOW, tree_to_shwi(), TREE_TYPE, type(), TYPE_OVERFLOW_SANITIZED, TYPE_OVERFLOW_UNDEFINED, TYPE_OVERFLOW_WRAPS, TYPE_PRECISION, TYPE_SIGN, TYPE_UNSIGNED, UNARY_CLASS_P, UNSIGNED, VL_EXP_CLASS_P, and wide_int_to_tree().
Referenced by extract_muldiv().
tree find_bitfield_repr_type | ( | int | fieldsize, |
int | len ) |
Try to find a type whose byte size is smaller or equal to LEN bytes larger or equal to FIELDSIZE bytes, with underlying mode precision/size multiple of BITS_PER_UNIT. As native_{interpret,encode}_int works in term of machine modes, we can't just use build_nonstandard_integer_type.
References FOR_EACH_MODE_IN_CLASS, GET_MODE_BITSIZE(), GET_MODE_PRECISION(), GET_MODE_SIZE(), i, int_n_data, int_n_enabled_p, int_n_trees, known_eq, known_ge, known_le, NULL_TREE, lang_hooks_for_types::type_for_mode, TYPE_MODE, lang_hooks::types, and int_n_trees_t::unsigned_type.
Referenced by native_encode_initializer(), and native_interpret_aggregate().
Perform constant folding and related simplification of EXPR. The related simplifications include x*1 => x, x*0 => 0, etc., and application of the associative law. NOP_EXPR conversions may be removed freely (as long as we are careful not to change the type of the overall expression). We cannot simplify through a CONVERT_EXPR, FIX_EXPR or FLOAT_EXPR, but we can constant-fold them if they have constant operands.
References build_int_cst(), build_vector_from_ctor(), CONSTANT_CLASS_P, CONSTRUCTOR_ELT, CONSTRUCTOR_ELTS, DECL_INITIAL, expr, EXPR_LOCATION, fold(), fold_binary_loc(), fold_call_expr(), fold_ternary_loc(), fold_unary_loc(), FOR_EACH_CONSTRUCTOR_VALUE, gcc_checking_assert, get_array_ctor_element_at_index(), i, IS_EXPR_CODE_CLASS, NULL_TREE, RAW_DATA_LENGTH, RAW_DATA_POINTER, tcc_constant, tcc_vl_exp, wi::to_offset(), TREE_CODE, TREE_CODE_CLASS, TREE_CODE_LENGTH, TREE_OPERAND, TREE_TYPE, and type_contains_placeholder_p().
Referenced by create_component_ref_by_pieces_1(), expand_expr_real_1(), expand_simple_operations(), fold(), fold_init(), fold_mem_refs(), simplify_replace_tree(), substitute_in_expr(), and substitute_placeholder_in_expr().
Return the tree for abs (ARG0) when ARG0 is known to be either an integer constant or real constant. TYPE is the type of the result.
References build_real(), force_fit_type(), gcc_unreachable, wi::neg(), wi::neg_p(), NULL_TREE, wi::OVF_NONE, real_value_negate(), REAL_VALUE_NEGATIVE, wi::to_wide(), TREE_CODE, TREE_OVERFLOW, TREE_REAL_CST, TREE_TYPE, and TYPE_SIGN.
Referenced by const_binop(), and const_unop().
|
static |
Try to fold a pointer difference of type TYPE two address expressions of array references AREF0 and AREF1 using location LOC. Return a simplified expression for the difference or NULL_TREE.
References array_ref_element_size(), build_int_cst(), fold_addr_of_array_ref_difference(), fold_binary_loc(), fold_build2_loc(), fold_convert, fold_convert_loc(), INDIRECT_REF_P, NULL_TREE, OEP_ADDRESS_OF, operand_equal_p(), TREE_CODE, and TREE_OPERAND.
Referenced by fold_addr_of_array_ref_difference(), and fold_binary_loc().
References END_FOLD_INIT, fold_binary_loc(), and START_FOLD_INIT.
Fold a binary expression of code CODE and type TYPE with operands OP0 and OP1. LOC is the location of the resulting expression. Return the folded expression if folding is successful. Otherwise, return NULL_TREE.
References ANY_INTEGRAL_TYPE_P, associate_trees(), wi::bit_and_not(), boolean_false_node, boolean_true_node, boolean_type_node, build1(), build1_loc(), build2(), build2_loc(), build_fold_indirect_ref_loc(), build_int_cst(), build_one_cst(), build_pointer_type(), build_qualified_type(), build_zero_cst(), CALL_EXPR_ARG, call_expr_nargs, char_type_node, commutative_tree_code(), compare_tree_int(), COMPARISON_CLASS_P, COMPLEX_FLOAT_TYPE_P, const_binop(), constant_boolean_node(), CONSTANT_CLASS_P, CONVERT_EXPR_P, element_precision(), wi::exact_log2(), extract_muldiv(), FLOAT_TYPE_P, fndecl_built_in_p(), fold_addr_of_array_ref_difference(), fold_binary_loc(), fold_binary_op_with_conditional_arg(), fold_build1_loc(), fold_build2, fold_build2_loc(), fold_comparison(), fold_convert, fold_convert_loc(), fold_mult_zconjz(), fold_overflow_warning(), fold_plusminus_mult_expr(), fold_to_nonsharp_ineq_using_bound(), fold_truth_andor(), fold_unary_loc(), wide_int_storage::from(), gcc_assert, gcc_unreachable, generic_simplify(), get_addr_base_and_unit_offset(), get_callee_fndecl(), GET_MODE_UNIT_PRECISION, handled_component_p(), HONOR_NANS(), HONOR_SIGNED_ZEROS(), HONOR_SNANS(), int_const_binop(), integer_one_node, integer_onep(), integer_pow2p(), integer_zero_node, integer_zerop(), INTEGRAL_TYPE_P, invert_truthvalue_loc(), IS_EXPR_CODE_CLASS, is_truth_type_for(), wi::mask(), mask_with_tz(), MODE_HAS_INFINITIES, multiple_of_p(), negate_expr(), negate_expr_p(), non_lvalue_loc(), NULL_TREE, OEP_ONLY_CONST, omit_one_operand_loc(), omit_two_operands_loc(), operand_equal_p(), optimize_bit_field_compare(), POINTER_TYPE_P, wi::popcount(), pow2p_hwi(), real_minus_onep(), real_onep(), REAL_VALUE_NEGATIVE, real_zerop(), save_expr(), signed_type_for(), size_int, sizetype, split_tree(), strip_float_extensions(), STRIP_NOPS, STRIP_SIGN_NOPS, swap_tree_comparison(), tcc_binary, tcc_comparison, wi::to_wide(), wi::to_widest(), TREE_CODE, TREE_CODE_CLASS, TREE_CODE_LENGTH, TREE_CONSTANT, tree_expr_nonnegative_warnv_p, TREE_IMAGPART, tree_int_cst_lt(), tree_int_cst_sgn(), TREE_OPERAND, TREE_OVERFLOW, TREE_OVERFLOW_P, TREE_REAL_CST, TREE_REALPART, TREE_SIDE_EFFECTS, tree_swap_operands_p(), TREE_TYPE, truth_value_p(), type(), TYPE_MODE, TYPE_OVERFLOW_SANITIZED, TYPE_OVERFLOW_UNDEFINED, TYPE_OVERFLOW_WRAPS, TYPE_PRECISION, TYPE_QUAL_CONST, TYPE_SATURATING, TYPE_UNSIGNED, UNSIGNED, VECTOR_INTEGER_TYPE_P, VECTOR_TYPE_P, WARN_STRICT_OVERFLOW_CONDITIONAL, WARN_STRICT_OVERFLOW_MISC, and wide_int_to_tree().
Referenced by combine_cond_expr_cond(), copy_prop_visit_cond_stmt(), fold(), fold_addr_of_array_ref_difference(), fold_binary_initializer_loc(), fold_binary_loc(), fold_build2_loc(), fold_builtin_arith_overflow(), fold_to_nonsharp_ineq_using_bound(), gimple_fold_stmt_to_constant_1(), and dom_opt_dom_walker::optimize_stmt().
|
static |
Transform `a + (b ? x : y)' into `b ? (a + x) : (a + y)'. Transform, `a + (x < y)' into `(x < y) ? (a + 1) : (a + 0)'. Here CODE corresponds to the `+', COND to the `(b ? x : y)' or `(x < y)' expression, and ARG to `a'. If COND_FIRST_P is nonzero, then the COND is the first argument to CODE; otherwise (as in the example given here), it is the second argument. TYPE is the type of the original expression. Return NULL_TREE if no simplification is possible.
References ANY_INTEGRAL_TYPE_P, arg_type, constant_boolean_node(), FLOAT_TYPE_P, fold_build2_loc(), fold_build3_loc(), fold_convert_loc(), NULL_TREE, operation_could_trap_p(), TREE_CODE, TREE_CONSTANT, TREE_OPERAND, TREE_SIDE_EFFECTS, TREE_TYPE, TYPE_OVERFLOW_TRAPS, VECTOR_TYPE_P, and VOID_TYPE_P.
Referenced by fold_binary_loc().
Given the components of a binary expression CODE, TYPE, OP0 and OP1, attempt to fold the expression to a constant without modifying TYPE, OP0 or OP1. If the expression could be simplified to a constant, then return the constant. If the expression would not be simplified to a constant, then return NULL_TREE.
References fold_binary, NULL_TREE, and TREE_CONSTANT.
Referenced by compare_values_warnv(), evaluate_conditions_for_known_args(), maybe_fold_tmr(), number_of_iterations_cond(), and number_of_iterations_ne().
tree fold_bit_and_mask | ( | tree | type, |
tree | arg1, | ||
enum tree_code | code, | ||
tree | arg00, | ||
enum tree_code | code00, | ||
tree | arg000, | ||
tree | arg001, | ||
tree | arg01, | ||
enum tree_code | code01, | ||
tree | arg010, | ||
tree | arg011, | ||
tree * | pmop ) |
For constants M and N, if M == (1LL << cst) - 1 && (N & M) == M, ((A & N) + B) & M -> (A + B) & M Similarly if (N & M) == 0, ((A | N) + B) & M -> (A + B) & M and for - instead of + (or unary - instead of +) and/or ^ instead of |. If B is constant and (B & M) == 0, fold into A & M. This function is a helper for match.pd patterns. Return non-NULL type in which the simplified operation should be performed only if any optimization is possible. ARG1 is M above, ARG00 is left operand of +/-, if CODE00 is BIT_*_EXPR, then ARG00{0,1} are operands of that bitop, otherwise CODE00 is ERROR_MARK. Similarly for ARG01, CODE01 and ARG01{0,1}, just for the right operand of +/-.
References build_int_cst(), gcc_assert, gcc_unreachable, INTEGRAL_TYPE_P, wi::max_value(), NULL_TREE, wi::to_wide(), TREE_CODE, type(), TYPE_OVERFLOW_WRAPS, and unsigned_type_for().
References END_FOLD_INIT, fold_build1_loc(), and START_FOLD_INIT.
Fold a unary tree expression with code CODE of type TYPE with an operand OP0. LOC is the location of the resulting expression. Return a folded expression if successful. Otherwise, return a tree expression with code CODE of type TYPE with an operand OP0.
References build1_loc(), fold_unary_loc(), and PASS_MEM_STAT.
Referenced by compute_access_range(), eval_subst(), expand_omp_atomic_store(), expand_omp_ordered_sink(), expand_vector_ubsan_overflow(), fold_binary_loc(), fold_build1_initializer_loc(), fold_builtin_1(), fold_builtin_abs(), fold_builtin_carg(), fold_builtin_classify(), fold_builtin_fabs(), fold_builtin_fpclassify(), fold_builtin_interclass_mathfn(), fold_builtin_sincos(), fold_builtin_unordered_cmp(), fold_cond_expr_with_comparison(), fold_const_aggregate_ref_1(), fold_convert_loc(), fold_indirect_ref_1(), fold_mult_zconjz(), fold_negate_expr_1(), fold_truth_andor_1(), fold_unary_loc(), gimplify_conversion(), gimplify_omp_depend(), gimplify_scalar_mode_aggregate_compare(), gimplify_self_mod_expr(), invert_truthvalue_loc(), load_assign_lhs_subreplacements(), lower_omp_target(), ipa_param_body_adjustments::modify_assignment(), omp_adjust_for_condition(), omp_get_for_step_from_incr(), sra_modify_assign(), and stabilize_va_list_loc().
tree fold_build2_initializer_loc | ( | location_t | loc, |
enum tree_code | code, | ||
tree | type, | ||
tree | op0, | ||
tree | op1 ) |
References END_FOLD_INIT, fold_build2_loc(), and START_FOLD_INIT.
Referenced by expr_expected_value_1().
tree fold_build2_loc | ( | location_t | loc, |
enum tree_code | code, | ||
tree | type, | ||
tree | op0, | ||
tree op1 | MEM_STAT_DECL ) |
Fold a binary tree expression with code CODE of type TYPE with operands OP0 and OP1. LOC is the location of the resulting expression. Return a folded expression if successful. Otherwise, return a tree expression with code CODE of type TYPE with operands OP0 and OP1.
References build2_loc(), fold_binary_loc(), and PASS_MEM_STAT.
Referenced by adjust_related_strinfos(), array_type_nelts_top(), associate_trees(), tree_switch_conversion::switch_conversion::build_arrays(), build_debug_ref_for_model(), build_range_check(), build_ref_for_offset(), c_strlen(), combine_comparisons(), compute_access_range(), decode_field_reference(), dr_analyze_indices(), tree_switch_conversion::bit_test_cluster::emit(), eval_subst(), expand_builtin_cexpi(), expand_builtin_signbit(), expand_builtin_sincos(), expand_builtin_strncmp(), expand_builtin_strnlen(), expand_omp_ordered_sink(), expand_parallel_call(), expand_single_bit_test(), expand_task_call(), fold_addr_of_array_ref_difference(), fold_binary_loc(), fold_binary_op_with_conditional_arg(), fold_build2_initializer_loc(), fold_build_pointer_plus_hwi_loc(), fold_build_pointer_plus_loc(), fold_builtin_addc_subc(), fold_builtin_arith_overflow(), fold_builtin_classify(), fold_builtin_fpclassify(), fold_builtin_frexp(), fold_builtin_isascii(), fold_builtin_isdigit(), fold_builtin_iseqsig(), fold_builtin_memcmp(), fold_builtin_modf(), fold_builtin_toascii(), fold_builtin_unordered_cmp(), fold_comparison(), fold_cond_expr_with_comparison(), fold_convert_loc(), fold_mult_zconjz(), fold_negate_expr_1(), fold_or_predicates(), fold_plusminus_mult_expr(), fold_ternary_loc(), fold_to_nonsharp_ineq_using_bound(), fold_truth_andor(), fold_unary_loc(), gimple_load_first_char(), gimplify_bind_expr(), gimplify_expr(), gimplify_omp_affinity(), gimplify_omp_depend(), gimplify_scalar_mode_aggregate_compare(), strlen_pass::handle_builtin_memcmp(), strlen_pass::handle_builtin_memcpy(), strlen_pass::handle_builtin_strcat(), strlen_pass::handle_builtin_strchr(), strlen_pass::handle_builtin_strcpy(), strlen_pass::handle_builtin_strlen(), strlen_pass::handle_store(), ifcombine_ifandif(), lower_omp_for_scan(), lower_omp_target(), lower_rec_input_clauses(), lower_reduction_clauses(), make_range_step(), maybe_canonicalize_comparison_1(), maybe_optimize_arith_overflow(), maybe_optimize_mod_cmp(), merge_truthop_with_opposite_arm(), ipa_param_adjustments::modify_call(), omp_accumulate_sibling_list(), omp_adjust_for_condition(), omp_extract_for_data(), optimize_bit_field_compare(), optimize_range_tests_to_bit_test(), rhs_to_tree(), set_endptr_and_length(), simplify_builtin_call(), size_binop_loc(), stabilize_va_list_loc(), std_gimplify_va_arg_expr(), and try_transform_to_exit_first_loop_alt().
tree fold_build3_loc | ( | location_t | loc, |
enum tree_code | code, | ||
tree | type, | ||
tree | op0, | ||
tree | op1, | ||
tree op2 | MEM_STAT_DECL ) |
Fold a ternary tree expression with code CODE of type TYPE with operands OP0, OP1, and OP2. Return a folded expression if successful. Otherwise, return a tree expression with code CODE of type TYPE with operands OP0, OP1, and OP2.
References build3_loc(), fold_ternary_loc(), gcc_assert, PASS_MEM_STAT, tcc_vl_exp, and TREE_CODE_CLASS.
Referenced by build_ref_for_model(), c_strlen(), eval_subst(), expand_omp_ordered_sink(), expand_task_call(), expand_vector_ubsan_overflow(), fold_binary_op_with_conditional_arg(), fold_builtin_classify(), fold_builtin_fpclassify(), fold_indirect_ref_1(), fold_ternary_loc(), fold_unary_loc(), gimplify_omp_affinity(), gimplify_omp_depend(), and rhs_to_tree().
tree fold_build_call_array_initializer_loc | ( | location_t | loc, |
tree | type, | ||
tree | fn, | ||
int | nargs, | ||
tree * | argarray ) |
References END_FOLD_INIT, fold_build_call_array_loc(), and START_FOLD_INIT.
Fold a CALL_EXPR expression of type TYPE with operands FN and NARGS arguments in ARGARRAY, and a null static chain. Return a folded expression if successful. Otherwise, return a CALL_EXPR of type TYPE from the given operands as constructed by build_call_array.
References build_call_array_loc(), fold_builtin_call_array(), i, and NULL_TREE.
Referenced by build_call_expr_loc_array(), and fold_build_call_array_initializer_loc().
If necessary, return a CLEANUP_POINT_EXPR for EXPR with the indicated TYPE. If no CLEANUP_POINT_EXPR is necessary, return EXPR itself.
References build1_loc(), expr, EXPR_LOCATION, TREE_CODE, TREE_OPERAND, and TREE_SIDE_EFFECTS.
Build and fold a POINTER_PLUS_EXPR at LOC offsetting PTR by OFF.
References fold_build2_loc(), size_int, and TREE_TYPE.
Referenced by fold_builtin_strpbrk(), and thunk_adjust().
Build and fold a POINTER_PLUS_EXPR at LOC offsetting PTR by OFF.
References convert_to_ptrofftype_loc(), fold_build2_loc(), and TREE_TYPE.
Referenced by compute_access_range(), fold_unary_loc(), gimple_fold_builtin_strcat(), omp_adjust_for_condition(), and thunk_adjust().
|
static |
Subroutine of fold_binary. This routine performs all of the transformations that are common to the equality/inequality operators (EQ_EXPR and NE_EXPR) and the ordering operators (LT_EXPR, LE_EXPR, GE_EXPR and GT_EXPR). Callers other than fold_binary should call fold_binary. Fold a comparison with tree code CODE and type TYPE with operands OP0 and OP1. Return the folded comparison or NULL_TREE.
References ANY_INTEGRAL_TYPE_P, build_fold_addr_expr_loc(), build_int_cst(), constant_boolean_node(), CONSTANT_CLASS_P, DECL_P, eval_subst(), fold_build2_loc(), fold_convert_loc(), fold_overflow_warning(), G_, gcc_unreachable, get_inner_reference(), INDIRECT_REF_P, int_const_binop(), integer_one_node, integer_onep(), integer_zero_node, integer_zerop(), INTEGRAL_TYPE_P, known_eq, known_ge, known_gt, known_le, known_lt, known_ne, maybe_canonicalize_comparison(), maybe_nonzero_address(), NULL_TREE, OEP_ADDRESS_OF, omit_one_operand_loc(), operand_equal_p(), pointer_may_wrap_p(), POINTER_TYPE_P, poly_int_tree_p(), wi::sext(), size_binop, sizetype, ssizetype, STRIP_SIGN_NOPS, wi::to_poly_offset(), poly_int< N, C >::to_shwi(), TREE_CODE, TREE_CONSTANT, tree_int_cst_compare(), tree_int_cst_sgn(), TREE_OPERAND, TREE_OVERFLOW, TREE_TYPE, twoval_comparison_p(), TYPE_MAX_VALUE, TYPE_MIN_VALUE, TYPE_OVERFLOW_UNDEFINED, TYPE_PRECISION, WARN_STRICT_OVERFLOW_COMPARISON, and WARN_STRICT_OVERFLOW_CONDITIONAL.
Referenced by fold_binary_loc().
|
static |
Subroutine of fold, looking inside expressions of the form A op B ? A : C, where (ARG00, COMP_CODE, ARG01), ARG1 and ARG2 are the three operands of the COND_EXPR. This function is being used also to optimize A op B ? C : A, by reversing the comparison first. Return a folded expression whose code is not a COND_EXPR anymore, or NULL_TREE if no folding opportunity is found.
References ANY_INTEGRAL_TYPE_P, build_zero_cst(), FLOAT_TYPE_P, fold_build1_loc(), fold_build2_loc(), fold_convert_loc(), gcc_assert, HONOR_NANS(), HONOR_SIGNED_ZEROS(), in_gimple_form, integer_zerop(), lang_GNU_CXX(), maybe_lvalue_p(), lang_hooks::name, negate_expr(), NULL_TREE, operand_equal_for_comparison_p(), operand_equal_p(), real_zerop(), STRIP_NOPS, tcc_comparison, TREE_CODE, TREE_CODE_CLASS, TREE_OPERAND, TREE_TYPE, TYPE_OVERFLOW_WRAPS, TYPE_UNSIGNED, unsigned_type_for(), and VECTOR_TYPE_P.
Referenced by fold_ternary_loc().
Attempt to fold type conversion operation CODE of expression ARG1 to type TYPE. If no simplification can be done return NULL_TREE.
References arg_type, tree_vector_builder::build(), build_poly_int_cst(), build_real_from_int_cst(), vector_builder< T, Shape, Derived >::encoded_nelts(), FIXED_POINT_TYPE_P, fold_convert_const(), fold_convert_const_fixed_from_fixed(), fold_convert_const_fixed_from_int(), fold_convert_const_fixed_from_real(), fold_convert_const_int_from_fixed(), fold_convert_const_int_from_int(), fold_convert_const_int_from_real(), fold_convert_const_real_from_fixed(), fold_convert_const_real_from_real(), poly_int< N, C >::from(), HONOR_SIGN_DEPENDENT_ROUNDING(), i, INTEGRAL_TYPE_P, known_eq, wi::ne_p(), vector_builder< T, Shape, Derived >::new_unary_operation(), NULL_TREE, POINTER_TYPE_P, POLY_INT_CST_P, poly_int_cst_value(), real_to_integer(), SCALAR_FLOAT_TYPE_P, wi::to_wide(), TREE_CODE, TREE_REAL_CST, TREE_TYPE, TYPE_PRECISION, TYPE_SIGN, TYPE_VECTOR_SUBPARTS(), VECTOR_CST_ELT, VECTOR_CST_NELTS, and VECTOR_TYPE_P.
Referenced by build_zero_vector(), const_binop(), const_unop(), fold_convert_const(), and fold_convert_loc().
|
static |
A subroutine of fold_convert_const handling conversions a FIXED_CST to another fixed-point type.
References build_fixed(), fixed_convert(), FIXED_VALUE_TYPE, SCALAR_TYPE_MODE, TREE_FIXED_CST, TREE_OVERFLOW, and TYPE_SATURATING.
Referenced by fold_convert_const().
|
static |
A subroutine of fold_convert_const handling conversions an INTEGER_CST to a fixed-point type.
References build_fixed(), fixed_convert_from_int(), FIXED_VALUE_TYPE, gcc_assert, double_int::high, HOST_WIDE_INT_M1, double_int::low, SCALAR_TYPE_MODE, TREE_INT_CST_ELT, TREE_INT_CST_NUNITS, TREE_OVERFLOW, TREE_TYPE, TYPE_SATURATING, and TYPE_UNSIGNED.
Referenced by fold_convert_const().
|
static |
A subroutine of fold_convert_const handling conversions a REAL_CST to a fixed-point type.
References build_fixed(), fixed_convert_from_real(), FIXED_VALUE_TYPE, SCALAR_TYPE_MODE, TREE_OVERFLOW, TREE_REAL_CST, and TYPE_SATURATING.
Referenced by fold_convert_const().
|
static |
A subroutine of fold_convert_const handling conversions of a FIXED_CST to an integer type.
References double_int_one, double_int_zero, force_fit_type(), GET_MODE_FBIT, HOST_BITS_PER_DOUBLE_INT, double_int::is_negative(), double_int::lshift(), double_int::rshift(), SIGNED_FIXED_POINT_MODE_P, TREE_FIXED_CST, TREE_OVERFLOW, TREE_TYPE, and TYPE_UNSIGNED.
Referenced by fold_convert_const().
|
static |
A subroutine of fold_convert_const handling conversions of an INTEGER_CST to another integer type.
References force_fit_type(), wide_int_storage::from(), MAX, POINTER_TYPE_P, wi::to_wide(), TREE_OVERFLOW, TREE_TYPE, TYPE_PRECISION, and TYPE_SIGN.
Referenced by fold_convert_const().
|
static |
A subroutine of fold_convert_const handling conversions a REAL_CST to an integer type.
References force_fit_type(), gcc_unreachable, NULL_TREE, r, real_less(), real_to_integer(), real_trunc(), real_value_from_int_cst(), REAL_VALUE_ISNAN, REAL_VALUE_TYPE, wi::to_wide(), TREE_OVERFLOW, TREE_REAL_CST, TYPE_MAX_VALUE, TYPE_MIN_VALUE, TYPE_PRECISION, and wi::zero().
Referenced by fold_convert_const().
|
static |
A subroutine of fold_convert_const handling conversions a FIXED_CST to a floating point type.
References build_real(), real_convert_from_fixed(), REAL_VALUE_TYPE, SCALAR_FLOAT_TYPE_MODE, TREE_FIXED_CST, and TREE_OVERFLOW.
Referenced by fold_convert_const().
|
static |
A subroutine of fold_convert_const handling conversions a REAL_CST to another floating point type.
References build_real(), exact_real_truncate(), HONOR_SIGN_DEPENDENT_ROUNDING(), HONOR_SNANS(), MODE_HAS_INFINITIES, MODE_HAS_NANS, NULL_TREE, real_convert(), REAL_VALUE_ISINF, REAL_VALUE_ISNAN, REAL_VALUE_ISSIGNALING_NAN, REAL_VALUE_TYPE, TREE_OVERFLOW, TREE_REAL_CST, TREE_TYPE, and TYPE_MODE.
Referenced by fold_convert_const().
Convert expression ARG to type TYPE. Used by the middle-end for simple conversions in preference to calling the front-end's convert.
References build_zero_vector(), error_mark_node, fold_build1_loc(), fold_build2_loc(), fold_convert_const(), fold_convert_loc(), fold_ignored_result(), gcc_assert, gcc_unreachable, integer_zero_node, integer_zerop(), INTEGRAL_TYPE_P, NULL_TREE, POINTER_TYPE_P, protected_set_expr_location_unshare(), save_expr(), TREE_CODE, tree_int_cst_equal(), TREE_OPERAND, TREE_TYPE, TYPE_ADDR_SPACE, TYPE_MAIN_VARIANT, TYPE_SIZE, and VECTOR_TYPE_P.
Referenced by adjust_related_strinfos(), array_ref_element_size(), associate_trees(), tree_switch_conversion::switch_conversion::build_arrays(), build_builtin_expect_predicate(), build_fold_addr_expr_with_type_loc(), build_range_check(), c_strlen(), component_ref_field_offset(), compute_access_range(), convert_to_ptrofftype_loc(), decode_field_reference(), tree_switch_conversion::bit_test_cluster::emit(), expand_arith_overflow(), expand_builtin_bzero(), expand_builtin_memcmp(), expand_builtin_strncmp(), expand_builtin_strnlen(), expand_expr_real_1(), expand_expr_real_2(), expand_omp_atomic_fetch_op(), expand_omp_ordered_sink(), expand_omp_target(), expand_parallel_call(), expand_single_bit_test(), expand_task_call(), finish_taskreg_scan(), fold_addr_of_array_ref_difference(), fold_binary_loc(), fold_binary_op_with_conditional_arg(), fold_builtin_abs(), fold_builtin_arith_overflow(), fold_builtin_expect(), fold_builtin_fabs(), fold_builtin_isdigit(), fold_builtin_iseqsig(), fold_builtin_memcmp(), fold_builtin_strlen(), fold_builtin_strpbrk(), fold_builtin_unordered_cmp(), fold_comparison(), fold_cond_expr_with_comparison(), fold_convert_loc(), fold_negate_expr(), fold_negate_expr_1(), fold_plusminus_mult_expr(), fold_read_from_constant_string(), fold_ternary_loc(), fold_to_nonsharp_ineq_using_bound(), fold_truth_andor_1(), fold_unary_loc(), tree_switch_conversion::switch_conversion::gen_inbound_check(), get_ws_args_for(), gimple_boolify(), gimple_fold_builtin_strcat(), gimple_fold_builtin_strcpy(), gimple_fold_builtin_strncpy(), gimplify_addr_expr(), gimplify_expr(), gimplify_modify_expr(), gimplify_omp_depend(), strlen_pass::handle_builtin_memcmp(), strlen_pass::handle_builtin_memcpy(), strlen_pass::handle_builtin_strcat(), strlen_pass::handle_builtin_strchr(), strlen_pass::handle_builtin_strcpy(), strlen_pass::handle_builtin_strlen(), layout_decl(), lower_builtin_setjmp(), lower_copyprivate_clauses(), lower_omp_for_scan(), lower_omp_single_copy(), lower_omp_single_simple(), lower_omp_target(), lower_omp_taskreg(), lower_rec_input_clauses(), lower_reduction_clauses(), make_bit_field_ref(), make_range_step(), maybe_optimize_arith_overflow(), maybe_optimize_mod_cmp(), ipa_param_adjustments::modify_call(), negate_expr(), omit_one_operand_loc(), omit_two_operands_loc(), omp_accumulate_sibling_list(), omp_extract_for_data(), omp_reduction_init_op(), optimize_bit_field_compare(), optimize_range_tests_to_bit_test(), optimize_stdarg_builtin(), predicate_bbs(), record_edge_info(), set_endptr_and_length(), simplify_builtin_call(), size_diffop_loc(), store_expr(), update_range_test(), and worker_single_simple().
bool fold_convertible_p | ( | const_tree | type, |
const_tree | arg ) |
Returns true, if ARG is convertible to TYPE using a NOP_EXPR.
References INTEGRAL_TYPE_P, known_eq, POINTER_TYPE_P, TREE_CODE, tree_int_cst_equal(), TREE_TYPE, TYPE_MAIN_VARIANT, TYPE_PRECISION, TYPE_SIZE, TYPE_VECTOR_SUBPARTS(), and VECTOR_TYPE_P.
Referenced by ipcp_modif_dom_walker::before_dom_children(), declare_return_variable(), eliminate_redundant_comparison(), force_value_to_type(), ipacp_value_safe_for_type(), and ipa_param_adjustments::modify_call().
void fold_defer_overflow_warnings | ( | void | ) |
Start deferring overflow warnings. We could use a stack here to permit nested calls, but at present it is not necessary.
References fold_deferring_overflow_warnings.
Referenced by cleanup_control_expr_graph(), combine_cond_expr_cond(), compare_values_warnv(), create_runtime_alias_checks(), estimate_numbers_of_iterations(), evaluate_stmt(), expand_simple_operations(), fold_stmt_1(), loop_exits_before_overflow(), loop_niter_by_eval(), number_of_iterations_exit_assumptions(), and jump_threader::simplify_control_stmt_condition_1().
bool fold_deferring_overflow_warnings_p | ( | void | ) |
Whether we are deferring overflow warnings.
References fold_deferring_overflow_warnings.
Referenced by verify_interpass_invariants().
enum tree_code fold_div_compare | ( | enum tree_code | code, |
tree | c1, | ||
tree | c2, | ||
tree * | lo, | ||
tree * | hi, | ||
bool * | neg_overflow ) |
Subroutine of match.pd that optimizes comparisons of a division by a nonzero integer constant against an integer constant, i.e. X/C1 op C2. CODE is the comparison operator: EQ_EXPR, NE_EXPR, GT_EXPR, LT_EXPR, GE_EXPR or LE_EXPR. ARG01 and ARG1 must be a INTEGER_CST.
References wi::add(), build_int_cst(), fold_negate_const(), force_fit_type(), gcc_unreachable, int_const_binop(), wi::mul(), NULL_TREE, operand_equal_p(), swap_tree_comparison(), wi::to_wide(), tree_int_cst_sgn(), TREE_OVERFLOW, TREE_TYPE, TYPE_MAX_VALUE, TYPE_MIN_VALUE, TYPE_SIGN, and UNSIGNED.
Strip non-trapping, non-side-effecting tree nodes from an expression whose result is ignored. The type of the returned tree need not be the same as the original expression.
References integer_zero_node, tcc_binary, tcc_comparison, tcc_expression, tcc_unary, TREE_CODE, TREE_CODE_CLASS, TREE_OPERAND, and TREE_SIDE_EFFECTS.
Referenced by fold_convert_loc(), and omit_one_operand_loc().
Given a pointer value OP0 and a type TYPE, return a simplified version of an indirection through OP0, or NULL_TREE if no simplification is possible.
References bitsize_int, build4_loc(), build_fold_indirect_ref_loc(), DECL_INITIAL, fold_build1_loc(), fold_build3_loc(), fold_read_from_constant_string(), in_gimple_form, known_eq, known_lt, NULL_TREE, POINTER_TYPE_P, poly_int_tree_p(), size_zero_node, sizetype, STRIP_NOPS, wi::to_poly_offset(), TREE_CODE, tree_fits_poly_int64_p(), TREE_OPERAND, tree_to_uhwi(), TREE_TYPE, TYPE_DOMAIN, TYPE_MIN_VALUE, TYPE_REF_CAN_ALIAS_ALL, TYPE_SIZE, TYPE_SIZE_UNIT, TYPE_VECTOR_SUBPARTS(), VECTOR_TYPE_P, and wide_int_to_tree().
Referenced by build_fold_indirect_ref_loc(), copy_tree_body_r(), fold_indirect_ref_loc(), and get_base_for_alignment_1().
Given an INDIRECT_REF T, return either T or a simplified version.
References fold_indirect_ref_1(), TREE_OPERAND, and TREE_TYPE.
Referenced by gimplify_compound_lval(), and gimplify_expr().
References END_FOLD_INIT, fold(), and START_FOLD_INIT.
Fold the truth-negation of ARG. This never alters ARG itself. We assume that ARG is an operation that returns a truth value (0 or 1 for scalars, 0 or -1 for vectors). Return the folded expression if folding is successful. Otherwise, return NULL_TREE.
References fold_unary_loc(), TREE_TYPE, and VECTOR_TYPE_P.
Referenced by fold_ternary_loc().
Subroutine of fold_binary. Optimize complex multiplications of the form z * conj(z), as pow(realpart(z),2) + pow(imagpart(z),2). The argument EXPR represents the expression "z" of type TYPE.
References build_zero_cst(), fold_build1_loc(), fold_build2_loc(), save_expr(), TREE_CODE, TREE_IMAGPART, TREE_OPERAND, TREE_REALPART, and TREE_TYPE.
Referenced by fold_binary_loc().
Return the tree for neg (ARG0) when ARG0 is known to be either an integer constant, real, or fixed-point constant. TYPE is the type of the result.
References build_fixed(), build_real(), fixed_arithmetic(), FIXED_VALUE_TYPE, force_fit_type(), gcc_unreachable, wi::neg(), NULL, NULL_TREE, poly_int_tree_p(), real_value_negate(), wi::to_poly_wide(), TREE_CODE, TREE_FIXED_CST, TREE_OVERFLOW, TREE_REAL_CST, TYPE_SATURATING, and TYPE_UNSIGNED.
Referenced by const_unop(), fold_div_compare(), and fold_negate_expr_1().
A wrapper for fold_negate_expr_1.
References fold_convert_loc(), fold_negate_expr_1(), NULL_TREE, STRIP_SIGN_NOPS, and TREE_TYPE.
Referenced by const_unop(), fold_negate_expr_1(), fold_unary_loc(), and negate_expr().
Given T, an expression, return a folded tree for -T or NULL_TREE, if no simplification is possible. If negate_expr_p would return true for T, NULL_TREE will never be returned.
References ANY_INTEGRAL_TYPE_P, tree_vector_builder::build(), build_call_expr_loc(), build_complex(), build_one_cst(), CALL_EXPR_ARG, count, element_precision(), vector_builder< T, Shape, Derived >::encoded_nelts(), fold_build1_loc(), fold_build2_loc(), fold_convert_loc(), fold_negate_const(), fold_negate_expr(), get_call_combined_fn(), get_callee_fndecl(), HONOR_SIGN_DEPENDENT_ROUNDING(), HONOR_SIGNED_ZEROS(), i, integer_onep(), INTEGRAL_TYPE_P, negate_expr(), negate_expr_p(), negate_mathfn_p(), vector_builder< T, Shape, Derived >::new_unary_operation(), NULL_TREE, SANITIZE_SI_OVERFLOW, SCALAR_FLOAT_TYPE_P, signed_type_for(), strip_float_extensions(), wi::to_wide(), TREE_CODE, TREE_IMAGPART, TREE_OPERAND, TREE_OVERFLOW, TREE_REALPART, TREE_TYPE, TYPE_OVERFLOW_SANITIZED, TYPE_OVERFLOW_TRAPS, TYPE_OVERFLOW_WRAPS, TYPE_UNSIGNED, unsigned_type_for(), and VECTOR_CST_ELT.
Referenced by fold_negate_expr().
|
static |
Return the tree for not (ARG0) when ARG0 is known to be an integer constant. TYPE is the type of the result.
References force_fit_type(), gcc_assert, wi::to_wide(), TREE_CODE, and TREE_OVERFLOW.
Referenced by const_unop().
void fold_overflow_warning | ( | const char * | gmsgid, |
enum warn_strict_overflow_code | wc ) |
This is called when we fold something based on the fact that signed overflow is undefined.
References fold_deferred_overflow_code, fold_deferred_overflow_warning, fold_deferring_overflow_warnings, issue_strict_overflow_warning, NULL, and warning().
Referenced by fold_binary_loc(), fold_comparison(), fold_range_test(), maybe_canonicalize_comparison(), tree_expr_nonnegative_p(), and tree_expr_nonzero_p().
|
static |
Fold a sum or difference of at least one multiplication. Returns the folded tree or NULL if no simplification could be made.
References absu_hwi(), ALL_FRACT_MODE_P, ANY_INTEGRAL_TYPE_P, build_int_cst(), build_one_cst(), fold_build2_loc(), fold_convert, fold_convert_loc(), wi::min_value(), wi::neg_p(), negate_expr(), negate_expr_p(), NULL_TREE, operand_equal_p(), pow2p_hwi(), SIGNED, wi::to_wide(), TREE_CODE, tree_fits_shwi_p(), TREE_OPERAND, tree_to_shwi(), TREE_TYPE, TYPE_MODE, TYPE_OVERFLOW_WRAPS, TYPE_PRECISION, TYPE_SIGN, and unsigned_type_for().
Referenced by fold_binary_loc().
|
static |
EXP is some logical combination of boolean tests. See if we can merge it into some range test. Return the new tree if so.
References build2_loc(), build_range_check(), CONTAINS_PLACEHOLDER_P, lang_hooks::decls, fold_overflow_warning(), G_, lang_hooks_for_decls::global_bindings_p, integer_zero_node, INTEGRAL_TYPE_P, invert_truthvalue_loc(), LOGICAL_OP_NON_SHORT_CIRCUIT, make_range(), merge_ranges(), operand_equal_p(), sanitize_coverage_p(), save_expr(), simple_operand_p(), and WARN_STRICT_OVERFLOW_COMPARISON.
Referenced by fold_truth_andor().
If EXP represents referencing an element in a constant string (either via pointer arithmetic or array indexing), return the tree representing the value accessed, otherwise return NULL.
References array_ref_low_bound(), build_int_cst_type(), compare_tree_int(), exp(), EXPR_LOCATION, fold_convert_loc(), GET_MODE_SIZE(), INDIRECT_REF_P, integer_zerop(), is_int_mode(), NULL, size_diffop_loc(), sizetype, string_constant(), TREE_CODE, tree_fits_uhwi_p(), TREE_INT_CST_LOW, TREE_OPERAND, TREE_STRING_LENGTH, TREE_STRING_POINTER, TREE_TYPE, and TYPE_MODE.
Referenced by expand_expr_real_1(), fold_const_aggregate_ref_1(), and fold_indirect_ref_1().
tree fold_read_from_vector | ( | tree | arg, |
poly_uint64 | idx ) |
Folds a read from vector element at IDX of vector ARG.
References build_zero_cst(), CONSTRUCTOR_ELT, CONSTRUCTOR_NELTS, i, poly_int< N, C >::is_constant(), known_ge, known_lt, NULL_TREE, TREE_CODE, TREE_TYPE, TYPE_VECTOR_SUBPARTS(), VECTOR_CST_ELT, and VECTOR_TYPE_P.
bool fold_real_zero_addition_p | ( | const_tree | type, |
const_tree | arg, | ||
const_tree | zero_arg, | ||
int | negate ) |
Subroutine of fold() that checks for the addition of ARG +/- 0.0. If !NEGATE, return true if ZERO_ARG is +/-0.0 and, for all ARG of type TYPE, ARG + ZERO_ARG is the same as ARG. If NEGATE, return true if ARG - ZERO_ARG is the same as X. If ARG is NULL, check for any value of type TYPE. X + 0 and X - 0 both give X when X is NaN, infinite, or nonzero and finite. The problematic cases are when X is zero, and its mode has signed zeros. In the case of rounding towards -infinity, X - 0 is not the same as X because 0 - 0 is -0. In other rounding modes, X + 0 is not the same as X because -0 + 0 is 0.
References HONOR_SIGN_DEPENDENT_ROUNDING(), HONOR_SIGNED_ZEROS(), HONOR_SNANS(), REAL_VALUE_MINUS_ZERO, real_zerop(), TREE_CODE, tree_expr_maybe_real_minus_zero_p(), tree_expr_maybe_signaling_nan_p(), TREE_REAL_CST, and uniform_vector_p().
Referenced by eliminate_using_constants().
Given CODE, a relational operator, the target type, TYPE and two constant operands OP0 and OP1, return the result of the relational operation. If the result is not a compile time constant, then return NULL_TREE.
References tree_vector_builder::build(), build_int_cst(), constant_boolean_node(), count, vector_builder< T, Shape, Derived >::encoded_nelts(), fixed_compare(), FIXED_VALUE_TYPE, fold_build2, fold_relational_const(), gcc_assert, gcc_unreachable, i, integer_zerop(), invert_tree_comparison(), known_eq, vector_builder< T, Shape, Derived >::new_binary_operation(), NULL_TREE, real_compare(), real_isnan(), REAL_VALUE_TYPE, swap_tree_comparison(), TREE_CODE, TREE_FIXED_CST_PTR, TREE_IMAGPART, tree_int_cst_equal(), tree_int_cst_lt(), TREE_REAL_CST_PTR, TREE_REALPART, TREE_TYPE, VECTOR_CST_ELT, VECTOR_CST_NELTS, and VECTOR_TYPE_P.
Referenced by const_binop(), and fold_relational_const().
tree fold_ternary_loc | ( | location_t | loc, |
enum tree_code | code, | ||
tree | type, | ||
tree | op0, | ||
tree | op1, | ||
tree | op2 ) |
Fold a ternary expression of code CODE and type TYPE with operands OP0, OP1, and OP2. Return the folded expression if folding is successful. Otherwise, return NULL_TREE.
References b, wi::bit_or(), tree_vector_builder::build(), can_native_interpret_type_p(), commutative_ternary_tree_code(), COMPARISON_CLASS_P, CONSTANT_CLASS_P, CONSTRUCTOR_ELTS, contains_label_p(), expr_location_or(), fold_build1, fold_build2_loc(), fold_build3_loc(), fold_cond_expr_with_comparison(), fold_convert_loc(), fold_invert_truthvalue(), fold_vec_perm(), FOR_EACH_CONSTRUCTOR_ELT, gcc_assert, gcc_unreachable, generic_simplify(), HONOR_NANS(), HONOR_SIGNED_ZEROS(), i, integer_all_onesp(), integer_onep(), integer_pow2p(), integer_zerop(), invert_tree_comparison(), invert_truthvalue_loc(), IS_EXPR_CODE_CLASS, known_le, wi::lshift(), native_encode_expr(), native_interpret_expr(), NULL, NULL_TREE, OEP_ONLY_CONST, operand_equal_for_comparison_p(), operand_equal_p(), protected_set_expr_location_unshare(), wi::shifted_mask(), sign_bit_p(), signed_type_for(), STRIP_NOPS, wi::to_wide(), TREE_CODE, TREE_CODE_CLASS, TREE_CODE_LENGTH, tree_fits_uhwi_p(), tree_log2(), TREE_OPERAND, TREE_SIDE_EFFECTS, tree_swap_operands_p(), tree_to_uhwi(), tree_to_vec_perm_builder(), TREE_TYPE, truth_value_p(), type_contains_placeholder_p(), TYPE_PRECISION, TYPE_SIZE, TYPE_UNSIGNED, TYPE_VECTOR_SUBPARTS(), types_compatible_p(), unsigned_type_for(), VECTOR_CST_ELT, VECTOR_CST_NELTS, VECTOR_TYPE_P, VOID_TYPE_P, wide_int_to_tree(), and wi::zext().
Referenced by fold(), fold_build3_loc(), fold_gimple_assign(), gimple_fold_stmt_to_constant_1(), and maybe_fold_reference().
Fold A < X && A + 1 > Y to A < X && A >= Y. Normally A + 1 > Y means A >= Y && A != MAX, but in this case we know that A < X <= MAX. INEQ is A + 1 > Y, BOUND is A < X.
References a, fold_binary_loc(), fold_build2_loc(), fold_convert_loc(), integer_onep(), INTEGRAL_TYPE_P, NULL_TREE, POINTER_TYPE_P, ssizetype, TREE_CODE, TREE_OPERAND, TREE_TYPE, and y.
Referenced by fold_binary_loc().
|
static |
Fold a binary bitwise/truth expression of code CODE and type TYPE with operands OP0 and OP1. LOC is the location of the resulting expression. ARG0 and ARG1 are the NOP_STRIPed results of OP0 and OP1. Return the folded expression if folding is successful. Otherwise, return NULL_TREE.
References fold_build2_loc(), fold_range_test(), fold_truth_andor_1(), LOGICAL_OP_NON_SHORT_CIRCUIT, merge_truthop_with_opposite_arm(), NULL_TREE, operand_equal_p(), sanitize_coverage_p(), simple_condition_p(), TREE_CODE, TREE_OPERAND, and TREE_SIDE_EFFECTS.
Referenced by fold_binary_loc().
|
static |
Find ways of folding logical expressions of LHS and RHS: Try to merge two comparisons to the same innermost item. Look for range tests like "ch >= '0' && ch <= '9'". Look for combinations of simple terms on machines with expensive branches and evaluate the RHS unconditionally. For example, if we have p->a == 2 && p->b == 4 and we can make an object large enough to span both A and B, we can do this with a comparison against the object ANDed with the a mask. If we have p->a == q->a && p->b == q->b, we may be able to use bit masking operations to do this with one comparison. We check for both normal comparisons and the BIT_AND_EXPRs made this by function and the one above. CODE is the logical operation being done. It can be TRUTH_ANDIF_EXPR, TRUTH_AND_EXPR, TRUTH_ORIF_EXPR, or TRUTH_OR_EXPR. TRUTH_TYPE is the type of the logical operand and LHS and RHS are its two operands. We return the simplified tree or 0 if no optimization is possible.
References all_ones_mask_p(), BITS_PER_WORD, build2(), build2_loc(), build_int_cst(), cfun, combine_comparisons(), const_binop(), constant_boolean_node(), decode_field_reference(), FLOAT_TYPE_P, fold_build1_loc(), fold_convert_loc(), get_best_mode(), GET_MODE_BITSIZE(), integer_onep(), integer_pow2p(), integer_zerop(), INTEGRAL_TYPE_P, make_bit_field_ref(), MAX, MIN, NULL_TREE, operand_equal_p(), optimize_function_for_speed_p(), simple_cst_equal(), simple_operand_p(), size_int, swap_tree_comparison(), tcc_comparison, TREE_CODE, TREE_CODE_CLASS, TREE_OPERAND, TREE_SIDE_EFFECTS, TREE_TYPE, type(), TYPE_ALIGN, lang_hooks_for_types::type_for_size, lang_hooks::types, unextend(), and warning().
Referenced by fold_truth_andor().
Return a simplified tree node for the truth-negation of ARG. This never alters ARG itself. We assume that ARG is an operation that returns a truth value (0 or 1). FIXME: one would think we would fold the result, but it causes problems with the dominator optimizer.
References build1_loc(), build2_loc(), build3_loc(), build_int_cst(), CASE_CONVERT, constant_boolean_node(), copy_warning(), expr_location_or(), FLOAT_TYPE_P, HONOR_NANS(), integer_onep(), integer_zerop(), invert_tree_comparison(), invert_truthvalue_loc(), NULL_TREE, tcc_comparison, TREE_CODE, TREE_CODE_CLASS, TREE_OPERAND, TREE_TYPE, and VOID_TYPE_P.
Referenced by fold_unary_loc().
If the operation was a conversion do _not_ mark a resulting constant with TREE_OVERFLOW if the original constant was not. These conversions have implementation defined behavior and retaining the TREE_OVERFLOW flag here would confuse later passes such as VRP.
References CONVERT_EXPR_CODE_P, fold_unary_loc(), TREE_CODE, and TREE_OVERFLOW.
Fold a unary expression of code CODE and type TYPE with operand OP0. Return the folded expression if folding is successful. Otherwise, return NULL_TREE.
References BITS_PER_WORD, build1_loc(), build2(), build2_loc(), build3(), build3_loc(), build_aligned_type(), build_fold_addr_expr_loc(), CASE_CONVERT, COMPARISON_CLASS_P, const_unop(), constant_boolean_node(), CONSTANT_CLASS_P, CONVERT_EXPR_CODE_P, CONVERT_EXPR_P, DECL_BIT_FIELD, fold_build1_loc(), fold_build2_loc(), fold_build3_loc(), fold_build_pointer_plus_loc(), fold_convert_loc(), fold_negate_expr(), fold_truth_not_expr(), fold_unary_loc(), force_fit_type(), wide_int_storage::from(), gcc_assert, generic_simplify(), get_inner_reference(), handled_component_p(), HOST_BITS_PER_WIDE_INT, HOST_WIDE_INT_M1U, in_gimple_form, INTEGRAL_TYPE_P, IS_EXPR_CODE_CLASS, known_eq, load_extend_op(), MAX, maybe_lvalue_p(), min_align_of_type(), NULL_TREE, offset, POINTER_TYPE_P, REF_REVERSE_STORAGE_ORDER, SANITIZE_ALIGNMENT, sanitize_flags_p(), SANITIZE_NULL, SANITIZE_SI_OVERFLOW, strip_float_extensions(), STRIP_NOPS, STRIP_SIGN_NOPS, suppress_warning(), tcc_unary, wi::to_wide(), TREE_CODE, TREE_CODE_CLASS, TREE_CODE_LENGTH, TREE_CONSTANT, tree_fits_uhwi_p(), TREE_OPERAND, TREE_OVERFLOW, TREE_READONLY, tree_to_uhwi(), TREE_TYPE, TREE_USED, type(), TYPE_ALIGN, TYPE_MAIN_VARIANT, TYPE_MODE, TYPE_OVERFLOW_WRAPS, TYPE_PRECISION, TYPE_QUALS, TYPE_SIGN, TYPE_UNQUALIFIED, TYPE_UNSIGNED, unsigned_type_for(), VAR_P, and VOID_TYPE_P.
Referenced by expand_expr_real_1(), fold(), fold_binary_loc(), fold_build1_loc(), fold_invert_truthvalue(), fold_unary_ignore_overflow_loc(), fold_unary_loc(), gimple_fold_stmt_to_constant_1(), and maybe_fold_reference().
Given the components of a unary expression CODE, TYPE and OP0, attempt to fold the expression to a constant without modifying TYPE or OP0. If the expression could be simplified to a constant, then return the constant. If the expression would not be simplified to a constant, then return NULL_TREE.
References fold_unary, NULL_TREE, and TREE_CONSTANT.
void fold_undefer_and_ignore_overflow_warnings | ( | void | ) |
Stop deferring overflow warnings, ignoring any deferred warnings.
References fold_undefer_overflow_warnings(), and NULL.
Referenced by cleanup_control_expr_graph(), compare_values_warnv(), create_runtime_alias_checks(), estimate_numbers_of_iterations(), expand_simple_operations(), loop_exits_before_overflow(), loop_niter_by_eval(), and number_of_iterations_exit_assumptions().
Stop deferring overflow warnings. If there is a pending warning, and ISSUE is true, then issue the warning if appropriate. STMT is the statement with which the warning should be associated (used for location information); STMT may be NULL. CODE is the level of the warning--a warn_strict_overflow_code value. This function will use the smaller of CODE and the deferred code when deciding whether to issue the warning. CODE may be zero to mean to always use the deferred code.
References fold_deferred_overflow_code, fold_deferred_overflow_warning, fold_deferring_overflow_warnings, gcc_assert, gimple_location(), input_location, issue_strict_overflow_warning, NULL, warning_at(), and warning_suppressed_p().
Referenced by cleanup_control_expr_graph(), combine_cond_expr_cond(), evaluate_stmt(), fold_stmt_1(), fold_undefer_and_ignore_overflow_warnings(), and jump_threader::simplify_control_stmt_condition_1().
tree fold_vec_perm | ( | tree | type, |
tree | arg0, | ||
tree | arg1, | ||
const vec_perm_indices & | sel ) |
Attempt to fold vector permutation of ARG0 and ARG1 vectors using SEL selector. Return the folded VECTOR_CST or CONSTRUCTOR if successful, NULL_TREE otherwise.
References build_constructor(), CONSTRUCTOR_APPEND_ELT, fold_vec_perm_cst(), gcc_assert, i, poly_int< N, C >::is_constant(), known_eq, vec_perm_indices::length(), NULL_TREE, TREE_CODE, TREE_TYPE, TYPE_VECTOR_SUBPARTS(), vec_alloc(), and vec_cst_ctor_to_array().
Referenced by fold_ternary_loc().
|
static |
Try to fold permutation of ARG0 and ARG1 with SEL selector when the input vectors are VECTOR_CST. Return NULL_TREE otherwise. REASON has same purpose as described in valid_mask_for_fold_vec_perm_cst_p.
References tree_vector_builder::build(), vec_perm_indices::encoding(), i, vector_builder< T, Shape, Derived >::nelts_per_pattern(), vector_builder< T, Shape, Derived >::npatterns(), NULL_TREE, r, TREE_TYPE, TYPE_VECTOR_SUBPARTS(), valid_mask_for_fold_vec_perm_cst_p(), vector_cst_elt(), and VECTOR_CST_NELTS_PER_PATTERN.
Referenced by fold_vec_perm().
Fold a VIEW_CONVERT_EXPR of a constant expression EXPR to type TYPE at compile-time. If we're unable to perform the conversion return NULL_TREE.
References CHAR_BIT, fold_view_convert_vector_encoding(), int_size_in_bytes(), native_encode_expr(), native_interpret_expr(), NULL_TREE, TREE_CODE, VECTOR_TYPE_P, and WIDE_INT_MAX_PRECISION.
Referenced by const_unop().
Try to view-convert VECTOR_CST EXPR to VECTOR_TYPE TYPE by operating directly on the VECTOR_CST encoding, in a way that works for variable- length vectors. Return the resulting VECTOR_CST on success or null on failure.
References CEIL, INTEGRAL_TYPE_P, known_gt, least_common_multiple(), native_encode_vector_part(), native_interpret_vector_part(), NULL_TREE, poly_int_tree_p(), TREE_TYPE, TYPE_SIZE, TYPE_VECTOR_SUBPARTS(), VECTOR_CST_NELTS_PER_PATTERN, VECTOR_CST_NPATTERNS, VECTOR_CST_STEPPED_P, and vector_element_size.
Referenced by fold_view_convert_expr().
Gets the element ACCESS_INDEX from CTOR, which must be a CONSTRUCTOR of an array (or vector). *CTOR_IDX if non-NULL is updated with the constructor element index of the value returned. If the element is not found NULL_TREE is returned and *CTOR_IDX is updated to the index of the element after the ACCESS_INDEX position (which may be outside of the CTOR array).
References wi::cmp(), CONSTRUCTOR_ELTS, wi::ext(), FOR_EACH_CONSTRUCTOR_ELT, gcc_assert, gcc_checking_assert, wi::gt_p(), in_gimple_form, wi::le_p(), NULL_TREE, RAW_DATA_LENGTH, SIGNED, wi::to_offset(), wi::to_wide(), TREE_CODE, tree_int_cst_lt(), TREE_OPERAND, TREE_TYPE, TYPE_DOMAIN, TYPE_MAX_VALUE, TYPE_MIN_VALUE, TYPE_PRECISION, TYPE_SIGN, TYPE_UNSIGNED, and UNSIGNED.
Referenced by fold(), and fold_array_ctor_reference().
const char * getbyterep | ( | tree | src, |
unsigned HOST_WIDE_INT * | strsize ) |
Return a pointer to a NUL-terminated string containing the sequence of bytes corresponding to the representation of the object referred to by SRC (or a subsequence of such bytes within it if SRC is a reference to an initialized constant array plus some constant offset). Set *STRSIZE the number of bytes in the constant sequence including the terminating NUL byte. *STRSIZE is equal to sizeof(A) - OFFSET where A is the array that stores the constant sequence that SRC points to and OFFSET is the byte offset of SRC from the beginning of A. SRC need not point to a string or even an array of characters but may point to an object of any type.
References array_size, byte_representation(), NULL, NULL_TREE, offset, string_constant(), tree_fits_uhwi_p(), TREE_STRING_LENGTH, TREE_STRING_POINTER, tree_to_uhwi(), TREE_TYPE, and TYPE_SIZE_UNIT.
Referenced by c_getstr(), expand_builtin_memcmp(), expand_builtin_memory_copy_args(), fold_const_call(), gimple_fold_builtin_memchr(), gimple_fold_builtin_memory_op(), gimple_fold_builtin_string_compare(), and inline_expand_builtin_bytecmp().
|
static |
Check whether TYPE1 and TYPE2 are equivalent integer types, suitable for use in int_const_binop, size_binop and size_diffop.
References INTEGRAL_TYPE_P, POINTER_TYPE_P, TYPE_MODE, TYPE_PRECISION, and TYPE_UNSIGNED.
Referenced by size_binop_loc(), and size_diffop_loc().
tree int_const_binop | ( | enum tree_code | code, |
const_tree | arg1, | ||
const_tree | arg2, | ||
int | overflowable ) |
Combine two integer constants ARG1 and ARG2 under operation CODE to produce a new constant. Return NULL_TREE if we don't know how to evaluate CODE at compile-time.
References force_fit_type(), NULL_TREE, wi::OVF_NONE, poly_int_binop(), poly_int_tree_p(), SIGNED, TREE_OVERFLOW, TREE_TYPE, and TYPE_SIGN.
Referenced by tree_switch_conversion::switch_conversion::build_constructors(), build_debug_ref_for_model(), build_ref_for_offset(), build_user_friendly_ref_for_offset(), tree_switch_conversion::switch_conversion::collect(), const_binop(), create_component_ref_by_pieces_1(), do_vec_narrow_conversion(), tree_switch_conversion::bit_test_cluster::emit(), tree_switch_conversion::switch_conversion::exp_index_transform(), expand_vector_comparison(), expand_vector_condition(), expand_vector_conversion(), expand_vector_piecewise(), extract_bit_test_mask(), find_case_label_range(), fold_binary_loc(), fold_comparison(), fold_const_call(), fold_const_call(), fold_div_compare(), get_up_bounds_for_array_ref(), inbounds_memaccess_p(), initialize_ao_ref_for_dse(), instrument_bool_enum_load(), inverse(), layout_type(), maybe_canonicalize_comparison_1(), maybe_canonicalize_mem_ref_addr(), maybe_fold_tmr(), maybe_rewrite_mem_ref_base(), ipa_param_adjustments::modify_call(), rt_bb_visited::push_rtcfg_pair(), simplify_using_ranges::simplify(), simplify_using_ranges::simplify_div_or_mod_using_ranges(), simplify_using_ranges::simplify_switch_using_ranges(), simplify_using_ranges::simplify_truth_ops_using_ranges(), size_binop_loc(), tree_fold_divides_p(), type_has_padding_at_level_p(), value_replacement(), vectorizable_live_operation(), vectorizable_live_operation_1(), vectorizable_load(), vectorizable_reduction(), vectorizable_scan_store(), vectorizable_store(), vn_reference_lookup_3(), and rt_bb_visited::vword().
Return true if the floating point result of (CODE OP0 OP1) has an integer value. We also allow +Inf, -Inf and NaN to be considered integer values. Return false for signaling NaN. DEPTH is the current nesting depth of the query.
References RECURSE.
Referenced by gimple_assign_integer_valued_real_p(), and integer_valued_real_p().
bool integer_valued_real_call_p | ( | combined_fn | fn, |
tree | arg0, | ||
tree | arg1, | ||
int | depth ) |
Return true if the floating point result of calling FNDECL with arguments ARG0 and ARG1 has an integer value. We also allow +Inf, -Inf and NaN to be considered integer values. Return false for signaling NaN. If FNDECL takes fewer than 2 arguments, the remaining ARGn are null. DEPTH is the current nesting depth of the query.
References RECURSE.
Referenced by gimple_call_integer_valued_real_p(), and integer_valued_real_p().
Return true if the floating point expression T (a GIMPLE_INVALID_RHS) has an integer value. We also allow +Inf, -Inf and NaN to be considered integer values. Return false for signaling NaN. DEPTH is the current nesting depth of the query.
References RECURSE, TREE_CODE, and TREE_OPERAND.
Referenced by integer_valued_real_p().
Return true if the floating point expression T has an integer value. We also allow +Inf, -Inf and NaN to be considered integer values. Return false for signaling NaN. DEPTH is the current nesting depth of the query.
References CALL_EXPR_ARG, call_expr_nargs, error_mark_node, get_call_combined_fn(), integer_valued_real_binary_p(), integer_valued_real_call_p(), integer_valued_real_invalid_p(), integer_valued_real_single_p(), integer_valued_real_unary_p(), NULL_TREE, STRIP_ANY_LOCATION_WRAPPER, tcc_binary, tcc_comparison, tcc_constant, tcc_declaration, tcc_reference, tcc_unary, TREE_CODE, TREE_CODE_CLASS, and TREE_OPERAND.
Return true if the floating point expression T (a GIMPLE_SINGLE_RHS) has an integer value. We also allow +Inf, -Inf and NaN to be considered integer values. Return false for signaling NaN. DEPTH is the current nesting depth of the query.
References gimple_stmt_integer_valued_real_p(), name_registered_for_update_p(), real_isinteger(), RECURSE, SSA_NAME_DEF_STMT, TREE_CODE, TREE_OPERAND, TREE_REAL_CST_PTR, TREE_TYPE, and TYPE_MODE.
Referenced by gimple_assign_integer_valued_real_p(), gimple_phi_integer_valued_real_p(), and integer_valued_real_p().
Return true if the floating point result of (CODE OP0) has an integer value. We also allow +Inf, -Inf and NaN to be considered integer values. Return false for signaling NaN. DEPTH is the current nesting depth of the query.
References CASE_CONVERT, RECURSE, SCALAR_FLOAT_TYPE_P, TREE_CODE, and TREE_TYPE.
Referenced by gimple_assign_integer_valued_real_p(), and integer_valued_real_p().
bool inverse_conditions_p | ( | const_tree | cond1, |
const_tree | cond2 ) |
Return true if COND1 tests the opposite condition of COND2.
References COMPARISON_CLASS_P, HONOR_NANS(), invert_tree_comparison(), operand_equal_p(), TREE_CODE, and TREE_OPERAND.
Referenced by check_redundant_cond_expr().
Given a tree comparison code, return the code that is the logical inverse. It is generally not safe to do this for floating-point comparisons, except for EQ_EXPR, NE_EXPR, ORDERED_EXPR and UNORDERED_EXPR, so we return ERROR_MARK in this case.
References gcc_unreachable.
Referenced by ipa_predicate::add_clause(), and_var_with_comparison(), bitwise_inverted_equal_p(), bound_difference(), canonicalize_bool(), cond_stmts_equal_p(), determine_value_range(), fold_relational_const(), fold_ternary_loc(), fold_truth_not_expr(), get_cmp_code(), gimple_bitwise_inverted_equal_p(), gimple_equal_p(), gimple_simplify_phiopt(), ifcombine_ifandif(), insert_predicates_for_cond(), inverse_conditions_p(), is_comparison_with_loop_invariant_p(), is_value_included_in(), iv_elimination_compare_lt(), loop_niter_by_eval(), merge_truthop_with_opposite_arm(), number_of_iterations_exit_assumptions(), optimize_range_tests_var_bound(), or_var_with_comparison(), ovce_extract_ops(), parloops_is_simple_reduction(), parse_predicate(), pred_equal_p(), pred_neg_p(), same_bool_comparison_p(), set_cond_stmt_execution_predicate(), simplify_1b(), simplify_using_ranges::simplify_compare_using_ranges_1(), spaceship_replacement(), subset_of(), vect_build_slp_tree_1(), and vectorizable_condition().
Return a simplified tree node for the truth-negation of ARG. This never alters ARG itself. We assume that ARG is an operation that returns a truth value (0 or 1 for scalars, 0 or -1 for vectors).
References fold_build1_loc(), TREE_CODE, TREE_TYPE, and VECTOR_TYPE_P.
Referenced by build_range_check(), fold_binary_loc(), fold_range_test(), fold_ternary_loc(), fold_truth_not_expr(), record_edge_info(), and update_range_test().
|
static |
Return a BIT_FIELD_REF of type TYPE to refer to BITSIZE bits of INNER starting at BITPOS. The field is unsigned if UNSIGNEDP is nonzero and uses reverse storage order if REVERSEP is nonzero. ORIG_INNER is the original memory reference used to preserve the alias set of the access.
References bitsize_int, build3_loc(), build_fold_addr_expr, build_int_cst(), build_nonstandard_integer_type(), fold_build2, fold_convert_loc(), get_alias_set(), get_inner_reference(), INTEGRAL_TYPE_P, known_eq, NULL_TREE, POINTER_TYPE_P, ptr_type_node, REF_REVERSE_STORAGE_ORDER, TREE_CODE, tree_fits_shwi_p(), TREE_OPERAND, tree_to_shwi(), TREE_TYPE, type(), TYPE_PRECISION, TYPE_SIZE, and TYPE_UNSIGNED.
Referenced by fold_truth_andor_1(), and optimize_bit_field_compare().
Given EXP, a logical expression, set the range it is testing into variables denoted by PIN_P, PLOW, and PHIGH. Return the expression actually being tested. *PLOW and *PHIGH will be made of the same type as the returned expression. If EXP is not a comparison, we will most likely not be returning a useful value and range. Set *STRICT_OVERFLOW_P to true if the return value is only valid because signed overflow is undefined; otherwise, do not change *STRICT_OVERFLOW_P.
References build_int_cst(), exp(), EXPR_LOCATION, integer_onep(), integer_type_node, IS_EXPR_CODE_CLASS, make_range_step(), NULL_TREE, range_binop(), tcc_binary, tcc_comparison, tcc_expression, TREE_CODE, TREE_CODE_CLASS, TREE_OPERAND, TREE_OPERAND_LENGTH, and TREE_TYPE.
Referenced by fold_range_test().
tree make_range_step | ( | location_t | loc, |
enum tree_code | code, | ||
tree | arg0, | ||
tree | arg1, | ||
tree | exp_type, | ||
tree * | p_low, | ||
tree * | p_high, | ||
int * | p_in_p, | ||
bool * | strict_overflow_p ) |
Helper routine for make_range. Perform one step for it, return new expression if the loop should continue or NULL_TREE if it should stop.
References ALL_FIXED_POINT_MODE_P, build2_loc(), build_int_cst(), build_zero_cst(), CASE_CONVERT, fold_build2_loc(), fold_convert_loc(), gcc_unreachable, int_fits_type_p(), integer_zero_node, integer_zerop(), INTEGRAL_TYPE_P, merge_ranges(), negate_expr(), normalize(), NULL_TREE, range_binop(), TREE_CODE, tree_int_cst_equal(), tree_int_cst_lt(), TREE_OVERFLOW, TREE_TYPE, lang_hooks_for_types::type_for_mode, TYPE_MAX_VALUE, TYPE_MIN_VALUE, TYPE_MODE, TYPE_OVERFLOW_UNDEFINED, TYPE_PRECISION, TYPE_SATURATING, TYPE_UNSIGNED, and lang_hooks::types.
Referenced by init_range_entry(), and make_range().
Mask out the tz least significant bits of X of type TYPE where tz is the number of trailing zeroes in Y.
References wi::ctz(), wi::mask(), TYPE_PRECISION, and y.
Referenced by fold_binary_loc().
|
static |
Returns TRUE if [LOW, HIGH] range check can be optimized to a bitwise check i.e. when LOW == 0xXX...X00...0 HIGH == 0xXX...X11...1 Return corresponding mask in MASK and stem in VALUE.
References wi::to_wide(), TREE_CODE, TYPE_PRECISION, and wide_int_to_tree().
Referenced by build_range_check().
bool may_negate_without_overflow_p | ( | const_tree | t | ) |
Check whether we may negate an integer constant T without causing overflow.
References gcc_assert, wi::only_sign_bit_p(), wi::to_wide(), TREE_CODE, TREE_TYPE, type(), and TYPE_UNSIGNED.
Referenced by create_iv(), and negate_expr_p().
|
static |
Canonicalize the comparison ARG0 CODE ARG1 with type TYPE with undefined overflow further. Try to decrease the magnitude of constants involved by changing LE_EXPR and GE_EXPR to LT_EXPR and GT_EXPR or vice versa and put sole constants at the second argument position. Returns the canonicalized tree if changed, otherwise NULL_TREE.
References fold_overflow_warning(), G_, maybe_canonicalize_comparison_1(), swap_tree_comparison(), and WARN_STRICT_OVERFLOW_MAGNITUDE.
Referenced by fold_comparison().
|
static |
Helper that tries to canonicalize the comparison ARG0 CODE ARG1 by changing CODE to reduce the magnitude of constants involved in ARG0 of the comparison. Returns a canonicalized comparison tree if a simplification was possible, otherwise returns NULL_TREE. Set *STRICT_OVERFLOW_P to true if the canonicalization is only valid if signed overflow is undefined.
References ANY_INTEGRAL_TYPE_P, build_int_cst(), fold_build2_loc(), fold_convert, int_const_binop(), integer_zerop(), INTEGRAL_TYPE_P, NULL_TREE, POINTER_TYPE_P, TREE_CODE, tree_int_cst_equal(), tree_int_cst_sgn(), TREE_OPERAND, TREE_OVERFLOW, TREE_TYPE, TYPE_MAX_VALUE, TYPE_MIN_VALUE, and TYPE_OVERFLOW_UNDEFINED.
Referenced by maybe_canonicalize_comparison().
|
static |
Return false if expr can be assumed not to be an lvalue, true otherwise.
References NUM_TREE_CODES, and TREE_CODE.
Referenced by fold_cond_expr_with_comparison(), fold_unary_loc(), and non_lvalue_loc().
|
static |
Return a positive integer when the symbol DECL is known to have a nonzero address, zero when it's known not to (e.g., it's a weak symbol), and a negative integer when the symbol is not yet in the symbol table and so whether or not its address is zero is unknown. For function local objects always return positive integer.
References auto_var_in_fn_p(), DECL_CONTEXT, decl_in_symtab_p(), DECL_P, folding_initializer, symtab_node::get(), symtab_node::get_create(), and TREE_CODE.
Referenced by fold_comparison(), and tree_single_nonzero_warnv_p().
bool merge_ranges | ( | int * | pin_p, |
tree * | plow, | ||
tree * | phigh, | ||
int | in0_p, | ||
tree | low0, | ||
tree | high0, | ||
int | in1_p, | ||
tree | low1, | ||
tree | high1 ) |
Given two ranges, see if we can merge them into one. Return 1 if we can, 0 if we can't. Set the output range into the specified parameters.
References build_int_cst(), GET_MODE_BITSIZE(), integer_onep(), integer_type_node, integer_zerop(), known_eq, merge_ranges(), NULL_TREE, operand_equal_p(), range_binop(), range_predecessor(), range_successor(), TREE_CODE, tree_int_cst_equal(), TREE_TYPE, TYPE_MAX_VALUE, TYPE_MIN_VALUE, TYPE_MODE, TYPE_PRECISION, and TYPE_UNSIGNED.
Referenced by fold_range_test(), make_range_step(), merge_ranges(), and optimize_range_tests().
|
static |
For an expression that has the form (A && B) || ~B or (A || B) && ~B, we can drop one of the inner expressions and simplify to A || ~B or A && ~B LOC is the location of the resulting expression. OP is the inner logical operation; the left-hand side in the examples above, while CMPOP is the right-hand side. RHS_ONLY is used to prevent us from accidentally removing a condition that guards another, as in (A != NULL && A->...) || A == NULL which we must not transform. If RHS_ONLY is true, only eliminate the right-most operand of the inner logical operation.
References fold_build2_loc(), HONOR_NANS(), invert_tree_comparison(), merge_truthop_with_opposite_arm(), NULL_TREE, operand_equal_p(), tcc_comparison, TREE_CODE, TREE_CODE_CLASS, TREE_OPERAND, TREE_SIDE_EFFECTS, and TREE_TYPE.
Referenced by fold_truth_andor(), and merge_truthop_with_opposite_arm().
This is a helper function to detect min/max for some operands of COND_EXPR. The form is "(EXP0 CMP EXP1) ? EXP2 : EXP3".
References cfun, get_range_query(), HONOR_NANS(), HONOR_SIGNED_ZEROS(), operand_equal_p(), r, path_range_query::range_of_expr(), wi::to_widest(), TREE_CODE, TREE_TYPE, and TYPE_SIGN.
bool multiple_of_p | ( | tree | type, |
const_tree | top, | ||
const_tree | bottom, | ||
bool | nowrap ) |
Determine if first argument is a multiple of second argument. Return false if it is not, or we cannot easily determined it to be. An example of the sort of thing we care about (at this point; this routine could surely be made more general, and expanded to do what the *_DIV_EXPR's fold cases do now) is discovering that SAVE_EXPR (I) * SAVE_EXPR (J * 8) is a multiple of SAVE_EXPR (J * 8) when we know that the two SAVE_EXPR (J * 8) nodes are the same node. This code also handles discovering that SAVE_EXPR (I) * SAVE_EXPR (J * 8) is a multiple of 8 so we don't have to worry about dealing with a possible remainder. Note that we *look* inside a SAVE_EXPR only to determine how it was calculated; it is not safe for fold to do much of anything else with the internals of a SAVE_EXPR, since it cannot know when it will be evaluated at run time. For example, the latter example above *cannot* be implemented as SAVE_EXPR (I) * J or any variant thereof, since the value of J at evaluation time of the original SAVE_EXPR is not necessarily the same at the time the new expression is evaluated. The only optimization of this sort that would be valid is changing SAVE_EXPR (I) * SAVE_EXPR (SAVE_EXPR (J) * 8) divided by 8 to SAVE_EXPR (I) * SAVE_EXPR (J) (where the same SAVE_EXPR (J) is used in the original and the transformed version). NOWRAP specifies whether all outer operations in TYPE should be considered not wrapping. Any type conversion within TOP acts as a barrier and we will fall back to NOWRAP being false. NOWRAP is mostly used to treat expressions in TYPE_SIZE and friends as not wrapping even though they are generally using unsigned arithmetic.
References CASE_CONVERT, wi::fits_to_tree_p(), fold_build1, gimple_assign_rhs1(), gimple_assign_rhs2(), gimple_assign_rhs_code(), integer_pow2p(), integer_zerop(), multiple_of_p(), wi::multiple_of_p(), NULL, NULL_TREE, wi::one(), operand_equal_p(), POLY_INT_CST_P, poly_int_tree_p(), wi::sdiv_trunc(), SIGNED, SSA_NAME_DEF_STMT, wi::to_poly_widest(), wi::to_wide(), wi::to_widest(), TREE_CODE, tree_int_cst_sign_bit(), TREE_OPERAND, TREE_TYPE, TYPE_OVERFLOW_UNDEFINED, TYPE_PRECISION, TYPE_UNSIGNED, and wide_int_to_tree().
Referenced by determine_exit_conditions(), extract_muldiv_1(), fold_binary_loc(), handle_warn_if_not_align(), multiple_of_p(), number_of_iterations_ne(), number_of_iterations_ne_max(), place_field(), round_down_loc(), round_up_loc(), and should_interchange_loops().
|
static |
Subroutine of native_encode_expr. Encode the COMPLEX_CST specified by EXPR into the buffer PTR of length LEN bytes. Return the number of bytes placed in the buffer, or zero upon failure.
References GET_MODE_SIZE(), MAX, native_encode_expr(), NULL, SCALAR_TYPE_MODE, TREE_IMAGPART, TREE_REALPART, and TREE_TYPE.
Referenced by native_encode_expr().
|
static |
Subroutine of native_encode_expr. Encode the CONSTRUCTOR specified by EXPR into the buffer PTR of length LEN bytes. Return the number of bytes placed in the buffer, or zero upon failure.
References CHAR_BIT, CONSTRUCTOR_NELTS, MIN, NULL, tree_fits_shwi_p(), tree_to_shwi(), TREE_TYPE, and TYPE_SIZE_UNIT.
Referenced by native_encode_expr().
int native_encode_expr | ( | const_tree | expr, |
unsigned char * | ptr, | ||
int | len, | ||
int | off ) |
Subroutine of fold_view_convert_expr. Encode the INTEGER_CST, REAL_CST, FIXED_CST, COMPLEX_CST, STRING_CST, or VECTOR_CST specified by EXPR into the buffer PTR of size LEN bytes. If PTR is NULL, don't actually store anything, just do a dry run. Fail either if OFF is -1 and LEN isn't sufficient to encode the entire EXPR, or if OFF is out of bounds. Otherwise, start at byte offset OFF and encode at most LEN bytes. Return the number of bytes placed in the buffer, or zero upon failure.
References native_encode_complex(), native_encode_constructor(), native_encode_fixed(), native_encode_int(), native_encode_real(), native_encode_string(), native_encode_vector(), and TREE_CODE.
Referenced by clear_padding_type(), const_with_all_bytes_same(), constant_byte_string(), strlen_pass::count_nonzero_bytes(), fold_array_ctor_reference(), fold_ctor_reference(), fold_ternary_loc(), fold_view_convert_expr(), fully_constant_vn_reference_p(), native_encode_complex(), native_encode_initializer(), native_encode_vector_part(), native_interpret_expr(), vn_walk_cb_data::push_partial_def(), vect_check_store_rhs(), and vn_reference_lookup_3().
|
static |
Subroutine of native_encode_expr. Encode the FIXED_CST specified by EXPR into the buffer PTR of length LEN bytes. Return the number of bytes placed in the buffer, or zero upon failure.
References double_int_to_tree(), FIXED_VALUE_TYPE, GET_MODE_BITSIZE(), GET_MODE_SIZE(), HOST_BITS_PER_DOUBLE_INT, native_encode_int(), NULL_TREE, SCALAR_TYPE_MODE, TREE_FIXED_CST, TREE_TYPE, lang_hooks_for_types::type_for_size, TYPE_PRECISION, and lang_hooks::types.
Referenced by native_encode_expr().
int native_encode_initializer | ( | tree | init, |
unsigned char * | ptr, | ||
int | len, | ||
int | off, | ||
unsigned char * | mask ) |
Similar to native_encode_expr, but also handle CONSTRUCTORs, VCEs, NON_LVALUE_EXPRs and nops. If MASK is non-NULL (then PTR has to be non-NULL and OFF zero), then in addition to filling the bytes pointed by PTR with the value also clear any bits pointed by MASK that are known to be initialized, keep them as is for e.g. uninitialized padding bits or uninitialized fields.
References build_zero_cst(), CONSTRUCTOR_ELTS, CONSTRUCTOR_NO_CLEARING, count, DECL_BIT_FIELD, DECL_BIT_FIELD_REPRESENTATIVE, DECL_CHAIN, DECL_FIELD_BIT_OFFSET, DECL_PADDING_P, DECL_SIZE, DECL_SIZE_UNIT, find_bitfield_repr_type(), wi::fits_shwi_p(), gcc_assert, ggc_free(), constructor_elt::index, int_byte_position(), INT_MAX, int_size_in_bytes(), integer_zerop(), INTEGRAL_TYPE_P, wi::lshift(), MIN, native_encode_expr(), native_encode_initializer(), native_encode_int(), NULL, NULL_TREE, r, RAW_DATA_LENGTH, RAW_DATA_POINTER, wi::sext(), sizetype, STRIP_NOPS, wi::to_offset(), wi::to_wide(), TREE_CODE, tree_fits_shwi_p(), tree_fits_uhwi_p(), TREE_OPERAND, tree_to_shwi(), tree_to_uhwi(), TREE_TYPE, TYPE_DOMAIN, TYPE_FIELDS, TYPE_MAX_VALUE, TYPE_MIN_VALUE, TYPE_PRECISION, constructor_elt::value, vec_safe_iterate(), and wide_int_to_tree().
Referenced by constant_byte_string(), fold_ctor_reference(), native_encode_initializer(), and tree_add_const_value_attribute().
|
static |
Subroutine of native_encode_expr. Encode the INTEGER_CST specified by EXPR into the buffer PTR of length LEN bytes. Return the number of bytes placed in the buffer, or zero upon failure.
References as_a(), bitint_info::big_endian, wi::extract_uhwi(), gcc_assert, gcc_checking_assert, GET_MODE_PRECISION(), GET_MODE_SIZE(), bitint_info::limb_mode, MIN, NULL, offset, SCALAR_INT_TYPE_MODE, targetm, wi::to_widest(), TREE_CODE, tree_to_uhwi(), TREE_TYPE, TYPE_PRECISION, and TYPE_SIZE_UNIT.
Referenced by native_encode_expr(), native_encode_fixed(), and native_encode_initializer().
|
static |
Subroutine of native_encode_expr. Encode the REAL_CST specified by EXPR into the buffer PTR of length LEN bytes. Return the number of bytes placed in the buffer, or zero upon failure.
References gcc_assert, GET_MODE_SIZE(), MIN, NULL, offset, real_to_target(), SCALAR_FLOAT_TYPE_MODE, TREE_REAL_CST_PTR, TREE_TYPE, and TYPE_MODE.
Referenced by native_encode_expr().
|
static |
Subroutine of native_encode_expr. Encode the STRING_CST specified by EXPR into the buffer PTR of length LEN bytes. Return the number of bytes placed in the buffer, or zero upon failure.
References CHAR_BIT, MIN, NULL, TREE_CODE, tree_fits_shwi_p(), TREE_STRING_LENGTH, TREE_STRING_POINTER, tree_to_shwi(), TREE_TYPE, and TYPE_SIZE_UNIT.
Referenced by native_encode_expr().
|
static |
Subroutine of native_encode_expr. Encode the VECTOR_CST specified by EXPR into the buffer PTR of length LEN bytes. Return the number of bytes placed in the buffer, or zero upon failure.
References count, native_encode_vector_part(), and VECTOR_CST_NELTS.
Referenced by native_encode_expr().
|
static |
Like native_encode_vector, but only encode the first COUNT elements. The other arguments are as for native_encode_vector.
References CEIL, count, GET_MODE_SIZE(), i, integer_nonzerop(), MIN, native_encode_expr(), NULL, offset, SCALAR_TYPE_MODE, TREE_CODE, TREE_TYPE, TYPE_PRECISION, VECTOR_BOOLEAN_TYPE_P, and VECTOR_CST_ELT.
Referenced by fold_view_convert_vector_encoding(), and native_encode_vector().
Attempt to interpret aggregate of TYPE from bytes encoded in target byte order at PTR + OFF with LEN bytes. Does not handle unions.
References build_constructor(), byte_position(), can_native_interpret_type_p(), CONSTRUCTOR_APPEND_ELT, DECL_BIT_FIELD, DECL_BIT_FIELD_REPRESENTATIVE, DECL_CHAIN, DECL_FIELD_BIT_OFFSET, DECL_FIELD_OFFSET, DECL_PADDING_P, find_bitfield_repr_type(), gcc_assert, i, int_byte_position(), int_size_in_bytes(), INTEGRAL_TYPE_P, poly_int< N, C >::is_constant(), is_empty_type(), wi::lrshift(), native_interpret_aggregate(), native_interpret_expr(), NULL, NULL_TREE, poly_int_tree_p(), size_int, wi::to_wide(), TREE_CODE, tree_fits_shwi_p(), tree_fits_uhwi_p(), tree_to_shwi(), tree_to_uhwi(), TREE_TYPE, TYPE_DOMAIN, TYPE_FIELDS, TYPE_MAX_VALUE, TYPE_PRECISION, and wide_int_to_tree().
Referenced by native_interpret_aggregate().
Subroutine of native_interpret_expr. Interpret the contents of the buffer PTR of length LEN as a COMPLEX_CST of type TYPE. If the buffer cannot be interpreted, return NULL_TREE.
References build_complex(), GET_MODE_SIZE(), native_interpret_expr(), NULL_TREE, SCALAR_TYPE_MODE, and TREE_TYPE.
Referenced by native_interpret_expr().
Subroutine of fold_view_convert_expr. Interpret the contents of the buffer PTR of length LEN as a constant of type TYPE. For INTEGRAL_TYPE_P we return an INTEGER_CST, for SCALAR_FLOAT_TYPE_P we return a REAL_CST, etc... If the buffer cannot be interpreted, return NULL_TREE.
References clear_type_padding_in_mask(), GET_MODE_SIZE(), native_encode_expr(), native_interpret_complex(), native_interpret_fixed(), native_interpret_int(), native_interpret_real(), native_interpret_vector(), NULL_TREE, SCALAR_FLOAT_TYPE_MODE, and TREE_CODE.
Referenced by clear_padding_flush(), fold_array_ctor_reference(), fold_ctor_reference(), fold_ternary_loc(), fold_view_convert_expr(), fully_constant_vn_reference_p(), native_interpret_aggregate(), native_interpret_complex(), native_interpret_vector_part(), vn_walk_cb_data::push_partial_def(), and vn_reference_lookup_3().
Subroutine of native_interpret_expr. Interpret the contents of the buffer PTR of length LEN as a FIXED_CST of type TYPE. If the buffer cannot be interpreted, return NULL_TREE.
References build_fixed(), fixed_from_double_int(), FIXED_VALUE_TYPE, double_int::from_buffer(), GET_MODE_SIZE(), HOST_BITS_PER_DOUBLE_INT, NULL_TREE, and SCALAR_TYPE_MODE.
Referenced by native_interpret_expr().
Subroutine of native_interpret_expr. Interpret the contents of the buffer PTR of length LEN as an INTEGER_CST of type TYPE. If the buffer cannot be interpreted, return NULL_TREE.
References as_a(), bitint_info::big_endian, wi::from_buffer(), gcc_assert, gcc_checking_assert, GET_MODE_PRECISION(), GET_MODE_SIZE(), bitint_info::limb_mode, NULL_TREE, SCALAR_INT_TYPE_MODE, targetm, TREE_CODE, tree_to_uhwi(), TYPE_PRECISION, TYPE_SIZE_UNIT, and wide_int_to_tree().
Referenced by native_interpret_expr().
Subroutine of native_interpret_expr. Interpret the contents of the buffer PTR of length LEN as a REAL_CST of type TYPE. If the buffer cannot be interpreted, return NULL_TREE.
References build_real(), gcc_assert, GET_MODE_SIZE(), MIN, NULL_TREE, offset, r, real_from_target(), REAL_VALUE_TYPE, and SCALAR_FLOAT_TYPE_MODE.
Referenced by clear_padding_type(), and native_interpret_expr().
|
static |
Subroutine of native_interpret_expr. Interpret the contents of the buffer PTR of length LEN as a VECTOR_CST of type TYPE. If the buffer cannot be interpreted, return NULL_TREE.
References count, native_interpret_vector_part(), NULL_TREE, poly_int< N, C >::to_constant(), tree_to_poly_uint64(), TYPE_SIZE_UNIT, and TYPE_VECTOR_SUBPARTS().
Referenced by native_interpret_expr().
|
static |
Read a vector of type TYPE from the target memory image given by BYTES, which contains LEN bytes. The vector is known to be encodable using NPATTERNS interleaved patterns with NELTS_PER_PATTERN elements each. Return the vector on success, otherwise return null.
References tree_vector_builder::build(), build_all_ones_cst(), build_zero_cst(), vector_builder< T, Shape, Derived >::encoded_nelts(), i, native_interpret_expr(), NULL_TREE, tree_to_uhwi(), TREE_TYPE, TYPE_PRECISION, TYPE_SIZE_UNIT, and VECTOR_BOOLEAN_TYPE_P.
Referenced by fold_view_convert_vector_encoding(), and native_interpret_vector().
Like fold_negate_expr, but return a NEGATE_EXPR tree, if T cannot be negated in a simpler way. Also allow for T to be NULL_TREE, in which case return NULL_TREE.
References build1_loc(), EXPR_LOCATION, fold_convert_loc(), fold_negate_expr(), NULL_TREE, STRIP_SIGN_NOPS, TREE_TYPE, and type().
Referenced by extract_muldiv_1(), fold_binary_loc(), fold_cond_expr_with_comparison(), fold_negate_expr_1(), fold_plusminus_mult_expr(), and make_range_step().
Determine whether an expression T can be cheaply negated using the function negate_expr without introducing undefined overflow.
References wi::abs(), ANY_INTEGRAL_TYPE_P, CALL_EXPR_ARG, count, element_precision(), FLOAT_TYPE_P, get_call_combined_fn(), HONOR_SIGN_DEPENDENT_ROUNDING(), HONOR_SIGNED_ZEROS(), i, integer_onep(), INTEGRAL_TYPE_P, may_negate_without_overflow_p(), negate_expr_p(), negate_mathfn_p(), wi::popcount(), REAL_VALUE_NEGATIVE, SCALAR_FLOAT_TYPE_P, strip_float_extensions(), STRIP_SIGN_NOPS, wi::to_wide(), TREE_CODE, TREE_IMAGPART, TREE_OPERAND, TREE_REAL_CST, TREE_REALPART, TREE_TYPE, type(), TYPE_OVERFLOW_SANITIZED, TYPE_OVERFLOW_WRAPS, TYPE_UNSIGNED, VECTOR_CST_ENCODED_ELT, and vector_cst_encoded_nelts().
Referenced by fold_binary_loc(), fold_negate_expr_1(), fold_plusminus_mult_expr(), and negate_expr_p().
bool negate_mathfn_p | ( | combined_fn | fn | ) |
Return true if the built-in mathematical function specified by CODE is odd, i.e. -f(x) == f(-x).
Referenced by fold_negate_expr_1(), and negate_expr_p().
Return an expr equal to X but certainly not valid as an lvalue.
References build1_loc(), in_gimple_form, maybe_lvalue_p(), and TREE_TYPE.
Referenced by fold_binary_loc(), fold_builtin_1(), omit_one_operand_loc(), and omit_two_operands_loc().
Return a tree for the case when the result of an expression is RESULT converted to TYPE and OMITTED was previously an operand of the expression but is now not needed (e.g., we folded OMITTED * 0). If OMITTED has side effects, we must evaluate it. Otherwise, just do the conversion of RESULT to TYPE.
References build1_loc(), build2_loc(), fold_convert_loc(), fold_ignored_result(), IS_EMPTY_STMT, non_lvalue_loc(), TREE_SIDE_EFFECTS, and void_type_node.
Referenced by build_range_check(), fold_binary_loc(), fold_builtin_arith_overflow(), fold_builtin_classify(), fold_builtin_frexp(), fold_builtin_memcmp(), fold_builtin_strcspn(), fold_builtin_strpbrk(), and fold_comparison().
Return a tree for the case when the result of an expression is RESULT converted to TYPE and OMITTED1 and OMITTED2 were previously operands of the expression but are now not needed. If OMITTED1 or OMITTED2 has side effects, they must be evaluated. If both OMITTED1 and OMITTED2 have side effects, OMITTED1 is evaluated before OMITTED2. Otherwise, if neither has side effects, just do the conversion of RESULT to TYPE.
References build2_loc(), fold_convert_loc(), non_lvalue_loc(), TREE_CODE, and TREE_SIDE_EFFECTS.
Referenced by fold_binary_loc(), fold_builtin_memcmp(), fold_builtin_strspn(), and fold_builtin_unordered_cmp().
Similar to operand_equal_p, but see if ARG0 might be a variant of ARG1 with a different signedness or a narrower precision.
References CONVERT_EXPR_P, INTEGRAL_TYPE_P, operand_equal_p(), STRIP_NOPS, TREE_OPERAND, TREE_TYPE, and TYPE_PRECISION.
Referenced by fold_cond_expr_with_comparison(), and fold_ternary_loc().
bool operand_equal_p | ( | const_tree | arg0, |
const_tree | arg1, | ||
unsigned int | flags ) |
Conveinece wrapper around operand_compare class because usually we do not need to play with the valueizer.
References default_compare_instance, and operand_compare::operand_equal_p().
Referenced by add_candidate_1(), add_type_duplicate(), adjust_offsets_for_equal_base_address(), aff_combination_add_elt(), aff_combination_find_elt(), affine_function_equal_p(), all_phi_incrs_profitable_1(), vect_scalar_ops_slice::all_same_p(), analyze_evolution_in_loop(), loop_cand::analyze_oloop_reduction_var(), analyze_overlapping_iterations(), and_comparisons_1(), arith_overflow_check_p(), bitwise_equal_p(), bitwise_inverted_equal_p(), bound_difference(), build_classic_dist_vector_1(), build_range_check(), bump_vector_ptr(), can_group_stmts_p(), cand_increment(), ccp_lattice_meet(), check_bounds_or_overlap(), check_loadstore(), check_loadstore(), check_redundant_cond_expr(), check_stmt_for_type_change(), chrec_apply(), loop_distribution::classify_builtin_ldst(), loop_cand::classify_simple_reduction(), clear_live_bytes_for_ref(), compare_values_warnv(), compatible_calls_p(), compatible_complex_nodes_p(), compute_access_range(), compute_avail(), cond_if_else_store_replacement(), cond_if_else_store_replacement_1(), convert_atomic_bit_not(), convert_to_divmod(), create_add_ssa_cand(), create_component_ref_by_pieces_1(), create_ifn_alias_checks(), create_intersect_range_checks_index(), create_phi_basis_1(), create_waw_or_war_checks(), degenerate_phi_result(), determine_group_iv_cost_cond(), determine_group_iv_cost_generic(), pcom_worker::determine_offset(), dr_may_alias_p(), dse_classify_store(), dse_optimize_stmt(), dump_alias_pair(), dump_mem_ref(), eliminate_redundant_comparison(), eliminate_dom_walker::eliminate_stmt(), pointer_equiv_analyzer::enter(), eq_evolutions_p(), asan_mem_ref_hasher::equal(), cand_chain_hasher::equal(), default_hash_traits< scalar_cond_masked_key >::equal(), gimplify_hasher::equal(), innermost_loop_behavior_hash::equal(), iv_common_cand_hasher::equal(), iv_inv_expr_hasher::equal(), log_entry_hasher::equal(), mem_ref_hasher::equal(), refs_hasher::equal(), sanopt_tree_couple_hash::equal(), sanopt_tree_triplet_hash::equal(), tm_memop_hasher::equal(), tree_operand_hash::equal(), tree_operand_hash_no_se::equal(), vect_scalar_ops_slice_hash::equal(), equal_mem_array_ref_p(), tree_vector_builder::equal_p(), ipa_call_context::equal_to(), ipa_icf::sem_variable::equals_wpa(), eval_subst(), evaluate_control_stmt_using_entry_checks(), execute_update_addresses_taken(), expand_assignment(), expand_builtin_memory_chk(), expand_complex_addition(), expand_expr_real_2(), expand_omp_atomic_cas(), expand_omp_atomic_fetch_op(), expand_omp_for_static_chunk(), expand_operands(), expand_vec_cond_optab_fn(), expr_expected_value_1(), expr_to_aff_combination(), expressions_equal_p(), extr_type_from_vtbl_ptr_store(), find_basis_for_base_expr(), find_matching_predicate_in_rest_chains(), find_or_create_group(), find_range_for_lhs(), vn_walk_cb_data::finish(), finish_bitfield_layout(), fold_addr_of_array_ref_difference(), fold_binary_loc(), fold_builtin_memcmp(), fold_comparison(), fold_cond_expr_with_comparison(), fold_div_compare(), fold_plusminus_mult_expr(), fold_range_test(), fold_ternary_loc(), fold_truth_andor(), fold_truth_andor_1(), fuse_memset_builtins(), gather_mem_refs_stmt(), get_computation_cost(), get_initial_def_for_reduction(), get_initial_defs_for_reduction(), get_shiftadd_cost(), gimple_bitwise_equal_p(), gimple_bitwise_inverted_equal_p(), gimple_canonical_types_compatible_p(), gimple_compare_field_offset(), gimple_equal_p(), gimple_expand_builtin_cabs(), gimple_fold_builtin_memory_chk(), gimple_fold_builtin_memory_op(), gimple_fold_builtin_realloc(), gimple_fold_builtin_strcpy(), gimple_fold_builtin_string_compare(), gimple_fold_builtin_stxcpy_chk(), gimple_fold_call(), gimple_fold_stmt_to_constant_1(), gimple_operand_equal_value_p(), strlen_pass::handle_builtin_memset(), strlen_pass::handle_builtin_strcat(), strlen_pass::handle_pointer_plus(), hashable_expr_equal_p(), hoist_adjacent_loads(), idx_infer_loop_bounds(), indirect_refs_may_alias_p(), infer_nonnull_range_by_attribute(), predicate::init_from_control_deps(), initialize_data_dependence_relation(), initializer_constant_valid_p_1(), inverse_conditions_p(), is_combined_permutation_identity(), is_divmod_with_given_divisor(), is_strlen_related_p(), loop_exits_before_overflow(), loop_iter_phi_semi_invariant_p(), lower_vec_perm(), make_forwarders_with_degenerate_phis(), mark_aliased_reaching_defs_necessary_1(), match_arith_overflow(), maybe_diag_stxncpy_trunc(), maybe_optimize_guarding_check(), maybe_optimize_mod_cmp(), maybe_optimize_ubsan_ptr_ifn(), ipa_polymorphic_call_context::meet_with(), mem_attrs_eq_p(), mem_expr_equal_p(), merge_last(), merge_ranges(), merge_truthop_with_opposite_arm(), minmax_from_comparison(), move_hint_to_base(), move_variant_to_index(), multiple_of_p(), narrowing_initializer_constant_valid_p(), ncd_with_phi(), non_rewritable_lvalue_p(), nonoverlapping_array_refs_p(), nonoverlapping_refs_since_match_p(), tree_vector_builder::note_representative(), oacc_entry_exit_ok_1(), odr_types_equivalent_p(), omp_accumulate_sibling_list(), operand_equal_for_comparison_p(), operand_equal_for_phi_arg_p(), operator==(), optimize_atomic_bit_test_and(), optimize_bitfield_assignment_op(), optimize_memcpy_to_memset(), optimize_pow_to_exp(), optimize_spaceship(), dom_opt_dom_walker::optimize_stmt(), optimize_successive_divisions_p(), or_comparisons_1(), phi_args_equal_on_edges(), phi_convertible_by_degenerating_args(), phi_incr_cost_1(), pred_equal_p(), pred_expr_equal_p(), pred_neg_p(), predicate_rhs_code(), prune_runtime_alias_test_list(), ptr_difference_const(), range_predecessor(), range_successor(), record_biv_for_address_use(), record_group_use(), record_increment(), record_phi_increments_1(), refine_bounds_using_guard(), refine_value_range_using_guard(), remove_unused_ivs(), replace_mult_candidate(), replace_one_candidate(), replace_rhs_if_not_dup(), same_access_path_p(), same_bool_comparison_p(), same_bool_result_p(), same_data_refs(), same_data_refs_base_objects(), same_handler_p(), same_phi_args_p(), scan_operand_equal_p(), set_copy_of_val(), set_lattice_value(), set_ssa_val_to(), loop_distribution::share_memory_accesses(), should_interchange_loops(), simplify_1b(), simplify_builtin_call(), simplify_peeled_chrec(), simplify_replace_tree(), simplify_using_initial_conditions(), simplify_vector_constructor(), sink_common_stores_to_bb(), slsr_process_add(), slsr_process_phi(), sm_seq_valid_bb(), spaceship_replacement(), split_at_bb_p(), statement_sink_location(), stmt_is_power_of_op(), stmt_kills_ref_p(), stmt_may_generate_copy(), subset_of(), substitute_in_expr(), suitable_cond_bb(), test_for_singularity(), transform_add_to_multiply(), loop_distribution::transform_reduction_loop(), tree_binary_nonnegative_warnv_p(), twoval_comparison_p(), uniform_vector_p(), pcom_worker::valid_initializer_p(), valid_lattice_transition(), valid_mask_for_fold_vec_perm_cst_p(), values_equal_for_ipcp_p(), vect_add_slp_permutation(), vect_analyze_group_access_1(), vect_build_slp_tree_1(), vect_build_slp_tree_2(), vect_check_gather_scatter(), vect_check_lower_bound(), vect_create_constant_vectors(), vect_dr_aligned_if_peeled_dr_is(), vect_enhance_data_refs_alignment(), vect_find_reusable_accumulator(), vect_get_and_check_slp_defs(), vect_prune_runtime_alias_test_list(), vect_slp_tree_uniform_p(), vect_transform_cycle_phi(), vectorizable_shift(), vectorizable_with_step_bound_p(), verify_type_variant(), copy_prop::visit_phi(), vn_reference_insert(), vn_reference_lookup(), vn_reference_lookup_3(), vn_reference_lookup_pieces(), vrp_operand_equal_p(), and warn_types_mismatch().
|
static |
Optimize a bit-field compare. There are two cases: First is a compare against a constant and the second is a comparison of two items where the fields are at the same bit position relative to the start of a chunk (byte, halfword, word) large enough to contain it. In these cases we can avoid the shift implicit in bitfield extractions. For constants, we emit a compare of the shifted constant with the BIT_AND_EXPR of a mask and a byte, halfword, or word of the operand being compared. For two fields at the same position, we do the ANDs with the similar mask and compare the result of the ANDs. CODE is the comparison code, known to be either NE_EXPR or EQ_EXPR. COMPARE_TYPE is the type of the comparison, and LHS and RHS are the left and right operands of the comparison, respectively. If the optimization described above can be done, we return the resulting tree. Otherwise we return zero.
References wi::arshift(), BITS_PER_WORD, build2(), build2_loc(), build_int_cst(), build_int_cst_type(), const_binop(), constant_boolean_node(), fold_build2_loc(), fold_convert_loc(), get_best_mode(), get_bit_range(), get_inner_reference(), GET_MODE_BITSIZE(), integer_zerop(), poly_int< N, C >::is_constant(), known_eq, wi::lrshift(), make_bit_field_ref(), MIN, NULL_TREE, offset, size_int, wi::to_wide(), TREE_CODE, TREE_TYPE, TYPE_ALIGN, lang_hooks_for_types::type_for_mode, lang_hooks::types, and warning().
Referenced by fold_binary_loc().
|
static |
Return whether BASE + OFFSET + BITPOS may wrap around the address space. This is used to avoid issuing overflow warnings for expressions like &p->x which cannot wrap.
References wi::add(), bits_to_bytes_round_down, known_eq, known_le, NULL_TREE, offset, POINTER_TYPE_P, poly_int_tree_p(), wi::shwi(), wi::to_poly_wide(), poly_int< N, C >::to_uhwi(), TREE_CODE, TREE_OPERAND, TREE_OVERFLOW, TREE_TYPE, TYPE_PRECISION, TYPE_SIZE_UNIT, UNSIGNED, and wi::zero().
Referenced by fold_comparison().
bool poly_int_binop | ( | poly_wide_int & | res, |
enum tree_code | code, | ||
const_tree | arg1, | ||
const_tree | arg2, | ||
signop | sign, | ||
wi::overflow_type * | overflow ) |
Combine two poly int's ARG1 and ARG2 under operation CODE to produce a new constant in RES. Return FALSE if we don't know how to evaluate CODE at compile-time.
References wi::add(), can_min_p(), gcc_assert, wi::mul(), NULL_TREE, NUM_POLY_INT_COEFFS, poly_int_tree_p(), wi::sub(), wi::to_poly_wide(), wi::to_wide(), TREE_CODE, TREE_TYPE, TYPE_PRECISION, and wide_int_binop().
Referenced by int_const_binop().
Similar to protected_set_expr_location, but never modify x in place, if location can and needs to be set, unshare it.
References CAN_HAVE_LOCATION_P, copy_node(), EXPR_LOCATION, SET_EXPR_LOCATION, and TREE_CODE.
Referenced by decl_value_expr_insert(), fold_convert_loc(), and fold_ternary_loc().
bool ptr_difference_const | ( | tree | e1, |
tree | e2, | ||
poly_int64 * | diff ) |
Returns true if addresses of E1 and E2 differ by a constant, false otherwise. If they do, E1 - E2 is stored in *DIFF.
References cst_and_fits_in_hwi(), fold_build2, fold_convert, int_cst_value(), operand_equal_p(), split_address_to_core_and_offset(), TREE_TYPE, and type().
|
static |
The following functions are subroutines to fold_range_test and allow it to try to change a logical combination of comparisons into a range test. For example, both X == 2 || X == 3 || X == 4 || X == 5 and X >= 2 && X <= 5 are converted to (unsigned) (X - 2) <= 3 We describe each set of comparisons as being either inside or outside a range, using a variable named like IN_P, and then describe the range with a lower and upper bound. If one of the bounds is omitted, it represents either the highest or lowest value of the type. In the comments below, we represent a range by two numbers in brackets preceded by a "+" to designate being inside that range, or a "-" to designate being outside that range, so the condition can be inverted by flipping the prefix. An omitted bound is represented by a "-". For example, "- [-, 10]" means being outside the range starting at the lowest possible value and ending at 10, in other words, being greater than 10. The range "+ [-, -]" is always true and hence the range "- [-, -]" is always false. We set up things so that the missing bounds are handled in a consistent manner so neither a missing bound nor "true" and "false" need to be handled using a special case.
Return the result of applying CODE to ARG0 and ARG1, but handle the case of ARG0 and/or ARG1 being omitted, meaning an unlimited range. UPPER0_P and UPPER1_P are nonzero if the respective argument is an upper bound and zero for a lower. TYPE, if nonzero, is the type of the result; it must be specified for a comparison. ARG1 will be converted to ARG0's type if both are specified.
References constant_boolean_node(), fold_build2, fold_convert, gcc_unreachable, STRIP_NOPS, tcc_comparison, TREE_CODE, TREE_CODE_CLASS, and TREE_TYPE.
Referenced by make_range(), make_range_step(), merge_ranges(), range_check_type(), range_predecessor(), and range_successor().
Helper routine for build_range_check and match.pd. Return the type to perform the check or NULL if it shouldn't be optimized.
References build_int_cst(), fold_convert, integer_type_node, integer_zerop(), NULL_TREE, POINTER_TYPE_P, range_binop(), TREE_CODE, TREE_TYPE, lang_hooks_for_types::type_for_size, TYPE_MAX_VALUE, TYPE_MIN_VALUE, TYPE_PRECISION, TYPE_UNSIGNED, lang_hooks::types, and unsigned_type_for().
Referenced by tree_switch_conversion::switch_conversion::build_one_array(), build_range_check(), convert_single_case_switch(), tree_switch_conversion::bit_test_cluster::emit(), generate_range_test(), and tree_switch_conversion::switch_decision_tree::try_switch_expansion().
Return the predecessor of VAL in its type, handling the infinite case.
References build_int_cst(), INTEGRAL_TYPE_P, NULL_TREE, operand_equal_p(), range_binop(), TREE_TYPE, and TYPE_MIN_VALUE.
Referenced by merge_ranges().
Return the successor of VAL in its type, handling the infinite case.
References build_int_cst(), INTEGRAL_TYPE_P, NULL_TREE, operand_equal_p(), range_binop(), TREE_TYPE, and TYPE_MAX_VALUE.
Referenced by merge_ranges().
Likewise, but round down.
References build_int_cst(), gcc_assert, multiple_of_p(), NULL_TREE, pow2_or_zerop(), size_binop_loc(), TREE_CODE, and TREE_TYPE.
Return the value of VALUE, rounded up to a multiple of DIVISOR.
References build_int_cst(), force_fit_type(), multiple_of_p(), NULL_TREE, pow2_or_zerop(), size_binop_loc(), wi::to_wide(), TREE_CODE, TREE_OVERFLOW, and TREE_TYPE.
void shift_bytes_in_array_left | ( | unsigned char * | ptr, |
unsigned int | sz, | ||
unsigned int | amnt ) |
Routines for manipulation of native_encode_expr encoded data if the encoded or extracted constant positions and/or sizes aren't byte aligned.
Shift left the bytes in PTR of SZ elements by AMNT bits, carrying over the bits between adjacent elements. AMNT should be within [0, BITS_PER_UNIT). Example, AMNT = 2: 00011111|11100000 << 2 = 01111111|10000000 PTR[1] | PTR[0] PTR[1] | PTR[0].
References i.
Referenced by vn_walk_cb_data::push_partial_def(), and vn_reference_lookup_3().
void shift_bytes_in_array_right | ( | unsigned char * | ptr, |
unsigned int | sz, | ||
unsigned int | amnt ) |
Like shift_bytes_in_array_left but for big-endian. Shift right the bytes in PTR of SZ elements by AMNT bits, carrying over the bits between adjacent elements. AMNT should be within [0, BITS_PER_UNIT). Example, AMNT = 2: 00011111|11100000 >> 2 = 00000111|11111000 PTR[0] | PTR[1] PTR[0] | PTR[1].
References i.
Referenced by vn_walk_cb_data::push_partial_def(), and vn_reference_lookup_3().
tree sign_bit_p | ( | tree | exp, |
const_tree | val ) |
Subroutine for fold: determine if VAL is the INTEGER_CONST that represents the sign bit of EXP's type. If EXP represents a sign or zero extension, also test VAL against the unextended type. The return value is the (sub)expression whose sign bit is VAL, or NULL_TREE otherwise.
References exp(), INTEGRAL_TYPE_P, NULL_TREE, wi::only_sign_bit_p(), sign_bit_p(), wi::to_wide(), TREE_CODE, TREE_OPERAND, TREE_OVERFLOW, TREE_TYPE, and TYPE_PRECISION.
Referenced by fold_ternary_loc(), and sign_bit_p().
Determine if an operand is simple enough to be evaluated unconditionally. In addition to simple_operand_p, we assume that comparisons, conversions, and logic-not operations are simple, if their operands are simple, too.
References CONVERT_EXPR_P, exp(), generic_expr_could_trap_p(), simple_condition_p(), simple_operand_p(), tcc_comparison, TREE_CODE, TREE_CODE_CLASS, TREE_OPERAND, and TREE_SIDE_EFFECTS.
Referenced by fold_truth_andor(), gimplify_call_expr(), and simple_condition_p().
|
static |
Subroutine for fold_truth_andor_1 and simple_condition_p: determine if an operand is simple enough to be evaluated unconditionally.
References CONSTANT_CLASS_P, DECL_EXTERNAL, DECL_NONLOCAL, DECL_P, DECL_REGISTER, DECL_WEAK, exp(), STRIP_NOPS, TREE_ADDRESSABLE, TREE_CODE, TREE_PUBLIC, TREE_STATIC, TREE_THIS_VOLATILE, and VAR_OR_FUNCTION_DECL_P.
Referenced by fold_range_test(), fold_truth_andor_1(), and simple_condition_p().
OP is the INDEXth operand to CODE (counting from zero) and OTHER_OP is the other operand. Try to use the value of OP to simplify the operation in one step, without having to process individual elements.
References integer_zerop(), NULL_TREE, and TREE_CODE.
Referenced by const_binop().
Combine operands OP1 and OP2 with arithmetic operation CODE. CODE is a tree code. The type of the result is taken from the operands. Both must be equivalent integer types, ala int_binop_types_match_p. If the operands are constant, so is the result.
References error_mark_node, fold_build2_loc(), gcc_assert, int_binop_types_match_p(), int_const_binop(), integer_onep(), integer_zerop(), NULL_TREE, poly_int_tree_p(), TREE_OVERFLOW, tree_strip_any_location_wrapper(), and TREE_TYPE.
Referenced by array_ref_element_size(), component_ref_field_offset(), compute_access_range(), expand_builtin_stpcpy_1(), expand_builtin_strncmp(), expand_builtin_strncpy(), gimple_fold_builtin_strcat(), gimple_fold_builtin_strcpy(), gimple_fold_builtin_strncpy(), gimplify_compound_lval(), gimplify_omp_depend(), layout_decl(), round_down_loc(), round_up_loc(), size_diffop_loc(), and store_expr().
Given two values, either both of sizetype or both of bitsizetype, compute the difference between the two values. Return the value in signed type corresponding to the type of the operands.
References bitsizetype, build_int_cst(), fold_convert_loc(), gcc_assert, int_binop_types_match_p(), sbitsizetype, signed_type_for(), size_binop_loc(), sizetype, ssizetype, TREE_CODE, tree_int_cst_equal(), tree_int_cst_lt(), TREE_TYPE, and TYPE_UNSIGNED.
Referenced by expand_expr_real_1(), and fold_read_from_constant_string().
tree size_int_kind | ( | poly_int64 | number, |
enum size_type_kind | kind ) |
Create a sizetype INT_CST node with NUMBER sign extended. KIND indicates which particular sizetype to create.
References build_int_cst(), and sizetype_tab.
|
static |
Returns the pointer to the base of the object addressed by EXP and extracts the information about the offset of the access, storing it to PBITPOS and POFFSET.
References build_fold_addr_expr_loc(), dyn_cast(), exp(), EXPR_LOCATION, get_inner_reference(), gimple_assign_rhs1(), gimple_assign_rhs_code(), NULL_TREE, poly_int_tree_p(), wi::sext(), SSA_NAME_DEF_STMT, STRIP_NOPS, wi::to_poly_offset(), poly_int< N, C >::to_shwi(), TREE_CODE, TREE_OPERAND, TREE_TYPE, and TYPE_PRECISION.
Referenced by ptr_difference_const().
|
static |
Split a tree IN into a constant, literal and variable parts that could be combined with CODE to make IN. "constant" means an expression with TREE_CONSTANT but that isn't an actual constant. CODE must be a commutative arithmetic operation. Store the constant part into *CONP, the literal in *LITP and return the variable part. If a part isn't present, set it to null. If the tree does not decompose in this way, return the entire tree as the variable part and the other parts as null. If CODE is PLUS_EXPR we also split trees that use MINUS_EXPR. In that case, we negate an operand that was subtracted. Except if it is a literal for which we use *MINUS_LITP instead. If NEGATE_P is true, we are negating all of IN, again except a literal for which we use *MINUS_LITP instead. If a variable part is of pointer type, it is negated after converting to TYPE. This prevents us from generating illegal MINUS pointer expression. LOC is the location of the converted variable part. If IN is itself a literal or constant, return it as appropriate. Note that we do not guarantee that any of the three values will be the same type as IN, but they will have the same signedness and mode.
References build_minus_one_cst(), drop_tree_overflow(), FLOAT_TYPE_P, SAT_FIXED_POINT_TYPE_P, STRIP_SIGN_NOPS, TREE_CODE, TREE_CONSTANT, TREE_OPERAND, TREE_OVERFLOW_P, and TREE_TYPE.
Referenced by fold_binary_loc().
Similar, but return the comparison that results if the operands are swapped. This is safe for floating-point.
References gcc_unreachable.
Referenced by analyze_agg_content_value(), and_comparisons_1(), bit_value_binop(), cond_stmts_equal_p(), fold_binary_loc(), fold_div_compare(), fold_relational_const(), fold_stmt_1(), fold_truth_andor_1(), get_cmp_code(), gimple_resimplify2(), gimple_simplify(), operand_compare::hash_operand(), insert_predicates_for_cond(), maybe_canonicalize_comparison(), number_of_iterations_cond(), operand_compare::operand_equal_p(), optimize_range_tests_var_bound(), or_comparisons_1(), overflow_comparison_p(), process_bb(), refine_bounds_using_guard(), refine_value_range_using_guard(), jump_threader::simplify_control_stmt_condition_1(), split_at_bb_p(), vect_build_slp_tree_1(), and vn_nary_op_compute_hash().
bool tree_binary_nonnegative_warnv_p | ( | enum tree_code | code, |
tree | type, | ||
tree | op0, | ||
tree | op1, | ||
bool * | strict_overflow_p, | ||
int | depth ) |
Return true if (CODE OP0 OP1) is known to be non-negative. If the return value is based on the assumption that signed overflow is undefined, set *STRICT_OVERFLOW_P to true; otherwise, don't change *STRICT_OVERFLOW_P. DEPTH is the current nesting depth of the query.
References ANY_INTEGRAL_TYPE_P, FLOAT_TYPE_P, MAX, operand_equal_p(), RECURSE, TREE_CODE, tree_expr_maybe_nan_p(), tree_int_cst_min_precision(), tree_int_cst_sgn(), TREE_OPERAND, tree_simple_nonnegative_warnv_p(), TREE_TYPE, TYPE_OVERFLOW_UNDEFINED, TYPE_PRECISION, TYPE_UNSIGNED, and UNSIGNED.
Referenced by gimple_assign_nonnegative_warnv_p(), and tree_expr_nonnegative_warnv_p().
bool tree_binary_nonzero_warnv_p | ( | enum tree_code | code, |
tree | type, | ||
tree | op0, | ||
tree | op1, | ||
bool * | strict_overflow_p ) |
Return true when (CODE OP0 OP1) is an address and is known to be nonzero. For floating point we further ensure that T is not denormal. Similar logic is present in nonzero_address in rtlanal.h. If the return value is based on the assumption that signed overflow is undefined, set *STRICT_OVERFLOW_P to true; otherwise, don't change *STRICT_OVERFLOW_P.
References ANY_INTEGRAL_TYPE_P, tree_expr_nonnegative_warnv_p, tree_expr_nonzero_warnv_p(), and TYPE_OVERFLOW_UNDEFINED.
Referenced by tree_expr_nonzero_warnv_p().
bool tree_call_nonnegative_warnv_p | ( | tree | type, |
combined_fn | fn, | ||
tree | arg0, | ||
tree | arg1, | ||
bool * | strict_overflow_p, | ||
int | depth ) |
Return true if T is known to be non-negative. If the return value is based on the assumption that signed overflow is undefined, set *STRICT_OVERFLOW_P to true; otherwise, don't change *STRICT_OVERFLOW_P. DEPTH is the current nesting depth of the query.
References HONOR_SIGNED_ZEROS(), real_from_integer(), real_identical(), real_to_integer(), REAL_VALUE_TYPE, RECURSE, SIGNED, TREE_CODE, tree_expr_maybe_nan_p(), tree_expr_maybe_signaling_nan_p(), TREE_INT_CST_LOW, TREE_REAL_CST, and tree_simple_nonnegative_warnv_p().
Referenced by gimple_call_nonnegative_warnv_p(), and tree_invalid_nonnegative_warnv_p().
bool tree_expr_finite_p | ( | const_tree | x | ) |
Return true if expression X cannot be (or contain) a NaN or infinity. This function returns true for integer expressions, and returns false if uncertain.
References CALL_EXPR_ARG, element_mode(), get_call_combined_fn(), HONOR_INFINITIES(), HONOR_NANS(), real_isfinite(), TREE_CODE, tree_expr_finite_p(), TREE_IMAGPART, TREE_OPERAND, TREE_REAL_CST_PTR, and TREE_REALPART.
Referenced by fold_builtin_classify(), tree_expr_finite_p(), and tree_expr_maybe_nan_p().
bool tree_expr_infinite_p | ( | const_tree | x | ) |
Return true if expression X evaluates to an infinity. This function returns false for integer expressions.
References HONOR_INFINITIES(), real_isinf(), TREE_CODE, tree_expr_infinite_p(), TREE_OPERAND, and TREE_REAL_CST_PTR.
Referenced by fold_builtin_classify(), and tree_expr_infinite_p().
bool tree_expr_maybe_infinite_p | ( | const_tree | x | ) |
Return true if expression X could evaluate to an infinity. This function returns false for integer expressions, and returns true if uncertain.
References HONOR_INFINITIES(), real_isinf(), TREE_CODE, tree_expr_maybe_infinite_p(), TREE_OPERAND, and TREE_REAL_CST_PTR.
Referenced by fold_builtin_classify(), fold_builtin_fpclassify(), and tree_expr_maybe_infinite_p().
bool tree_expr_maybe_nan_p | ( | const_tree | x | ) |
Return true if expression X could evaluate to a NaN. This function returns false for integer expressions, and returns true if uncertain.
References CALL_EXPR_ARG, get_call_combined_fn(), HONOR_NANS(), real_isnan(), TREE_CODE, tree_expr_finite_p(), tree_expr_maybe_nan_p(), TREE_OPERAND, and TREE_REAL_CST_PTR.
Referenced by fold_builtin_classify(), fold_builtin_fpclassify(), fold_builtin_unordered_cmp(), tree_binary_nonnegative_warnv_p(), tree_call_nonnegative_warnv_p(), and tree_expr_maybe_nan_p().
bool tree_expr_maybe_real_minus_zero_p | ( | const_tree | x | ) |
Return true if expression X could evaluate to -0.0. This function returns true if uncertain.
References get_call_combined_fn(), HONOR_SIGNED_ZEROS(), REAL_VALUE_MINUS_ZERO, TREE_CODE, tree_expr_maybe_real_minus_zero_p(), TREE_OPERAND, and TREE_REAL_CST.
Referenced by fold_real_zero_addition_p(), and tree_expr_maybe_real_minus_zero_p().
bool tree_expr_maybe_signaling_nan_p | ( | const_tree | x | ) |
Return true if expression X could evaluate to a signaling NaN. This function returns false for integer expressions, and returns true if uncertain.
References CALL_EXPR_ARG, get_call_combined_fn(), HONOR_SNANS(), real_issignaling_nan(), TREE_CODE, tree_expr_maybe_signaling_nan_p(), TREE_OPERAND, and TREE_REAL_CST_PTR.
Referenced by fold_real_zero_addition_p(), tree_call_nonnegative_warnv_p(), and tree_expr_maybe_signaling_nan_p().
bool tree_expr_nan_p | ( | const_tree | x | ) |
Return true if expression X evaluates to a NaN. This function returns false for integer expressions.
References HONOR_NANS(), real_isnan(), TREE_CODE, tree_expr_nan_p(), TREE_OPERAND, and TREE_REAL_CST_PTR.
Referenced by fold_builtin_classify(), fold_builtin_unordered_cmp(), and tree_expr_nan_p().
Return true if `t' is known to be non-negative. Handle warnings about undefined signed overflow.
References fold_overflow_warning(), tree_expr_nonnegative_warnv_p, and WARN_STRICT_OVERFLOW_MISC.
Referenced by derive_constant_upper_bound_ops(), and gimple_expand_builtin_pow().
Return true if T is known to be non-negative. If the return value is based on the assumption that signed overflow is undefined, set *STRICT_OVERFLOW_P to true; otherwise, don't change *STRICT_OVERFLOW_P. DEPTH is the current nesting depth of the query.
References error_mark_node, tcc_binary, tcc_comparison, tcc_constant, tcc_declaration, tcc_reference, tcc_unary, tree_binary_nonnegative_warnv_p(), TREE_CODE, TREE_CODE_CLASS, tree_invalid_nonnegative_warnv_p(), TREE_OPERAND, tree_single_nonnegative_warnv_p(), TREE_TYPE, and tree_unary_nonnegative_warnv_p().
Return true when T is an address and is known to be nonzero. Handle warnings about undefined signed overflow.
References fold_overflow_warning(), tree_expr_nonzero_warnv_p(), and WARN_STRICT_OVERFLOW_MISC.
Referenced by strlen_pass::count_nonzero_bytes(), infer_nonnull_range_by_attribute(), match_single_bit_test(), and simplify_count_trailing_zeroes().
Return true when T is an address and is known to be nonzero. For floating point we further ensure that T is not denormal. Similar logic is present in nonzero_address in rtlanal.h. If the return value is based on the assumption that signed overflow is undefined, set *STRICT_OVERFLOW_P to true; otherwise, don't change *STRICT_OVERFLOW_P.
References alloca_call_p(), DECL_IS_OPERATOR_NEW_P, get_callee_fndecl(), INTEGRAL_TYPE_P, lookup_attribute(), POINTER_TYPE_P, tcc_binary, tcc_comparison, tcc_constant, tcc_declaration, tcc_reference, tcc_unary, tree_binary_nonzero_warnv_p(), TREE_CODE, TREE_CODE_CLASS, tree_expr_nonzero_warnv_p(), TREE_NOTHROW, TREE_OPERAND, tree_single_nonzero_warnv_p(), TREE_TYPE, tree_unary_nonzero_warnv_p(), and TYPE_ATTRIBUTES.
Referenced by tree_binary_nonzero_warnv_p(), tree_expr_nonzero_p(), tree_expr_nonzero_warnv_p(), tree_single_nonzero_warnv_p(), and tree_unary_nonzero_warnv_p().
bool tree_expr_signaling_nan_p | ( | const_tree | x | ) |
Return true if expression X evaluates to a signaling NaN. This function returns false for integer expressions.
References HONOR_SNANS(), real_issignaling_nan(), TREE_CODE, tree_expr_signaling_nan_p(), TREE_OPERAND, and TREE_REAL_CST_PTR.
Referenced by tree_expr_signaling_nan_p().
Return true if T is known to be non-negative. If the return value is based on the assumption that signed overflow is undefined, set *STRICT_OVERFLOW_P to true; otherwise, don't change *STRICT_OVERFLOW_P. DEPTH is the current nesting depth of the query.
References BIND_EXPR_BODY, CALL_EXPR_ARG, call_expr_nargs, expr_last(), get_call_combined_fn(), NULL_TREE, RECURSE, TARGET_EXPR_INITIAL, TARGET_EXPR_SLOT, tree_call_nonnegative_warnv_p(), TREE_CODE, TREE_OPERAND, tree_simple_nonnegative_warnv_p(), TREE_TYPE, TYPE_UNSIGNED, and VOID_TYPE_P.
Referenced by tree_expr_nonnegative_warnv_p().
wide_int tree_nonzero_bits | ( | const_tree | t | ) |
Given a tree T, compute which bits in T may be nonzero.
References wi::bit_and(), wi::bit_or(), CASE_CONVERT, wide_int_storage::from(), get_nonzero_bits(), INTEGRAL_TYPE_P, wi::lshift(), wi::neg_p(), wi::rshift(), wi::shwi(), wi::to_wide(), TREE_CODE, tree_nonzero_bits(), TREE_OPERAND, TREE_TYPE, TYPE_PRECISION, and TYPE_SIGN.
Referenced by do_store_flag(), is_widening_mult_rhs_p(), and tree_nonzero_bits().
Return true if CODE or TYPE is known to be non-negative.
References truth_value_p(), TYPE_PRECISION, TYPE_UNSIGNED, and VECTOR_TYPE_P.
Referenced by tree_binary_nonnegative_warnv_p(), tree_call_nonnegative_warnv_p(), tree_invalid_nonnegative_warnv_p(), tree_single_nonnegative_warnv_p(), and tree_unary_nonnegative_warnv_p().
Return true if T is known to be non-negative. If the return value is based on the assumption that signed overflow is undefined, set *STRICT_OVERFLOW_P to true; otherwise, don't change *STRICT_OVERFLOW_P. DEPTH is the current nesting depth of the query.
References FIXED_VALUE_NEGATIVE, gimple_stmt_nonnegative_warnv_p(), name_registered_for_update_p(), REAL_VALUE_NEGATIVE, RECURSE, SSA_NAME_DEF_STMT, TREE_CODE, TREE_FIXED_CST, tree_int_cst_sgn(), TREE_OPERAND, TREE_REAL_CST, tree_simple_nonnegative_warnv_p(), TREE_TYPE, and TYPE_UNSIGNED.
Referenced by gimple_assign_nonnegative_warnv_p(), gimple_phi_nonnegative_warnv_p(), and tree_expr_nonnegative_warnv_p().
Return true when T is an address and is known to be nonzero. For floating point we further ensure that T is not denormal. Similar logic is present in nonzero_address in rtlanal.h. If the return value is based on the assumption that signed overflow is undefined, set *STRICT_OVERFLOW_P to true; otherwise, don't change *STRICT_OVERFLOW_P.
References CONSTANT_CLASS_P, DECL_P, expr_not_equal_to(), get_base_address(), integer_zerop(), INTEGRAL_TYPE_P, maybe_nonzero_address(), TARGET_EXPR_SLOT, TREE_CODE, tree_expr_nonzero_warnv_p(), TREE_OPERAND, TREE_TYPE, TYPE_PRECISION, and wi::zero().
Referenced by absorbing_element_p(), range_query::get_tree_range(), ipa_compute_jump_functions_for_edge(), fold_using_range::range_of_address(), and tree_expr_nonzero_warnv_p().
bool tree_swap_operands_p | ( | const_tree | arg0, |
const_tree | arg1 ) |
Test whether it is preferable to swap two operands, ARG0 and ARG1, for example because ARG0 is an integer constant and ARG1 isn't.
References CONSTANT_CLASS_P, DECL_P, SSA_NAME_VERSION, STRIP_NOPS, TREE_CODE, and TREE_CONSTANT.
Referenced by fold_binary_loc(), fold_stmt_1(), fold_ternary_loc(), gimple_resimplify2(), gimple_resimplify3(), gimple_resimplify4(), gimple_resimplify5(), gimple_resimplify6(), gimple_resimplify7(), gimple_simplify(), gimple_simplify(), insert_predicates_for_cond(), optimize_range_tests_var_bound(), process_bb(), record_equality(), avail_exprs_stack::simplify_binary_operation(), jump_threader::simplify_control_stmt_condition_1(), visit_phi(), and vn_nary_op_compute_hash().
bool tree_unary_nonnegative_warnv_p | ( | enum tree_code | code, |
tree | type, | ||
tree | op0, | ||
bool * | strict_overflow_p, | ||
int | depth ) |
Return true if (CODE OP0) is known to be non-negative. If the return value is based on the assumption that signed overflow is undefined, set *STRICT_OVERFLOW_P to true; otherwise, don't change *STRICT_OVERFLOW_P. DEPTH is the current nesting depth of the query.
References ANY_INTEGRAL_TYPE_P, CASE_CONVERT, INTEGRAL_TYPE_P, RECURSE, SCALAR_FLOAT_TYPE_P, tree_simple_nonnegative_warnv_p(), TREE_TYPE, type(), TYPE_OVERFLOW_UNDEFINED, TYPE_PRECISION, and TYPE_UNSIGNED.
Referenced by gimple_assign_nonnegative_warnv_p(), and tree_expr_nonnegative_warnv_p().
bool tree_unary_nonzero_warnv_p | ( | enum tree_code | code, |
tree | type, | ||
tree | op0, | ||
bool * | strict_overflow_p ) |
Return true when (CODE OP0) is an address and is known to be nonzero. For floating point we further ensure that T is not denormal. Similar logic is present in nonzero_address in rtlanal.h. If the return value is based on the assumption that signed overflow is undefined, set *STRICT_OVERFLOW_P to true; otherwise, don't change *STRICT_OVERFLOW_P.
References tree_expr_nonzero_warnv_p(), TREE_TYPE, type(), and TYPE_PRECISION.
Referenced by tree_expr_nonzero_warnv_p().
See if ARG is an expression that is either a comparison or is performing arithmetic on comparisons. The comparisons must only be comparing two different values, which will be stored in *CVAL1 and *CVAL2; if they are nonzero it means that some operands have already been found. No variables may be used anywhere else in the expression except in the comparisons. If this is true, return 1. Otherwise, return zero.
References operand_equal_p(), tcc_binary, tcc_comparison, tcc_constant, tcc_expression, tcc_unary, TREE_CODE, TREE_CODE_CLASS, TREE_OPERAND, and twoval_comparison_p().
Referenced by fold_comparison(), and twoval_comparison_p().
Subroutine for fold_truth_andor_1: C is an INTEGER_CST interpreted as a P bit value. Arrange things so the extra bits will be set to zero if and only if C is signed-extended to its full width. If MASK is nonzero, it is an INTEGER_CST that should be AND'ed with the extra bits.
References build_int_cst(), const_binop(), wi::extract_uhwi(), fold_convert, GET_MODE_BITSIZE(), SCALAR_INT_TYPE_MODE, signed_type_for(), size_int, wi::to_wide(), TREE_TYPE, and TYPE_UNSIGNED.
Referenced by fold_truth_andor_1().
|
static |
Helper routine for fold_vec_perm_cst to check if SEL is a suitable mask for VLA vec_perm folding. REASON if specified, will contain the reason why SEL is not suitable. Used only for debugging and unit-testing.
References const_binop(), vec_perm_indices::encoding(), poly_int< N, C >::is_constant(), vec_perm_indices::length(), vector_builder< T, Shape, Derived >::nelts_per_pattern(), vector_builder< T, Shape, Derived >::npatterns(), operand_equal_p(), pow2p_hwi(), TREE_TYPE, TYPE_VECTOR_SUBPARTS(), vector_cst_elt(), and VECTOR_CST_NPATTERNS.
Referenced by fold_vec_perm_cst().
Helper function for fold_vec_perm. Store elements of VECTOR_CST or CONSTRUCTOR ARG into array ELTS, which has NELTS elements, and return true if successful.
References CONSTRUCTOR_ELTS, fold_convert, FOR_EACH_VEC_SAFE_ELT, i, integer_zero_node, TREE_CODE, TREE_TYPE, constructor_elt::value, VECTOR_CST_ELT, and VECTOR_CST_NELTS.
Referenced by fold_vec_perm().
tree vector_const_binop | ( | tree_code | code, |
tree | arg1, | ||
tree | arg2, | ||
tree(* | elt_const_binop )(enum tree_code, tree, tree) ) |
If ARG1 and ARG2 are constants, and if performing CODE on them would be an elementwise vector operation, try to fold the operation to a constant vector, using ELT_CONST_BINOP to fold each element. Return the folded value on success, otherwise return null.
References tree_vector_builder::build(), count, distributes_over_addition_p(), vector_builder< T, Shape, Derived >::encoded_nelts(), i, known_eq, vector_builder< T, Shape, Derived >::new_binary_operation(), vector_builder< T, Shape, Derived >::new_unary_operation(), NULL_TREE, TREE_CODE, TREE_TYPE, TYPE_VECTOR_SUBPARTS(), VECTOR_CST_ELT, and VECTOR_CST_STEPPED_P.
Referenced by const_binop().
bool wide_int_binop | ( | wide_int & | res, |
enum tree_code | code, | ||
const wide_int & | arg1, | ||
const wide_int & | arg2, | ||
signop | sign, | ||
wi::overflow_type * | overflow ) |
Combine two wide ints ARG1 and ARG2 under operation CODE to produce a new constant in RES. Return FALSE if we don't know how to evaluate CODE at compile-time.
References wi::add(), wi::bit_and(), wi::bit_or(), wi::bit_xor(), wi::div_ceil(), wi::div_floor(), wi::div_round(), wi::div_trunc(), wi::lrotate(), wi::lshift(), wi::max(), wi::min(), wi::mod_ceil(), wi::mod_floor(), wi::mod_round(), wi::mod_trunc(), wi::mul(), wi::mul_high(), wi::neg_p(), wi::OVF_NONE, wi::rrotate(), wi::rshift(), and wi::sub().
Referenced by poly_int_binop().
|
static |
Referenced by inchash::add_expr(), and operand_equal_p().
|
static |
If a warning about undefined overflow is deferred, this is the level at which the warning should be emitted.
Referenced by fold_overflow_warning(), and fold_undefer_overflow_warnings().
|
static |
If a warning about undefined overflow is deferred, this is the warning. Note that this may cause us to turn two warnings into one, but that is fine since it is sufficient to only give one warning per expression.
Referenced by fold_overflow_warning(), and fold_undefer_overflow_warnings().
|
static |
This is nonzero if we should defer warnings about undefined overflow. This facility exists because these warnings are a special case. The code to estimate loop iterations does not want to issue any warnings, since it works with expressions which do not occur in user code. Various bits of cleanup code call fold(), but only use the result if it has certain characteristics (e.g., is a constant); that code only wants to issue a warning if the result is used.
Referenced by fold_defer_overflow_warnings(), fold_deferring_overflow_warnings_p(), fold_overflow_warning(), and fold_undefer_overflow_warnings().
Nonzero if we are folding C++ manifestly-constant-evaluated context; zero otherwise. Should be used when certain constructs shouldn't be optimized during folding in that context.
Referenced by address_compare().
int folding_initializer = 0 |
Nonzero if we are folding constants inside an initializer or a C++ manifestly-constant-evaluated context; zero otherwise. Should be used when folding in initializer enables additional optimizations.
Referenced by address_compare(), const_binop(), symtab_node::equal_address_to(), fold_builtin_constant_p(), and maybe_nonzero_address().