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 "ssa.h"
#include "cgraph.h"
#include "gimple-pretty-print.h"
#include "gimple-ssa-warn-access.h"
#include "gimple-ssa-warn-restrict.h"
#include "fold-const.h"
#include "stmt.h"
#include "expr.h"
#include "stor-layout.h"
#include "dumpfile.h"
#include "gimple-iterator.h"
#include "gimple-fold.h"
#include "gimplify.h"
#include "tree-into-ssa.h"
#include "tree-dfa.h"
#include "tree-object-size.h"
#include "tree-ssa.h"
#include "tree-ssa-propagate.h"
#include "ipa-utils.h"
#include "tree-ssa-address.h"
#include "langhooks.h"
#include "gimplify-me.h"
#include "dbgcnt.h"
#include "builtins.h"
#include "tree-eh.h"
#include "gimple-match.h"
#include "gomp-constants.h"
#include "optabs-query.h"
#include "omp-general.h"
#include "tree-cfg.h"
#include "fold-const-call.h"
#include "stringpool.h"
#include "attribs.h"
#include "asan.h"
#include "diagnostic-core.h"
#include "intl.h"
#include "calls.h"
#include "tree-vector-builder.h"
#include "tree-ssa-strlen.h"
#include "varasm.h"
#include "internal-fn.h"
#include "gimple-range.h"
Data Structures | |
struct | clear_padding_struct |
Enumerations | |
enum | strlen_range_kind { SRK_STRLEN , SRK_STRLENMAX , SRK_LENRANGE , SRK_INT_VALUE } |
Variables | |
static constexpr size_t | clear_padding_unit = MAX_BITSIZE_MODE_ANY_MODE / BITS_PER_UNIT |
static const size_t | clear_padding_buf_size = 32 * clear_padding_unit |
static basic_block | fosa_bb |
static vec< std::pair< tree, flow_sensitive_info_storage > > * | fosa_unwind |
enum strlen_range_kind |
Statement simplification on GIMPLE. Copyright (C) 2010-2024 Free Software Foundation, Inc. Split out from tree-ssa-ccp.cc. 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/>.
Enumerator | |
---|---|
SRK_STRLEN | |
SRK_STRLENMAX | |
SRK_LENRANGE | |
SRK_INT_VALUE |
|
static |
Forward declarations for some mutually recursive functions.
Try to simplify the AND of two comparisons defined by (OP1A CODE1 OP1B) and (OP2A CODE2 OP2B), respectively. If this can be done without constructing an intermediate value, return the resulting tree; otherwise NULL_TREE is returned. This function is deliberately asymmetric as it recurses on SSA_DEFs in the first comparison but not the second.
References and_var_with_comparison(), boolean_false_node, boolean_type_node, CDI_DOMINATORS, combine_comparisons(), dom_info_available_p(), dominated_by_p(), fold_build2, gimple_bb(), gimple_phi_arg_def(), gimple_phi_num_args(), gimple_phi_result(), i, integer_nonzerop(), integer_onep(), integer_zerop(), NULL_TREE, operand_equal_p(), same_bool_comparison_p(), same_bool_result_p(), SSA_NAME_DEF_STMT, SSA_NAME_IS_DEFAULT_DEF, swap_tree_comparison(), TREE_CODE, TREE_TYPE, truth_type_for(), and UNKNOWN_LOCATION.
Referenced by and_var_with_comparison_1(), and maybe_fold_and_comparisons().
|
static |
Helper function for and_comparisons_1: try to simplify the AND of the ssa variable VAR with the comparison specified by (OP2A CODE2 OP2B). If INVERT is true, invert the value of the VAR before doing the AND. Return NULL_EXPR if we can't simplify this to a single expression.
References and_var_with_comparison_1(), canonicalize_bool(), invert_tree_comparison(), is_gimple_assign(), NULL_TREE, or_var_with_comparison_1(), and SSA_NAME_DEF_STMT.
Referenced by and_comparisons_1(), and and_var_with_comparison_1().
|
static |
Try to simplify the AND of the ssa variable defined by the assignment STMT with the comparison specified by (OP2A CODE2 OP2B). Return NULL_EXPR if we can't simplify this to a single expression.
References and_comparisons_1(), and_var_with_comparison(), boolean_false_node, boolean_true_node, gimple_assign_lhs(), gimple_assign_rhs1(), gimple_assign_rhs2(), gimple_assign_rhs_code(), integer_nonzerop(), integer_onep(), integer_zerop(), is_gimple_assign(), maybe_fold_and_comparisons(), NULL_TREE, same_bool_result_p(), SSA_NAME_DEF_STMT, tcc_comparison, TREE_CODE, TREE_CODE_CLASS, and TREE_TYPE.
Referenced by and_var_with_comparison(), and or_var_with_comparison().
Return true if CODE is an operation that when operating on signed integer types involves undefined behavior on overflow and the operation can be expressed with unsigned arithmetic.
Referenced by final_value_replacement_loop(), if_convertible_gimple_assign_stmt_p(), move_computations_worker(), predicate_statements(), split_loop(), and update_range_test().
bool arith_overflowed_p | ( | enum tree_code | code, |
const_tree | type, | ||
const_tree | arg0, | ||
const_tree | arg1 ) |
Return true if ARG0 CODE ARG1 in infinite signed precision operation doesn't fit into TYPE. The test for overflow should be regardless of -fwrapv, and even for unsigned types.
References wi::add(), gcc_unreachable, wi::min_precision(), wi::mul(), wi::neg_p(), wi::sub(), TYPE_PRECISION, TYPE_SIGN, and UNSIGNED.
Referenced by check_for_binary_op_overflow(), fold_builtin_arith_overflow(), fold_const_call(), fold_const_call(), and gimple_fold_call().
Return true when DECL can be referenced from current unit. FROM_DECL (if non-null) specify constructor of variable DECL was taken from. We can get declarations that are not possible to reference for various reasons: 1) When analyzing C++ virtual tables. C++ virtual tables do have known constructors even when they are keyed to other compilation unit. Those tables can contain pointers to methods and vars in other units. Those methods have both STATIC and EXTERNAL set. 2) In WHOPR mode devirtualization might lead to reference to method that was partitioned elsehwere. In this case we have static VAR_DECL or FUNCTION_DECL that has no corresponding callgraph/varpool node declaring the body. 3) COMDAT functions referred by external vtables that we devirtualize only during final compilation stage. At this time we already decided that we will not output the function body and thus we can't reference the symbol directly.
References DECL_ABSTRACT_P, DECL_COMDAT, DECL_EXTERNAL, DECL_VISIBILITY, DECL_VISIBILITY_SPECIFIED, symtab_node::definition, dyn_cast(), symtab_node::force_output, symtab_node::forced_by_abi, symbol_table::function_flags_ready, symtab_node::get(), varpool_node::get(), symtab_node::in_other_partition, cgraph_node::inlined_to, NULL, symtab, TREE_PUBLIC, TREE_STATIC, VAR_OR_FUNCTION_DECL_P, VAR_P, and VISIBILITY_DEFAULT.
Referenced by canonicalize_constructor_val(), and gimple_get_virt_method_for_vtable().
Canonicalize and possibly invert the boolean EXPR; return NULL_TREE if EXPR is null or we don't know how. If non-null, the result always has boolean type.
References boolean_false_node, boolean_true_node, boolean_type_node, build_int_cst(), COMPARISON_CLASS_P, expr, fold_build2, integer_nonzerop(), integer_zerop(), invert_tree_comparison(), NULL_TREE, TREE_CODE, TREE_OPERAND, and TREE_TYPE.
Referenced by and_var_with_comparison(), and or_var_with_comparison().
CVAL is value taken from DECL_INITIAL of variable. Try to transform it into acceptable form for is_gimple_min_invariant. FROM_DECL (if non-NULL) specify variable whose constructor contains CVAL.
References build1_loc(), build_fold_addr_expr, can_refer_decl_in_current_unit_p(), COMPOUND_LITERAL_EXPR_DECL, CONSTANT_CLASS_P, drop_tree_overflow(), error_mark_node, EXPR_LOCATION, fold_build2, fold_convert, get_base_address(), cgraph_node::get_create(), is_gimple_min_invariant(), NULL_TREE, ptr_type_node, STRIP_NOPS, TREE_CODE, TREE_OPERAND, TREE_OVERFLOW_P, TREE_TYPE, useless_type_conversion_p(), VAR_OR_FUNCTION_DECL_P, and VAR_P.
Referenced by fold_ctor_reference(), get_symbol_constant_value(), ipa_make_edge_direct_to_target(), and record_reference().
|
static |
Append PADDING_BYTES padding bytes.
References clear_padding_struct::buf, clear_padding_buf_size, clear_padding_flush(), gcc_assert, clear_padding_struct::off, clear_padding_struct::padding_bytes, and clear_padding_struct::size.
Referenced by clear_padding_type(), and clear_padding_union().
_BitInt has padding bits if it isn't extended in the ABI and has smaller precision than bits in limb or corresponding number of limbs.
References bitint_info::abi_limb_mode, as_a(), bitint_info::extended, gcc_assert, GET_MODE_PRECISION(), bitint_info::limb_mode, targetm, and TYPE_PRECISION.
Referenced by clear_padding_type_may_have_padding_p(), and type_has_padding_at_level_p().
|
static |
Emit a runtime loop: for (; buf.base != end; buf.base += sz) __builtin_clear_padding (buf.base);
References clear_padding_struct::base, clear_padding_flush(), clear_padding_type(), create_artificial_label(), end(), g, gimple_build_assign(), gimple_build_cond(), gimple_build_goto(), gimple_build_label(), gimple_set_location(), clear_padding_struct::gsi, gsi_insert_before(), GSI_SAME_STMT, clear_padding_struct::loc, size_int, and clear_padding_struct::sz.
Referenced by clear_padding_type(), and gimple_fold_builtin_clear_padding().
|
static |
Emit code to clear padding requested in BUF->buf - set bits in there stand for padding that should be cleared. FULL is true if everything from the buffer should be flushed, otherwise it can leave up to 2 * clear_padding_unit bytes for further processing.
References clear_padding_struct::alias_type, clear_padding_struct::align, clear_padding_struct::base, clear_padding_struct::buf, build2_loc(), build_aligned_type(), build_array_type_nelts(), build_constructor(), build_int_cst(), build_zero_cst(), char_type_node, clear_padding_struct::clear_in_mask, clear_padding_unit, end(), fold_build1, g, gcc_assert, gimple_build_assign(), gimple_set_location(), clear_padding_struct::gsi, gsi_insert_before(), GSI_SAME_STMT, i, clear_padding_struct::loc, make_ssa_name(), native_interpret_expr(), NULL, clear_padding_struct::off, clear_padding_struct::padding_bytes, SET_EXPR_LOCATION, clear_padding_struct::size, suppress_warning(), clear_padding_struct::sz, TREE_CODE, type(), TYPE_ALIGN, lang_hooks_for_types::type_for_size, lang_hooks::types, clear_padding_struct::union_ptr, UNKNOWN_LOCATION, and unshare_expr().
Referenced by clear_padding_add_padding(), clear_padding_emit_loop(), clear_padding_type(), clear_padding_union(), clear_type_padding_in_mask(), and gimple_fold_builtin_clear_padding().
The only known floating point formats with padding bits are the IEEE extended ones.
References real_format::b, REAL_MODE_FORMAT, real_format::signbit_ro, real_format::signbit_rw, and TYPE_MODE.
Referenced by clear_padding_type(), clear_padding_type_may_have_padding_p(), and type_has_padding_at_level_p().
|
static |
Clear padding bits for TYPE. Called recursively from gimple_fold_builtin_clear_padding. If FOR_AUTO_INIT is true, the __builtin_clear_padding is not called by the end user, instead, it's inserted by the compiler to initialize the paddings of automatic variable. Therefore, we should not emit the error messages for flexible array members to confuse the end user.
References bitint_info::abi_limb_mode, clear_padding_struct::align, as_a(), clear_padding_struct::base, bitint_info::big_endian, clear_padding_struct::buf, build_nonstandard_integer_type(), build_pointer_type(), lang_hooks_for_types::classtype_as_base, clear_padding_struct::clear_in_mask, clear_padding_add_padding(), clear_padding_buf_size, clear_padding_emit_loop(), clear_padding_flush(), clear_padding_real_needs_padding_p(), clear_padding_type(), clear_padding_type_may_have_padding_p(), clear_padding_union(), clear_padding_unit, COMPLETE_TYPE_P, create_tmp_var, DECL_BIT_FIELD, DECL_CHAIN, DECL_FIELD_BIT_OFFSET, DECL_PADDING_P, DECL_SIZE_UNIT, end(), error_at(), error_mark_node, bitint_info::extended, g, gcc_assert, GET_MODE_PRECISION(), gimple_build_assign(), gimple_set_location(), clear_padding_struct::gsi, gsi_insert_before(), GSI_SAME_STMT, i, int_byte_position(), int_size_in_bytes(), is_empty_type(), bitint_info::limb_mode, clear_padding_struct::loc, make_ssa_name(), wi::mask(), native_encode_expr(), native_interpret_real(), NULL, NULL_TREE, clear_padding_struct::off, ROUND_UP, clear_padding_struct::size, size_int, sorry_at(), clear_padding_struct::sz, targetm, poly_int< N, C >::to_constant(), TREE_CODE, tree_to_shwi(), tree_to_uhwi(), TREE_TYPE, TYPE_ALIGN, TYPE_FIELDS, TYPE_PRECISION, TYPE_VECTOR_SUBPARTS(), lang_hooks::types, clear_padding_struct::union_ptr, and wide_int_to_tree().
Referenced by clear_padding_emit_loop(), clear_padding_type(), clear_padding_union(), clear_type_padding_in_mask(), and gimple_fold_builtin_clear_padding().
Return true if TYPE might contain any padding bits.
References clear_padding_bitint_needs_padding_p(), clear_padding_real_needs_padding_p(), clear_padding_type_may_have_padding_p(), TREE_CODE, and TREE_TYPE.
Referenced by clear_padding_type(), clear_padding_type_may_have_padding_p(), gimple_fold_builtin_clear_padding(), gimplify_decl_expr(), and gimplify_init_constructor().
|
static |
Clear padding bits of union type TYPE.
References clear_padding_struct::alias_type, clear_padding_struct::align, clear_padding_struct::base, clear_padding_struct::buf, clear_padding_struct::clear_in_mask, clear_padding_add_padding(), clear_padding_buf_size, clear_padding_flush(), clear_padding_type(), COMPLETE_TYPE_P, DECL_CHAIN, DECL_PADDING_P, DECL_SIZE_UNIT, error_at(), error_mark_node, gcc_assert, clear_padding_struct::gsi, clear_padding_struct::loc, MIN, NULL, NULL_TREE, clear_padding_struct::off, clear_padding_struct::padding_bytes, clear_padding_struct::size, clear_padding_struct::sz, TREE_CODE, tree_to_shwi(), TREE_TYPE, TYPE_FIELDS, and clear_padding_struct::union_ptr.
Referenced by clear_padding_type().
void clear_type_padding_in_mask | ( | tree | type, |
unsigned char * | mask ) |
Clear padding bits of TYPE in MASK.
References clear_padding_struct::alias_type, clear_padding_struct::align, clear_padding_struct::base, clear_padding_struct::clear_in_mask, clear_padding_flush(), clear_padding_type(), clear_padding_struct::gsi, int_size_in_bytes(), clear_padding_struct::loc, NULL, NULL_TREE, clear_padding_struct::off, clear_padding_struct::padding_bytes, clear_padding_struct::size, clear_padding_struct::sz, clear_padding_struct::union_ptr, and UNKNOWN_LOCATION.
Referenced by native_interpret_expr().
Create a temporary for TYPE for a statement STMT. If the current function is in SSA form, a SSA name is created. Otherwise a temporary register is made.
References cfun, create_tmp_reg(), gimple_in_ssa_p(), and make_ssa_name().
Referenced by copy_bb(), gimple_build(), gimple_build(), gimple_build(), gimple_build(), gimple_build(), gimple_build(), gimple_build(), gimple_fold_builtin_memory_op(), gimple_fold_builtin_strcat(), gimple_fold_builtin_strchr(), gimple_fold_builtin_string_compare(), and gimple_load_first_char().
Print a message in the dump file recording transformation of FROM to TO.
References dump_enabled_p(), dump_printf_loc(), gimple_call_fn(), and MSG_OPTIMIZED_LOCATIONS.
Referenced by replace_call_with_call_and_fold().
|
static |
Helper function for update_gimple_call and gimplify_and_update_call_from_tree. A GIMPLE_CALL STMT is being replaced with GIMPLE_CALL NEW_STMT.
References gimple_block(), gimple_call_lhs(), gimple_call_set_lhs(), gimple_location(), gimple_move_vops(), gimple_set_block(), gimple_set_location(), gsi_replace(), NULL_TREE, SSA_NAME_DEF_STMT, and TREE_CODE.
Referenced by gimplify_and_update_call_from_tree(), and update_gimple_call().
|
static |
CTOR is a CONSTRUCTOR of an array or vector type. Fold a reference of SIZE bits to the memory at bit OFFSET. If non-null, TYPE is the expected type of the reference; otherwise the type of the referenced element is used instead. When SIZE is zero, attempt to fold a reference to the entire element OFFSET refers to. Increment *SUBOFF by the bit offset of the accessed element.
References build_zero_cst(), wi::cmpu(), CONSTANT_CLASS_P, CONSTRUCTOR_ELT, CONSTRUCTOR_NELTS, fold_ctor_reference(), get_array_ctor_element_at_index(), constructor_elt::index, native_encode_expr(), native_interpret_expr(), NULL_TREE, offset, wi::to_offset(), TREE_CODE, TREE_OPERAND, TREE_TYPE, TYPE_DOMAIN, TYPE_MIN_VALUE, TYPE_SIZE_UNIT, wi::udiv_trunc(), wi::umax(), and constructor_elt::value.
Referenced by fold_ctor_reference().
void fold_builtin_atomic_compare_exchange | ( | gimple_stmt_iterator * | gsi | ) |
Fold r = __atomic_compare_exchange_N (p, &e, d, w, s, f); into _Complex uintN_t t = ATOMIC_COMPARE_EXCHANGE (p, e, d, w * 256 + N, s, f); i = IMAGPART_EXPR <t>; r = (_Bool) i; e = REALPART_EXPR <t>;
References as_a(), build1(), build_complex_type(), build_int_cst(), cfun, find_fallthru_edge(), g, gimple_assign_lhs(), gimple_build_assign(), gimple_build_call_internal(), gimple_call_arg(), gimple_call_fndecl(), gimple_call_lhs(), gimple_call_nothrow_p(), gimple_call_set_lhs(), gimple_call_set_nothrow(), gimple_move_vops(), gsi_bb(), gsi_for_stmt(), gsi_insert_after(), gsi_insert_before(), gsi_insert_on_edge_immediate(), GSI_NEW_STMT, gsi_replace(), GSI_SAME_STMT, gsi_stmt(), int_size_in_bytes(), integer_onep(), integer_type_node, make_ssa_name(), NULL, NULL_TREE, stmt_can_throw_internal(), basic_block_def::succs, TREE_CHAIN, TREE_OPERAND, TREE_TYPE, TREE_VALUE, TYPE_ARG_TYPES, and useless_type_conversion_p().
Referenced by execute_update_addresses_taken().
References fold_const_aggregate_ref_1(), and NULL.
Referenced by gimple_fold_builtin_memory_op(), strlen_pass::handle_builtin_memcmp(), and maybe_fold_reference().
Return the tree representing the element referenced by T if T is an ARRAY_REF or COMPONENT_REF into constant aggregates valuezing SSA names using VALUEIZE. Return NULL_TREE otherwise.
References array_ref_element_size(), array_ref_low_bound(), build_zero_cst(), DECL_BIT_FIELD, DECL_BIT_FIELD_REPRESENTATIVE, DECL_FIELD_BIT_OFFSET, DECL_FIELD_OFFSET, DECL_P, DECL_SIZE, error_mark_node, EXPR_LOCATION, fold_build1_loc(), fold_const_aggregate_ref_1(), fold_ctor_reference(), fold_read_from_constant_string(), get_base_constructor(), get_ref_base_and_extent(), get_symbol_constant_value(), INTEGRAL_TYPE_P, poly_int< N, C >::is_constant(), wi::lrshift(), NULL_TREE, offset, poly_int_tree_p(), wi::sext(), sizetype, wi::to_poly_offset(), poly_int< N, C >::to_shwi(), wi::to_wide(), TREE_CODE, tree_fits_uhwi_p(), TREE_OPERAND, TREE_THIS_VOLATILE, tree_to_uhwi(), TREE_TYPE, TYPE_PRECISION, and wide_int_to_tree().
Referenced by fold_const_aggregate_ref(), fold_const_aggregate_ref_1(), and gimple_fold_stmt_to_constant_1().
tree fold_ctor_reference | ( | tree | type, |
tree | ctor, | ||
const poly_uint64 & | poly_offset, | ||
const poly_uint64 & | poly_size, | ||
tree | from_decl, | ||
unsigned HOST_WIDE_INT * | suboff ) |
CTOR is a value initializing memory. Fold a reference of TYPE and bit size POLY_SIZE to the memory at bit POLY_OFFSET. When POLY_SIZE is zero, attempt to fold a reference to the entire subobject which OFFSET refers to. This is used when folding accesses to string members of aggregates. When non-null, set *SUBOFF to the bit offset of the accessed subobject.
References AGGREGATE_TYPE_P, can_native_interpret_type_p(), canonicalize_constructor_val(), CONSTANT_CLASS_P, fold_array_ctor_reference(), fold_nonarray_ctor_reference(), fold_unary, INT_MAX, poly_int< N, C >::is_constant(), known_eq, native_encode_expr(), native_encode_initializer(), native_interpret_expr(), NULL_TREE, offset, STRIP_USELESS_TYPE_CONVERSION, wi::to_poly_widest(), TREE_CODE, TREE_TYPE, TYPE_REVERSE_STORAGE_ORDER, TYPE_SIZE, unshare_expr(), and useless_type_conversion_p().
Referenced by constant_byte_string(), fold_array_ctor_reference(), fold_const_aggregate_ref_1(), fold_nonarray_ctor_reference(), and fully_constant_vn_reference_p().
|
static |
Attempt to fold an assignment statement pointed-to by SI. Returns a replacement rhs for the statement or NULL_TREE if no simplification could be made. It is assumed that the operands have been previously folded.
References build1(), build_fold_addr_expr_loc(), build_int_cst(), build_vector_from_ctor(), CONSTANT_CLASS_P, CONSTRUCTOR_ELTS, dbg_cnt(), DECL_P, dump_enabled_p(), dump_printf_loc(), fold_convert, fold_ternary_loc(), FOR_EACH_CONSTRUCTOR_VALUE, gcc_unreachable, get_gimple_rhs_class(), get_symbol_constant_value(), gimple_assign_lhs(), gimple_assign_rhs1(), gimple_assign_rhs2(), gimple_assign_rhs3(), gimple_assign_rhs_code(), GIMPLE_BINARY_RHS, GIMPLE_INVALID_RHS, gimple_location(), GIMPLE_SINGLE_RHS, GIMPLE_TERNARY_RHS, GIMPLE_UNARY_RHS, gsi_stmt(), i, integer_zerop(), is_gimple_min_invariant(), is_gimple_reg_type(), maybe_fold_reference(), MSG_OPTIMIZED_LOCATIONS, NULL_TREE, OBJ_TYPE_REF_EXPR, possible_polymorphic_call_targets(), REFERENCE_CLASS_P, si, STRIP_USELESS_TYPE_CONVERSION, TREE_CLOBBER_P, TREE_CODE, TREE_OPERAND, TREE_TYPE, useless_type_conversion_p(), valid_gimple_rhs_p(), and virtual_method_call_p().
Referenced by fold_stmt_1().
Transform IFN_GOACC_DIM_SIZE and IFN_GOACC_DIM_POS internal function calls to constants, where possible.
References build_int_cst(), current_function_decl, gimple_call_internal_fn(), gimple_call_lhs(), NULL_TREE, oacc_get_fn_dim_size(), oacc_get_ifn_dim_arg(), and TREE_TYPE.
Referenced by gimple_fold_call().
|
static |
CTOR is a CONSTRUCTOR of a record or union type. Fold a reference of SIZE bits to the memory at bit OFFSET. If non-null, TYPE is the expected type of the reference; otherwise the type of the referenced member is used instead. When SIZE is zero, attempt to fold a reference to the entire member OFFSET refers to. Increment *SUBOFF by the bit offset of the accessed member.
References build_zero_cst(), wi::cmps(), CONSTRUCTOR_ELTS, DECL_BIT_FIELD, DECL_FIELD_BIT_OFFSET, DECL_FIELD_OFFSET, DECL_SIZE, fold_ctor_reference(), FOR_EACH_CONSTRUCTOR_ELT, gcc_assert, GET_MODE_BITSIZE(), INTEGRAL_TYPE_P, wi::lts_p(), NULL_TREE, offset, SCALAR_INT_TYPE_MODE, wi::to_offset(), TREE_CODE, TREE_TYPE, and TYPE_SIZE.
Referenced by fold_ctor_reference().
bool fold_stmt | ( | gimple_stmt_iterator * | gsi, |
bitmap | dce_bitmap ) |
Fold the statement pointed to by GSI. In some cases, this function may replace the whole statement with a new one. Returns true iff folding makes any changes. The statement pointed to by GSI should be in valid gimple form but may be in unfolded state as resulting from for example constant propagation which can produce *&x = 0.
References fold_stmt_1(), and no_follow_ssa_edges().
Referenced by substitute_and_fold_dom_walker::before_dom_children(), bump_vector_ptr(), convert_mult_to_fma_1(), eliminate_dom_walker::eliminate_stmt(), execute_early_expand_coro_ifns(), fold_marked_statements(), forward_propagate_into_comparison(), generate_memcpy_builtin(), generate_memset_builtin(), gimple_fold_builtin_bzero(), gimple_fold_builtin_memory_op(), gimple_fold_builtin_snprintf(), gimple_fold_builtin_snprintf_chk(), gimple_fold_builtin_sprintf(), gimple_fold_builtin_sprintf_chk(), gimple_fold_builtin_stpcpy(), gimple_fold_builtin_strcat(), gimple_fold_builtin_strchr(), lower_omp(), lower_stmt(), maybe_fold_stmt(), dom_opt_dom_walker::optimize_stmt(), predicate_scalar_phi(), replace_call_with_call_and_fold(), replace_uses_by(), simplify_using_ranges::simplify(), simplify_using_ranges::simplify_abs_using_ranges(), simplify_bitfield_ref(), simplify_conversion_using_ranges(), simplify_using_ranges::simplify_div_or_mod_using_ranges(), simplify_using_ranges::simplify_float_conversion_using_ranges(), and simplify_using_ranges::simplify_truth_ops_using_ranges().
bool fold_stmt | ( | gimple_stmt_iterator * | gsi, |
tree(* | valueize )(tree), | ||
bitmap | dce_bitmap ) |
References fold_stmt_1().
|
static |
Worker for both fold_stmt and fold_stmt_inplace. The INPLACE argument distinguishes both cases.
References as_a(), associated_internal_fn(), build_int_cst(), changed, commutative_ternary_tree_code(), commutative_tree_code(), dce_worklist, first_commutative_argument(), fold_convert, fold_defer_overflow_warnings(), fold_gimple_assign(), fold_undefer_overflow_warnings(), get_gimple_rhs_num_ops(), gimple_asm_input_op(), gimple_asm_ninputs(), gimple_asm_noutputs(), gimple_asm_output_op(), gimple_assign_lhs(), gimple_assign_lhs_ptr(), gimple_assign_rhs1(), gimple_assign_rhs1_ptr(), gimple_assign_rhs2(), gimple_assign_rhs_class(), gimple_assign_rhs_code(), gimple_assign_set_rhs1(), gimple_assign_set_rhs2(), gimple_assign_set_rhs_code(), gimple_assign_set_rhs_from_tree(), gimple_assign_set_rhs_with_ops(), gimple_call_arg(), gimple_call_arg_ptr(), gimple_call_combined_fn(), gimple_call_lhs_ptr(), gimple_call_num_args(), gimple_call_set_arg(), gimple_cond_code(), gimple_cond_lhs(), gimple_cond_rhs(), gimple_cond_set_code(), gimple_cond_set_lhs(), gimple_cond_set_rhs(), gimple_debug_bind_get_value(), gimple_debug_bind_get_value_ptr(), gimple_debug_bind_p(), gimple_debug_bind_set_value(), gimple_fold_call(), gimple_num_ops(), gimple_return_retval(), gimple_return_set_retval(), gimple_seq_discard(), gimple_simplify(), GIMPLE_SINGLE_RHS, gsi_stmt(), i, integer_onep(), integer_zerop(), is_gimple_assign(), may_propagate_copy(), maybe_canonicalize_mem_ref_addr(), maybe_fold_reference(), NULL, REFERENCE_CLASS_P, replace_stmt_with_simplification(), sizetype, swap_tree_comparison(), tcc_comparison, TREE_CODE, TREE_CODE_CLASS, TREE_OPERAND, tree_swap_operands_p(), TREE_TYPE, TREE_VALUE, TYPE_PRECISION, useless_type_conversion_p(), and warning_suppressed_p().
Referenced by fold_stmt(), fold_stmt(), and fold_stmt_inplace().
bool fold_stmt_inplace | ( | gimple_stmt_iterator * | gsi | ) |
Perform the minimal folding on statement *GSI. Only operations like *&x created by constant propagation are handled. The statement cannot be replaced with a new one. Return true if the statement was changed, false otherwise. The statement *GSI should be in valid gimple form but may be in unfolded state as resulting from for example constant propagation which can produce *&x = 0.
References changed, fold_stmt_1(), gcc_assert, gsi_stmt(), and no_follow_ssa_edges().
Referenced by create_expression_by_pieces(), forward_propagate_addr_expr_1(), insert_debug_temp_for_var_def(), optimize_recip_sqrt(), replace_reciprocal(), replace_reciprocal_squares(), and update_ops().
Valueization callback that follows all SSA edges.
Referenced by bump_vector_ptr(), convert_mult_to_fma_1(), eliminate_dom_walker::eliminate_stmt(), fold_build_cond_expr(), gimple_build(), gimple_build(), gimple_build(), gimple_simplify_phiopt(), maybe_fold_comparisons_from_match_pd(), predicate_bbs(), predicate_scalar_phi(), and tree_vec_extract().
References ANY_INTEGRAL_TYPE_P, CDI_DOMINATORS, dom_info_available_p(), dominated_by_p(), fosa_bb, fosa_unwind, gimple_bb(), NULL_TREE, POINTER_TYPE_P, flow_sensitive_info_storage::save_and_clear(), SSA_NAME_DEF_STMT, SSA_NAME_IS_DEFAULT_DEF, TREE_CODE, TREE_TYPE, and TYPE_OVERFLOW_WRAPS.
Referenced by maybe_fold_comparisons_from_match_pd().
Valueization callback that ends up following single-use SSA edges only.
References has_single_use(), NULL_TREE, and TREE_CODE.
Referenced by substitute_and_fold_dom_walker::before_dom_children(), fvrp_folder::fold_stmt(), rvrp_folder::fold_stmt(), simplify_using_ranges::simplify(), simplify_using_ranges::simplify_abs_using_ranges(), simplify_conversion_using_ranges(), simplify_using_ranges::simplify_div_or_mod_using_ranges(), simplify_using_ranges::simplify_float_conversion_using_ranges(), and simplify_using_ranges::simplify_truth_ops_using_ranges().
|
static |
The following set of functions are supposed to fold references using their constant initializers.
See if we can find constructor defining value of BASE. When we know the consructor with constant offset (such as base is array[40] and we do know constructor of array), then BIT_OFFSET is adjusted accordingly. As a special case, return error_mark_node when constructor is not explicitly available, but it is known to be zero such as 'static const int a;'.
References CONSTANT_CLASS_P, ctor_for_folding(), error_mark_node, get_base_constructor(), get_ref_base_and_extent(), mem_ref_offset(), NULL_TREE, poly_int< N, C >::to_shwi(), TREE_CODE, and TREE_OPERAND.
Referenced by fold_const_aggregate_ref_1(), and get_base_constructor().
|
static |
Return the maximum value for ARG given RKIND (see strlen_range_kind). For ARG of pointer types, NONSTR indicates if the caller is prepared to handle unterminated strings. For integer ARG and when RKIND == SRK_INT_VALUE, NONSTR must be null. If an unterminated array is discovered and our caller handles unterminated arrays, then bubble up the offending DECL and return the maximum size. Otherwise return NULL.
References c_strlen_data::decl, gcc_assert, get_range_strlen(), integer_all_onesp(), INTEGRAL_TYPE_P, c_strlen_data::maxlen, NULL, NULL_TREE, SRK_INT_VALUE, TREE_TYPE, and visited.
Referenced by gimple_fold_builtin_fputs(), gimple_fold_builtin_memory_chk(), gimple_fold_builtin_snprintf(), gimple_fold_builtin_snprintf_chk(), gimple_fold_builtin_sprintf(), gimple_fold_builtin_strcat(), gimple_fold_builtin_strcpy(), gimple_fold_builtin_strncpy(), gimple_fold_builtin_stxcpy_chk(), and gimple_fold_builtin_stxncpy_chk().
bool get_range_strlen | ( | tree | arg, |
c_strlen_data * | pdata, | ||
unsigned | eltsize ) |
Try to obtain the range of the lengths of the string(s) referenced by ARG, or the size of the largest array ARG refers to if the range of lengths cannot be determined, and store all in *PDATA which must be zero-initialized on input except PDATA->MAXBOUND may be set to a non-null tree node other than INTEGER_CST to request to have it set to the length of the longest string in a PHI. ELTSIZE is the expected size of the string element in bytes: 1 for char and some power of 2 for wide characters. Return true if the range [PDATA->MINLEN, PDATA->MAXLEN] is suitable for optimization. Returning false means that a nonzero PDATA->MINLEN doesn't reflect the true lower bound of the range when PDATA->MAXLEN is -1 (in that case, the actual range is indeterminate, i.e., [0, PTRDIFF_MAX - 2].
References build_all_ones_cst(), get_range_strlen(), integer_all_onesp(), c_strlen_data::maxbound, c_strlen_data::maxlen, c_strlen_data::minlen, size_type_node, SRK_LENRANGE, ssize_int, and visited.
|
static |
For an ARG referencing one or more strings, try to obtain the range of their lengths, or the size of the largest array ARG referes to if the range of lengths cannot be determined, and store all in *PDATA. For an integer ARG (when RKIND == SRK_INT_VALUE), try to determine the maximum constant value. If ARG is an SSA_NAME, follow its use-def chains. When RKIND == SRK_STRLEN, then if PDATA->MAXLEN is not equal to the determined length or if we are unable to determine the length, return false. VISITED is a bitmap of visited variables. RKIND determines the kind of value or range to obtain (see strlen_range_kind). Set PDATA->DECL if ARG refers to an unterminated constant array. On input, set ELTSIZE to 1 for normal single byte character strings, and either 2 or 4 for wide characer strings (the size of wchar_t). Return true if *PDATA was successfully populated and false otherwise.
References bitmap_set_bit, build_all_ones_cst(), get_range_strlen(), get_range_strlen_tree(), gimple_assign_rhs1(), gimple_assign_rhs2(), gimple_assign_rhs3(), gimple_assign_rhs_code(), gimple_assign_single_p(), gimple_assign_unary_nop_p(), gimple_phi_arg(), gimple_phi_num_args(), gimple_phi_result(), i, c_strlen_data::maxlen, name_registered_for_update_p(), size_type_node, SRK_LENRANGE, SSA_NAME_DEF_STMT, SSA_NAME_VERSION, TREE_CODE, and visited.
Referenced by check_access(), check_strncat_sizes(), get_maxval_strlen(), get_range_strlen(), get_range_strlen(), get_range_strlen_dynamic(), get_range_strlen_tree(), gimple_fold_builtin_strlen(), maybe_diag_stxncpy_trunc(), maybe_trim_memstar_call(), and maybe_warn_nonstring_arg().
|
static |
Helper of get_range_strlen for ARG that is not an SSA_NAME.
References array_ref_flexible_size_p(), build_all_ones_cst(), c_strlen(), c_strlen_data::decl, decl_binds_to_current_def_p(), DECL_SIZE_UNIT, fold_build2, gcc_assert, get_addr_base_and_unit_offset(), get_base_address(), get_range_strlen(), integer_all_onesp(), integer_one_node, integer_zerop(), INTEGRAL_TYPE_P, known_le, c_strlen_data::maxbound, c_strlen_data::maxlen, mem_ref_offset(), c_strlen_data::minlen, NULL_TREE, offset, simple_cst_equal(), size_int, size_type_node, SRK_INT_VALUE, SRK_LENRANGE, SRK_STRLEN, ssize_int, wi::sub(), wi::to_offset(), wi::to_wide(), TREE_CODE, tree_int_cst_lt(), tree_int_cst_sgn(), TREE_OPERAND, TREE_TYPE, TYPE_DOMAIN, TYPE_MAX_VALUE, TYPE_SIZE_UNIT, VAR_P, visited, and wide_int_to_tree().
Referenced by get_range_strlen().
If SYM is a constant variable with known value, return the value. NULL_TREE is returned otherwise.
References build_zero_cst(), canonicalize_constructor_val(), ctor_for_folding(), error_mark_node, is_gimple_min_invariant(), is_gimple_reg_type(), NULL_TREE, TREE_TYPE, unshare_expr(), and useless_type_conversion_p().
Referenced by fold_const_aggregate_ref_1(), fold_gimple_assign(), get_default_value(), and gimple_fold_stmt_to_constant_1().
Return true if the floating-point value computed by assignment STMT is known to have 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 gcc_unreachable, get_gimple_rhs_class(), gimple_assign_rhs1(), gimple_assign_rhs2(), gimple_assign_rhs_code(), GIMPLE_BINARY_RHS, GIMPLE_INVALID_RHS, GIMPLE_SINGLE_RHS, GIMPLE_TERNARY_RHS, GIMPLE_UNARY_RHS, integer_valued_real_binary_p(), integer_valued_real_single_p(), and integer_valued_real_unary_p().
Referenced by gimple_stmt_integer_valued_real_p().
|
static |
Return true if the result of assignment STMT 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 gcc_unreachable, get_gimple_rhs_class(), gimple_assign_lhs(), gimple_assign_rhs1(), gimple_assign_rhs2(), gimple_assign_rhs_code(), GIMPLE_BINARY_RHS, GIMPLE_INVALID_RHS, GIMPLE_SINGLE_RHS, GIMPLE_TERNARY_RHS, GIMPLE_UNARY_RHS, tree_binary_nonnegative_warnv_p(), tree_single_nonnegative_warnv_p(), TREE_TYPE, and tree_unary_nonnegative_warnv_p().
Referenced by gimple_stmt_nonnegative_warnv_p().
tree gimple_build | ( | gimple_stmt_iterator * | gsi, |
bool | before, | ||
gsi_iterator_update | update, | ||
location_t | loc, | ||
code_helper | code, | ||
tree | type, | ||
tree | op0 ) |
Build CODE (OP0) with a result of type TYPE (or no result if TYPE is void) with location LOC, simplifying it first if possible. Returns the built expression value (or NULL_TREE if TYPE is void) inserting any new statements at GSI honoring BEFORE and UPDATE.
References gimple_build(), and code_helper::is_tree_code().
tree gimple_build | ( | gimple_stmt_iterator * | gsi, |
bool | before, | ||
gsi_iterator_update | update, | ||
location_t | loc, | ||
code_helper | code, | ||
tree | type, | ||
tree | op0, | ||
tree | op1 ) |
Build CODE (OP0, OP1) with a result of type TYPE (or no result if TYPE is void) with location LOC, simplifying it first if possible. Returns the built expression value (or NULL_TREE if TYPE is void) inserting any new statements at GSI honoring BEFORE and UPDATE.
References gimple_build(), and code_helper::is_tree_code().
tree gimple_build | ( | gimple_stmt_iterator * | gsi, |
bool | before, | ||
gsi_iterator_update | update, | ||
location_t | loc, | ||
code_helper | code, | ||
tree | type, | ||
tree | op0, | ||
tree | op1, | ||
tree | op2 ) |
Build CODE (OP0, OP1, OP2) with a result of type TYPE (or no result if TYPE is void) with location LOC, simplifying it first if possible. Returns the built expression value (or NULL_TREE if TYPE is void) inserting any new statements at GSI honoring BEFORE and UPDATE.
References gimple_build(), and code_helper::is_tree_code().
tree gimple_build | ( | gimple_stmt_iterator * | gsi, |
bool | before, | ||
gsi_iterator_update | update, | ||
location_t | loc, | ||
combined_fn | fn, | ||
tree | type ) |
Build the call FN () with a result of type TYPE (or no result if TYPE is void) with a location LOC. Returns the built expression value (or NULL_TREE if TYPE is void) inserting any new statements at GSI honoring BEFORE and UPDATE.
References as_builtin_fn(), as_internal_fn(), builtin_decl_implicit(), create_tmp_reg_or_ssa_name(), gimple_build_call(), gimple_build_call_internal(), gimple_build_insert_seq(), gimple_call_set_lhs(), gimple_seq_add_stmt_without_update(), gimple_set_location(), internal_fn_p(), NULL, NULL_TREE, and VOID_TYPE_P.
tree gimple_build | ( | gimple_stmt_iterator * | gsi, |
bool | before, | ||
gsi_iterator_update | update, | ||
location_t | loc, | ||
combined_fn | fn, | ||
tree | type, | ||
tree | arg0 ) |
Build the call FN (ARG0) with a result of type TYPE (or no result if TYPE is void) with location LOC, simplifying it first if possible. Returns the built expression value (or NULL_TREE if TYPE is void) inserting any new statements at GSI honoring BEFORE and UPDATE.
References as_builtin_fn(), as_internal_fn(), builtin_decl_implicit(), create_tmp_reg_or_ssa_name(), gimple_build_call(), gimple_build_call_internal(), gimple_build_insert_seq(), gimple_build_valueize(), gimple_call_set_lhs(), gimple_seq_add_stmt_without_update(), gimple_set_location(), gimple_simplify(), internal_fn_p(), NULL, and VOID_TYPE_P.
tree gimple_build | ( | gimple_stmt_iterator * | gsi, |
bool | before, | ||
gsi_iterator_update | update, | ||
location_t | loc, | ||
combined_fn | fn, | ||
tree | type, | ||
tree | arg0, | ||
tree | arg1 ) |
Build the call FN (ARG0, ARG1) with a result of type TYPE (or no result if TYPE is void) with location LOC, simplifying it first if possible. Returns the built expression value (or NULL_TREE if TYPE is void) inserting any new statements at GSI honoring BEFORE and UPDATE.
References as_builtin_fn(), as_internal_fn(), builtin_decl_implicit(), create_tmp_reg_or_ssa_name(), gimple_build_call(), gimple_build_call_internal(), gimple_build_insert_seq(), gimple_build_valueize(), gimple_call_set_lhs(), gimple_seq_add_stmt_without_update(), gimple_set_location(), gimple_simplify(), internal_fn_p(), NULL, and VOID_TYPE_P.
tree gimple_build | ( | gimple_stmt_iterator * | gsi, |
bool | before, | ||
gsi_iterator_update | update, | ||
location_t | loc, | ||
combined_fn | fn, | ||
tree | type, | ||
tree | arg0, | ||
tree | arg1, | ||
tree | arg2 ) |
Build the call FN (ARG0, ARG1, ARG2) with a result of type TYPE (or no result if TYPE is void) with location LOC, simplifying it first if possible. Returns the built expression value (or NULL_TREE if TYPE is void) inserting any new statements at GSI honoring BEFORE and UPDATE.
References as_builtin_fn(), as_internal_fn(), builtin_decl_implicit(), create_tmp_reg_or_ssa_name(), gimple_build_call(), gimple_build_call_internal(), gimple_build_insert_seq(), gimple_build_valueize(), gimple_call_set_lhs(), gimple_seq_add_stmt_without_update(), gimple_set_location(), gimple_simplify(), internal_fn_p(), NULL, and VOID_TYPE_P.
tree gimple_build | ( | gimple_stmt_iterator * | gsi, |
bool | before, | ||
gsi_iterator_update | update, | ||
location_t | loc, | ||
enum tree_code | code, | ||
tree | type, | ||
tree | op0 ) |
Build the expression CODE OP0 of type TYPE with location LOC, simplifying it first if possible. Returns the built expression value and inserts statements possibly defining it before GSI if BEFORE is true or after GSI if false and advance the iterator accordingly. If gsi refers to a basic block simplifying is allowed to look at all SSA defs while when it does not it is restricted to SSA defs that are not associated with a basic block yet, indicating they belong to the currently building sequence.
References gimple_stmt_iterator::bb, build1(), create_tmp_reg_or_ssa_name(), follow_all_ssa_edges(), gimple_build_assign(), gimple_build_insert_seq(), gimple_build_valueize(), gimple_seq_add_stmt_without_update(), gimple_set_location(), gimple_simplify(), and NULL.
Referenced by asan_expand_mark_ifn(), tree_switch_conversion::switch_conversion::build_one_array(), compute_new_first_bound(), convert_mult_to_fma_1(), convert_scalar_cond_reduction(), create_expression_by_pieces(), duplicate_and_interleave(), eliminate_dom_walker::eliminate_insert(), tree_switch_conversion::jump_table_cluster::emit(), expand_complex_addition(), expand_complex_comparison(), expand_complex_conjugate(), expand_complex_div_straight(), expand_complex_div_wide(), expand_complex_division(), expand_complex_multiplication(), expand_complex_multiplication_components(), expand_complex_negation(), expand_complex_paren(), gen_log2(), gen_pow2p(), generate_range_test(), get_initial_def_for_reduction(), get_initial_defs_for_reduction(), gimple_build(), gimple_build(), gimple_build(), gimple_build_round_up(), gimple_build_vector_from_val(), gimple_convert(), gimple_expand_builtin_cabs(), gimple_expand_vec_cond_expr(), gimple_fold_builtin_memory_chk(), gimple_fold_builtin_memory_op(), gimple_fold_builtin_stpcpy(), gimple_fold_builtin_stxcpy_chk(), gimplify_build1(), gimplify_build2(), gimplify_build3(), handle_builtin_alloca(), minmax_replacement(), optimize_atomic_bit_test_and(), predicate_statements(), simplify_using_ranges::simplify(), simplify_vector_constructor(), ubsan_expand_ptr_ifn(), vect_adjust_loop_lens_control(), vect_create_epilog_for_reduction(), vect_create_nonlinear_iv_init(), vect_create_nonlinear_iv_step(), vect_create_partial_epilog(), vect_gen_len(), vect_gen_while_not(), vect_get_loop_len(), vect_get_loop_mask(), vect_init_vector(), vect_peel_nonlinear_iv_init(), vect_recog_bit_insert_pattern(), vect_set_loop_condition_normal(), vect_set_loop_condition_partial_vectors(), vect_set_loop_condition_partial_vectors_avx512(), vect_set_loop_controls_directly(), vect_update_nonlinear_iv(), vectorizable_condition(), vectorizable_induction(), vectorizable_live_operation_1(), vectorizable_load(), vectorizable_store(), and vectorize_slp_instance_root_stmt().
tree gimple_build | ( | gimple_stmt_iterator * | gsi, |
bool | before, | ||
gsi_iterator_update | update, | ||
location_t | loc, | ||
enum tree_code | code, | ||
tree | type, | ||
tree | op0, | ||
tree | op1 ) |
Build the expression OP0 CODE OP1 of type TYPE with location LOC, simplifying it first if possible. Returns the built expression value inserting any new statements at GSI honoring BEFORE and UPDATE.
References gimple_stmt_iterator::bb, create_tmp_reg_or_ssa_name(), follow_all_ssa_edges(), gimple_build_assign(), gimple_build_insert_seq(), gimple_build_valueize(), gimple_seq_add_stmt_without_update(), gimple_set_location(), gimple_simplify(), and NULL.
tree gimple_build | ( | gimple_stmt_iterator * | gsi, |
bool | before, | ||
gsi_iterator_update | update, | ||
location_t | loc, | ||
enum tree_code | code, | ||
tree | type, | ||
tree | op0, | ||
tree | op1, | ||
tree | op2 ) |
Build the expression (CODE OP0 OP1 OP2) of type TYPE with location LOC, simplifying it first if possible. Returns the built expression value inserting any new statements at GSI honoring BEFORE and UPDATE.
References gimple_stmt_iterator::bb, build3(), create_tmp_reg_or_ssa_name(), follow_all_ssa_edges(), gimple_build_assign(), gimple_build_insert_seq(), gimple_build_valueize(), gimple_seq_add_stmt_without_update(), gimple_set_location(), gimple_simplify(), and NULL.
|
inlinestatic |
Helper for gimple_build to perform the final insertion of stmts on SEQ.
References gimple_stmt_iterator::bb, gsi_insert_seq_after(), gsi_insert_seq_after_without_update(), gsi_insert_seq_before(), and gsi_insert_seq_before_without_update().
Referenced by gimple_build(), gimple_build(), gimple_build(), gimple_build(), gimple_build(), gimple_build(), gimple_build(), gimple_build_vector(), and gimple_build_vector_from_val().
tree gimple_build_round_up | ( | gimple_stmt_iterator * | gsi, |
bool | before, | ||
gsi_iterator_update | update, | ||
location_t | loc, | ||
tree | type, | ||
tree | old_size, | ||
unsigned HOST_WIDE_INT | align ) |
Emit gimple statements into &stmts that take a value given in OLD_SIZE and generate a value guaranteed to be rounded upwards to ALIGN. Return the tree node representing this size, it is of TREE_TYPE TYPE.
References build_int_cst(), gcc_assert, gimple_build(), and INTEGRAL_TYPE_P.
Referenced by asan_expand_mark_ifn(), and handle_builtin_alloca().
The valueization hook we use for the gimple_build API simplification. This makes us match fold_buildN behavior by only combining with statements in the sequence(s) we are currently building.
References gimple_bb(), NULL, NULL_TREE, and SSA_NAME_DEF_STMT.
Referenced by gimple_build(), gimple_build(), gimple_build(), gimple_build(), gimple_build(), and gimple_build().
tree gimple_build_vector | ( | gimple_stmt_iterator * | gsi, |
bool | before, | ||
gsi_iterator_update | update, | ||
location_t | loc, | ||
tree_vector_builder * | builder ) |
Build a vector from BUILDER, handling the case in which some elements are non-constant. Return a gimple value for the result, inserting any new instructions to GSI honoring BEFORE and UPDATE. BUILDER must not have a stepped encoding on entry. This is because the function is not geared up to handle the arithmetic that would be needed in the variable case, and any code building a vector that is known to be constant should use BUILDER->build () directly.
References tree_vector_builder::build(), build_constructor(), cfun, CONSTANT_CLASS_P, CONSTRUCTOR_APPEND_ELT, create_tmp_reg(), vector_builder< T, Shape, Derived >::elt(), vector_builder< T, Shape, Derived >::encoded_nelts(), gcc_assert, gimple_build_assign(), gimple_build_insert_seq(), gimple_in_ssa_p(), gimple_seq_add_stmt_without_update(), gimple_set_location(), i, make_ssa_name(), vector_builder< T, Shape, Derived >::nelts_per_pattern(), NULL, NULL_TREE, poly_int< N, C >::to_constant(), tree_vector_builder::type(), TYPE_VECTOR_SUBPARTS(), and vec_alloc().
Referenced by duplicate_and_interleave(), get_initial_def_for_reduction(), get_initial_defs_for_reduction(), vect_create_constant_vectors(), vect_create_nonlinear_iv_init(), and vectorizable_induction().
tree gimple_build_vector_from_val | ( | gimple_stmt_iterator * | gsi, |
bool | before, | ||
gsi_iterator_update | update, | ||
location_t | loc, | ||
tree | type, | ||
tree | op ) |
Build a vector of type TYPE in which each element has the value OP. Return a gimple value for the result, inserting any new statements at GSI honoring BEFORE and UPDATE.
References build_vector_from_val(), cfun, CONSTANT_CLASS_P, create_tmp_reg(), gimple_build(), gimple_build_assign(), gimple_build_insert_seq(), gimple_in_ssa_p(), gimple_seq_add_stmt_without_update(), gimple_set_location(), is_gimple_val(), make_ssa_name(), NULL, and TYPE_VECTOR_SUBPARTS().
Referenced by duplicate_and_interleave(), get_initial_def_for_reduction(), get_initial_defs_for_reduction(), simplify_vector_constructor(), vect_create_constant_vectors(), vect_create_epilog_for_reduction(), vect_create_nonlinear_iv_init(), vect_set_loop_condition_partial_vectors_avx512(), and vectorizable_induction().
Return true if the floating-point value computed by call STMT is known to have 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_call_arg(), gimple_call_combined_fn(), gimple_call_num_args(), integer_valued_real_call_p(), and NULL_TREE.
Referenced by gimple_stmt_integer_valued_real_p().
|
static |
Return true if return value of call STMT 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 gimple_call_arg(), gimple_call_combined_fn(), gimple_call_lhs(), gimple_call_num_args(), NULL_TREE, tree_call_nonnegative_warnv_p(), and TREE_TYPE.
Referenced by gimple_stmt_nonnegative_warnv_p().
tree gimple_convert | ( | gimple_stmt_iterator * | gsi, |
bool | before, | ||
gsi_iterator_update | update, | ||
location_t | loc, | ||
tree | type, | ||
tree | op ) |
Build the conversion (TYPE) OP with a result of type TYPE with location LOC if such conversion is neccesary in GIMPLE, simplifying it first. Returns the built expression inserting any new statements at GSI honoring BEFORE and UPDATE.
References gimple_build(), TREE_TYPE, and useless_type_conversion_p().
Referenced by tree_switch_conversion::switch_conversion::build_one_array(), compute_new_first_bound(), convert_scalar_cond_reduction(), create_expression_by_pieces(), tree_switch_conversion::jump_table_cluster::emit(), gen_log2(), gen_pow2p(), generate_range_test(), generate_strlen_builtin_1(), generate_strlen_builtin_using_rawmemchr(), get_initial_def_for_reduction(), get_initial_defs_for_reduction(), gimple_convert_to_ptrofftype(), gimple_fold_builtin_stpcpy(), gimple_fold_builtin_stxcpy_chk(), optimize_atomic_bit_test_and(), rewrite_to_defined_overflow(), vect_create_epilog_for_reduction(), vect_create_nonlinear_iv_init(), vect_get_loop_mask(), vect_init_vector(), vect_peel_nonlinear_iv_init(), vect_set_loop_condition_partial_vectors(), vect_set_loop_condition_partial_vectors_avx512(), vect_set_loop_controls_directly(), vect_transform_cycle_phi(), vect_update_nonlinear_iv(), vectorizable_induction(), vectorizable_live_operation_1(), vectorizable_load(), vectorizable_recurr(), vectorizable_store(), and vectorize_slp_instance_root_stmt().
tree gimple_convert_to_ptrofftype | ( | gimple_stmt_iterator * | gsi, |
bool | before, | ||
gsi_iterator_update | update, | ||
location_t | loc, | ||
tree | op ) |
Build the conversion (ptrofftype) OP with a result of a type compatible with ptrofftype with location LOC if such conversion is neccesary in GIMPLE, simplifying it first. Returns the built expression value inserting any new statements at GSI honoring BEFORE and UPDATE.
References gimple_convert(), ptrofftype_p(), sizetype, and TREE_TYPE.
Referenced by gimple_fold_builtin_memory_chk(), and gimple_fold_builtin_memory_op().
|
static |
Fold the non-target builtin at *GSI and return whether any simplification was made.
References as_a(), avoid_folding_inline_builtin(), DECL_FUNCTION_CODE(), fold_call_stmt(), fold_convert, gimple_call_arg(), gimple_call_fndecl(), gimple_call_lhs(), gimple_call_num_args(), gimple_call_return_type(), gimple_fold_builtin_acc_on_device(), gimple_fold_builtin_bcmp(), gimple_fold_builtin_bcopy(), gimple_fold_builtin_bzero(), gimple_fold_builtin_clear_padding(), gimple_fold_builtin_fprintf(), gimple_fold_builtin_fputs(), gimple_fold_builtin_memchr(), gimple_fold_builtin_memory_chk(), gimple_fold_builtin_memory_op(), gimple_fold_builtin_memset(), gimple_fold_builtin_omp_is_initial_device(), gimple_fold_builtin_printf(), gimple_fold_builtin_realloc(), gimple_fold_builtin_snprintf_chk(), gimple_fold_builtin_sprintf_chk(), gimple_fold_builtin_stpcpy(), gimple_fold_builtin_strcat(), gimple_fold_builtin_strcat_chk(), gimple_fold_builtin_strchr(), gimple_fold_builtin_strcpy(), gimple_fold_builtin_string_compare(), gimple_fold_builtin_strlen(), gimple_fold_builtin_strncat(), gimple_fold_builtin_strncat_chk(), gimple_fold_builtin_strncpy(), gimple_fold_builtin_strstr(), gimple_fold_builtin_stxcpy_chk(), gimple_fold_builtin_stxncpy_chk(), gimplify_and_update_call_from_tree(), gsi_stmt(), NULL, NULL_TREE, and STRIP_NOPS.
Referenced by gimple_fold_call().
|
static |
Fold a call to __builtin_acc_on_device.
References boolean_type_node, build_int_cst(), EXPANSION, gimple_build_assign(), gimple_location(), gimple_set_location(), gsi_insert_before(), GSI_SAME_STMT, gsi_stmt(), make_ssa_name(), replace_call_with_value(), symbol_table::state, symtab, and TREE_TYPE.
Referenced by gimple_fold_builtin().
|
static |
Transform a call to built-in bcmp(a, b, len) at *GSI into one to built-in memcmp (a, b, len).
References a, b, builtin_decl_implicit(), gimple_build_call(), gimple_call_arg(), gsi_stmt(), and replace_call_with_call_and_fold().
Referenced by gimple_fold_builtin().
|
static |
Transform a call to built-in bcopy (src, dest, len) at *GSI into one to built-in memmove (dest, src, len).
References as_a(), builtin_decl_implicit(), gimple_build_call(), gimple_call_arg(), gimple_call_set_fntype(), gsi_stmt(), replace_call_with_call_and_fold(), and TREE_TYPE.
Referenced by gimple_fold_builtin().
|
static |
Transform a call to built-in bzero (dest, len) at *GSI into one to built-in memset (dest, 0, len).
References builtin_decl_implicit(), fold_stmt(), gimple_build_call(), gimple_call_arg(), gimple_seq_add_stmt_without_update(), gsi_replace_with_seq_vops(), gsi_stmt(), integer_zero_node, and NULL.
Referenced by gimple_fold_builtin().
|
static |
Fold __builtin_clear_padding builtin.
References clear_padding_struct::alias_type, clear_padding_struct::align, clear_padding_struct::base, bool, build_pointer_type(), cfun, CHAR_BIT, clear_padding_struct::clear_in_mask, clear_padding_emit_loop(), clear_padding_flush(), clear_padding_type(), clear_padding_type_may_have_padding_p(), COMPLETE_TYPE_P, create_tmp_var, end(), g, gcc_assert, get_pointer_alignment(), gimple_build_assign(), gimple_build_nop(), gimple_call_arg(), gimple_call_num_args(), gimple_in_ssa_p(), gimple_location(), gimple_set_location(), clear_padding_struct::gsi, gsi_insert_before(), gsi_prev(), gsi_remove(), gsi_replace(), GSI_SAME_STMT, gsi_stmt(), int_size_in_bytes(), is_gimple_mem_ref_addr(), clear_padding_struct::loc, make_ssa_name(), MAX, min_align_of_type(), NULL, NULL_TREE, clear_padding_struct::off, clear_padding_struct::padding_bytes, clear_padding_struct::size, sorry_at(), strip_array_types(), clear_padding_struct::sz, TREE_CODE, TREE_INT_CST_LOW, TREE_TYPE, type(), TYPE_ALIGN, TYPE_SIZE_UNIT, and clear_padding_struct::union_ptr.
Referenced by gimple_fold_builtin().
|
static |
Fold a call to the {,v}fprintf{,_unlocked} and __{,v}printf_chk builtins. FP, FMT, and ARG are the arguments to the call. We don't fold calls with more than 3 arguments, and ARG may be null in the 2-argument case. Return NULL_TREE if no simplification was possible, otherwise return the simplified form of the call as a tree. FCODE is the BUILT_IN_* code of the function to be simplified.
References as_a(), builtin_decl_explicit(), builtin_decl_implicit(), c_getstr(), gimple_build_call(), gimple_call_lhs(), gsi_stmt(), init_target_chars(), integer_type_node, NULL, NULL_TREE, POINTER_TYPE_P, replace_call_with_call_and_fold(), replace_call_with_value(), target_percent, target_percent_c, target_percent_s, TREE_TYPE, and useless_type_conversion_p().
Referenced by gimple_fold_builtin().
|
static |
Fold a call to the fputs builtin. ARG0 and ARG1 are the arguments to the call. IGNORE is true if the value returned by the builtin will be ignored. UNLOCKED is true is true if this actually a call to fputs_unlocked. If LEN in non-NULL, it represents the known length of the string. Return NULL_TREE if no simplification was possible.
References build_int_cst(), builtin_decl_explicit(), builtin_decl_implicit(), c_getstr(), cfun, compare_tree_int(), fold_convert, gcc_unreachable, get_maxval_strlen(), gimple_build_call(), gimple_call_lhs(), gsi_stmt(), integer_type_node, integer_zero_node, NULL, optimize_function_for_size_p(), replace_call_with_call_and_fold(), replace_call_with_value(), size_one_node, size_type_node, SRK_STRLEN, and TREE_CODE.
Referenced by gimple_fold_builtin().
|
static |
Fold a call to the memchr pointed by GSI iterator.
References build_int_cst(), byte_representation(), gcc_checking_assert, getbyterep(), gimple_build_assign(), gimple_build_nop(), gimple_call_arg(), gimple_call_lhs(), gimple_seq_add_stmt_without_update(), gsi_replace_with_seq_vops(), gsi_stmt(), integer_zerop(), MIN, NULL, NULL_TREE, offset, ptr_type_node, r, replace_call_with_value(), sizetype, string_length(), target_char_cst_p(), TREE_CODE, tree_fits_uhwi_p(), and tree_to_uhwi().
Referenced by gimple_fold_builtin().
|
static |
Fold a call to the __mem{cpy,pcpy,move,set}_chk builtin. DEST, SRC, LEN, and SIZE are the arguments to the call. IGNORE is true, if return value can be ignored. FCODE is the BUILT_IN_* code of the builtin. If MAXLEN is not NULL, it is maximum length passed as third argument.
References builtin_decl_explicit(), get_maxval_strlen(), gimple_build(), gimple_build_call(), gimple_call_lhs(), gimple_convert_to_ptrofftype(), gimple_location(), gsi_insert_seq_before(), GSI_SAME_STMT, gsi_stmt(), integer_all_onesp(), known_lower(), NULL, NULL_TREE, operand_equal_p(), replace_call_with_call_and_fold(), replace_call_with_value(), SRK_INT_VALUE, and TREE_TYPE.
Referenced by gimple_fold_builtin().
|
static |
Fold function call to builtin mem{{,p}cpy,move}. Try to detect and diagnose (otherwise undefined) overlapping copies without preventing folding. When folded, GCC guarantees that overlapping memcpy has the same semantics as memmove. Call to the library memcpy need not provide the same guarantee. Return false if no simplification can be made.
References AGGREGATE_TYPE_P, ao_ref_init_from_ptr_and_size(), as_a(), bitwise_mode_for_size(), bitwise_type_for_mode(), build_aligned_type(), build_array_type_nelts(), build_int_cst(), build_pointer_type_for_mode(), builtin_decl_implicit(), c_strlen(), char_type_node, check_bounds_or_overlap(), compare_tree_int(), create_tmp_reg_or_ssa_name(), FLOAT_MODE_P, fold_build2, fold_const_aggregate_ref(), fold_stmt(), gcc_unreachable, get_addr_base_and_unit_offset(), GET_MODE_ALIGNMENT, GET_MODE_BITSIZE(), get_pointer_alignment(), getbyterep(), gimple_assign_set_lhs(), gimple_build(), gimple_build_assign(), gimple_build_nop(), gimple_call_alloca_for_var_p(), gimple_call_arg(), gimple_call_lhs(), gimple_call_set_arg(), gimple_call_set_fndecl(), gimple_convert_to_ptrofftype(), gimple_location(), gimple_move_vops(), gimple_set_location(), gimple_set_vuse(), gimple_vdef(), gimple_vuse(), gsi_insert_before(), gsi_insert_seq_before(), gsi_replace(), GSI_SAME_STMT, gsi_stmt(), int_mode_for_size(), integer_zerop(), is_gimple_min_invariant(), is_gimple_reg_type(), known_eq, mem_ref_offset(), MIN, NULL, NULL_TREE, operand_equal_p(), optab_handler(), POINTER_TYPE_P, poly_int_tree_p(), pow2p_hwi(), ptr_mode, readonly_data_expr(), refs_may_alias_p_1(), release_ssa_name(), size_must_be_zero_p(), SSA_VAR_P, string_constant(), targetm, TREE_ADDRESSABLE, TREE_CODE, tree_fits_shwi_p(), tree_fits_uhwi_p(), tree_int_cst_equal(), TREE_OPERAND, tree_to_uhwi(), TREE_TYPE, type(), TYPE_ALIGN, TYPE_MAIN_VARIANT, TYPE_MODE, TYPE_REVERSE_STORAGE_ORDER, TYPE_SIZE_UNIT, unlink_stmt_vdef(), unsigned_char_type_node, var_decl_component_p(), and warning().
Referenced by gimple_fold_builtin().
|
static |
Fold function call to builtin memset or bzero at *GSI setting the memory of size LEN to VAL. Return whether a simplification was made.
References build_int_cst(), build_int_cst_type(), CHAR_BIT, fold_build2, GET_MODE_BITSIZE(), GET_MODE_PRECISION(), GET_MODE_SIZE(), get_pointer_alignment(), gimple_build_assign(), gimple_call_arg(), gimple_call_lhs(), gimple_location(), gimple_move_vops(), gimple_set_location(), gsi_insert_before(), gsi_prev(), gsi_remove(), gsi_replace(), GSI_SAME_STMT, gsi_stmt(), HOST_BITS_PER_WIDE_INT, integer_zerop(), INTEGRAL_TYPE_P, NULL_TREE, POINTER_TYPE_P, ptr_type_node, replace_call_with_value(), SCALAR_INT_TYPE_MODE, TREE_CODE, tree_fits_uhwi_p(), TREE_INT_CST_LOW, TREE_OPERAND, TREE_THIS_VOLATILE, tree_to_uhwi(), TREE_TYPE, lang_hooks_for_types::type_for_mode, type_has_mode_precision_p(), TYPE_UNSIGNED, lang_hooks::types, and var_decl_component_p().
Referenced by gimple_fold_builtin().
|
static |
References EXPANSION, integer_one_node, integer_zero_node, replace_call_with_value(), symbol_table::state, and symtab.
Referenced by gimple_fold_builtin().
|
static |
Fold a call to the {,v}printf{,_unlocked} and __{,v}printf_chk builtins. FMT and ARG are the arguments to the call; we don't fold cases with more than 2 arguments, and ARG may be null if this is a 1-argument case. Return NULL_TREE if no simplification was possible, otherwise return the simplified form of the call as a tree. FCODE is the BUILT_IN_* code of the function to be simplified.
References as_a(), build_int_cst(), build_string_literal(), builtin_decl_explicit(), builtin_decl_implicit(), c_getstr(), free(), gimple_build_call(), gimple_call_lhs(), gsi_stmt(), init_target_chars(), integer_type_node, NULL, NULL_TREE, POINTER_TYPE_P, replace_call_with_call_and_fold(), replace_call_with_value(), target_newline, target_percent, target_percent_c, target_percent_s, target_percent_s_newline, TREE_TYPE, and useless_type_conversion_p().
Referenced by gimple_fold_builtin().
|
static |
Fold realloc (0, n) -> malloc (n).
References builtin_decl_implicit(), gimple_build_call(), gimple_call_arg(), gsi_stmt(), null_pointer_node, operand_equal_p(), and replace_call_with_call_and_fold().
Referenced by gimple_fold_builtin().
bool gimple_fold_builtin_snprintf | ( | gimple_stmt_iterator * | gsi | ) |
Simplify a call to the snprintf builtin with arguments DEST, DESTSIZE, FMT, and ORIG. ORIG may be null if this is a 3-argument call. We don't attempt to simplify calls with more than 4 arguments. Return true if simplification was possible, otherwise false.
References as_a(), build_int_cstu(), builtin_decl_implicit(), c_getstr(), fold_convert, fold_stmt(), get_maxval_strlen(), gimple_build_assign(), gimple_build_call(), gimple_call_arg(), gimple_call_lhs(), gimple_call_num_args(), gimple_seq_add_stmt_without_update(), gsi_prev(), gsi_replace_with_seq_vops(), gsi_stmt(), init_target_chars(), known_lower(), NULL, NULL_TREE, SRK_STRLEN, target_percent, target_percent_s, TREE_TYPE, and useless_type_conversion_p().
|
static |
Fold a call EXP to {,v}snprintf having NARGS passed as ARGS. Return NULL_TREE if a normal call should be emitted rather than expanding the function inline. FCODE is either BUILT_IN_SNPRINTF_CHK or BUILT_IN_VSNPRINTF_CHK. If MAXLEN is not NULL, it is maximum length passed as second argument.
References as_a(), builtin_decl_explicit(), c_getstr(), fold_stmt(), get_maxval_strlen(), gimple_call_arg(), gimple_call_num_args(), gimple_call_set_arg(), gimple_call_set_fndecl(), gimple_call_set_fntype(), gimple_num_ops(), gimple_set_num_ops(), gsi_stmt(), i, init_target_chars(), integer_all_onesp(), integer_zerop(), known_lower(), NULL, SRK_INT_VALUE, target_percent, target_percent_s, and TREE_TYPE.
Referenced by gimple_fold_builtin().
bool gimple_fold_builtin_sprintf | ( | gimple_stmt_iterator * | gsi | ) |
Simplify a call to the sprintf builtin with arguments DEST, FMT, and ORIG. ORIG may be null if this is a 2-argument call. We don't attempt to simplify calls with more than 3 arguments. Return true if simplification was possible, otherwise false.
References build_int_cst(), builtin_decl_implicit(), c_getstr(), copy_warning(), fold_convert, fold_stmt(), get_maxval_strlen(), gimple_build_assign(), gimple_build_call(), gimple_call_arg(), gimple_call_lhs(), gimple_call_num_args(), gimple_seq_add_stmt_without_update(), gsi_prev(), gsi_replace_with_seq_vops(), gsi_stmt(), init_target_chars(), NULL, NULL_TREE, POINTER_TYPE_P, SRK_STRLEN, target_percent, target_percent_s, TREE_TYPE, and useless_type_conversion_p().
|
static |
Fold a call EXP to __{,v}sprintf_chk having NARGS passed as ARGS. Return NULL_TREE if a normal call should be emitted rather than expanding the function inline. FCODE is either BUILT_IN_SPRINTF_CHK or BUILT_IN_VSPRINTF_CHK.
References as_a(), build_int_cstu(), builtin_decl_explicit(), c_getstr(), c_strlen(), fold_stmt(), gimple_call_arg(), gimple_call_num_args(), gimple_call_set_arg(), gimple_call_set_fndecl(), gimple_call_set_fntype(), gimple_num_ops(), gimple_set_num_ops(), gsi_stmt(), i, init_target_chars(), integer_all_onesp(), integer_zerop(), known_lower(), NULL, NULL_TREE, POINTER_TYPE_P, size_type_node, target_percent, target_percent_s, and TREE_TYPE.
Referenced by gimple_fold_builtin().
|
static |
Fold function call to builtin stpcpy with arguments DEST and SRC. Return NULL_TREE if no simplification can be made.
References as_a(), build_int_cst(), builtin_decl_implicit(), c_strlen(), cfun, fold_stmt(), gimple_build(), gimple_build_assign(), gimple_build_call(), gimple_call_arg(), gimple_call_lhs(), gimple_call_set_fndecl(), gimple_convert(), gimple_location(), gimple_move_vops(), gsi_insert_before(), gsi_insert_seq_before(), gsi_prev(), gsi_replace(), GSI_SAME_STMT, gsi_stmt(), integer_zerop(), NULL, NULL_TREE, optimize_function_for_size_p(), size_type_node, sizetype, suppress_warning(), TREE_CODE, unterminated_array(), warn_string_no_nul(), and warning_suppressed_p().
Referenced by gimple_fold_builtin().
|
static |
Simplify a call to the strcat builtin. DST and SRC are the arguments to the call. Return NULL_TREE if no simplification was possible, otherwise return the simplified form of the call as a tree. The simplified form may be a constant or other expression which computes the same value, but in a more efficient manner (including calls to other builtin functions). The call may contain arguments which need to be evaluated, but which are not useful to determine the result of the call. In this case we return a chain of COMPOUND_EXPRs. The LHS of each COMPOUND_EXPR will be an argument which must be evaluated. COMPOUND_EXPRs are chained through their RHS. The RHS of the last COMPOUND_EXPR in the chain will contain the tree for the simplified form of the builtin function call.
References build_int_cst(), builtin_decl_implicit(), c_getstr(), create_tmp_reg_or_ssa_name(), fold_build_pointer_plus_loc(), fold_convert_loc(), fold_stmt(), force_gimple_operand(), get_maxval_strlen(), gimple_bb(), gimple_build_assign(), gimple_build_call(), gimple_call_lhs(), gimple_call_set_lhs(), gimple_location(), gimple_seq_add_seq_without_update(), gimple_seq_add_stmt_without_update(), gimple_set_location(), gsi_prev(), gsi_replace_with_seq_vops(), gsi_stmt(), NULL, NULL_TREE, optimize_bb_for_speed_p(), replace_call_with_value(), size_binop_loc(), size_type_node, and SRK_STRLEN.
Referenced by gimple_fold_builtin().
|
static |
Fold a call to the __strcat_chk builtin FNDECL. DEST, SRC, and SIZE are the arguments to the call.
References builtin_decl_explicit(), c_getstr(), gimple_build_call(), gimple_call_arg(), gsi_stmt(), integer_all_onesp(), replace_call_with_call_and_fold(), replace_call_with_value(), and tree_fits_uhwi_p().
Referenced by gimple_fold_builtin().
|
static |
Fold function call to builtin strchr or strrchr. If both arguments are constant, evaluate and fold the result, otherwise simplify str(r)chr (str, 0) into str + strlen (str). In general strlen is significantly faster than strchr due to being a simpler operation.
References build_int_cst(), builtin_decl_implicit(), c_getstr(), cfun, check_nul_terminated_array(), create_tmp_reg_or_ssa_name(), fold_stmt(), gimple_build_assign(), gimple_build_call(), gimple_call_arg(), gimple_call_lhs(), gimple_call_set_lhs(), gimple_location(), gimple_seq_add_stmt_without_update(), gimple_set_location(), gsi_prev(), gsi_replace_with_seq_vops(), gsi_stmt(), integer_zero_node, integer_zerop(), NULL, NULL_TREE, optimize_function_for_size_p(), replace_call_with_call_and_fold(), replace_call_with_value(), size_type_node, and target_char_cst_p().
Referenced by gimple_fold_builtin().
|
static |
Fold function call to builtin strcpy with arguments DEST and SRC. If LEN is not NULL, it represents the length of the string to be copied. Return NULL_TREE if no simplification can be made.
References build_int_cst(), builtin_decl_implicit(), cfun, fold_convert_loc(), force_gimple_operand_gsi(), get_maxval_strlen(), gimple_build_call(), gimple_call_fndecl(), gimple_location(), GSI_SAME_STMT, gsi_stmt(), integer_zerop(), NULL, NULL_TREE, operand_equal_p(), optimize_function_for_size_p(), replace_call_with_call_and_fold(), replace_call_with_value(), size_binop_loc(), size_type_node, SRK_STRLEN, suppress_warning(), warn_string_no_nul(), warning_at(), and warning_suppressed_p().
Referenced by gimple_fold_builtin().
|
static |
Fold a call to the str{n}{case}cmp builtin pointed by GSI iterator.
References build_cmp_result(), builtin_decl_implicit(), create_tmp_reg_or_ssa_name(), DECL_FUNCTION_CODE(), gcc_unreachable, getbyterep(), gimple_build_assign(), gimple_build_call(), gimple_call_arg(), gimple_call_fndecl(), gimple_call_lhs(), gimple_call_num_args(), gimple_load_first_char(), gimple_location(), gimple_seq_add_stmt_without_update(), gsi_replace_with_seq_vops(), gsi_stmt(), HOST_WIDE_INT_M1U, HOST_WIDE_INT_MAX, integer_type_node, integer_zero_node, MIN, NULL, NULL_TREE, operand_equal_p(), r, replace_call_with_call_and_fold(), replace_call_with_value(), tree_fits_uhwi_p(), and tree_to_uhwi().
Referenced by gimple_fold_builtin().
|
static |
Fold a call to __builtin_strlen with known length LEN.
References c_strlen_data::decl, force_gimple_operand_gsi(), get_range_strlen(), gimple_call_arg(), gimple_call_lhs(), GSI_SAME_STMT, gsi_stmt(), max_object_size(), wi::max_value(), c_strlen_data::maxlen, c_strlen_data::minlen, NULL, replace_call_with_value(), SANITIZE_ADDRESS, sanitize_flags_p(), set_strlen_range(), wi::shwi(), sizetype, wi::to_wide(), TREE_CODE, TREE_TYPE, TYPE_PRECISION, UNSIGNED, and wide_int_to_tree().
Referenced by gimple_fold_builtin().
|
static |
Simplify a call to the strncat builtin.
References builtin_decl_implicit(), c_strlen(), compute_builtin_object_size(), G_, gimple_build_call(), gimple_call_arg(), gimple_call_fndecl(), gimple_location(), gsi_stmt(), integer_zerop(), known_lower(), replace_call_with_call_and_fold(), replace_call_with_value(), suppress_warning(), TREE_CODE, tree_int_cst_compare(), warning_at(), and warning_suppressed_p().
Referenced by gimple_fold_builtin().
|
static |
Fold a call to the __strncat_chk builtin with arguments DEST, SRC, LEN, and SIZE.
References builtin_decl_explicit(), c_getstr(), c_strlen(), gimple_build_call(), gimple_call_arg(), gsi_stmt(), integer_all_onesp(), integer_zerop(), known_lower(), replace_call_with_call_and_fold(), and replace_call_with_value().
Referenced by gimple_fold_builtin().
|
static |
Fold function call to builtin strncpy with arguments DEST, SRC, and LEN. If SLEN is not NULL, it represents the length of the source string. Return NULL_TREE if no simplification can be made.
References builtin_decl_implicit(), fold_convert_loc(), force_gimple_operand_gsi(), get_attr_nonstring_decl(), get_maxval_strlen(), gimple_build_call(), gimple_call_fndecl(), gimple_location(), GSI_SAME_STMT, gsi_stmt(), integer_zerop(), maybe_diag_stxncpy_trunc(), NULL_TREE, replace_call_with_call_and_fold(), replace_call_with_value(), size_binop_loc(), size_type_node, SRK_STRLEN, ssize_int, TREE_CODE, tree_int_cst_lt(), and warning_at().
Referenced by gimple_fold_builtin().
|
static |
Fold function call to builtin strstr. If both arguments are constant, evaluate and fold the result, additionally fold strstr (x, "") into x and strstr (x, "c") into strchr (x, 'c').
References build_int_cst(), builtin_decl_implicit(), c_getstr(), check_nul_terminated_array(), gimple_build_assign(), gimple_build_call(), gimple_call_arg(), gimple_call_lhs(), gimple_seq_add_stmt_without_update(), gsi_replace_with_seq_vops(), gsi_stmt(), integer_type_node, integer_zero_node, NULL, NULL_TREE, r, replace_call_with_call_and_fold(), replace_call_with_value(), and size_type_node.
Referenced by gimple_fold_builtin().
|
static |
Fold a call to the __st[rp]cpy_chk builtin. DEST, SRC, and SIZE are the arguments to the call. IGNORE is true if return value can be ignored. FCODE is the BUILT_IN_* code of the builtin. If MAXLEN is not NULL, it is maximum length of strings passed as second argument.
References as_a(), build_int_cst(), builtin_decl_explicit(), c_strlen(), force_gimple_operand(), get_maxval_strlen(), gimple_build(), gimple_build_call(), gimple_call_fndecl(), gimple_call_lhs(), gimple_convert(), gimple_location(), gsi_insert_seq_before(), GSI_SAME_STMT, gsi_stmt(), integer_all_onesp(), integer_zerop(), known_lower(), NULL, NULL_TREE, operand_equal_p(), replace_call_with_call_and_fold(), replace_call_with_value(), size_type_node, SRK_STRLENMAX, TREE_SIDE_EFFECTS, warning_at(), and warning_suppressed_p().
Referenced by gimple_fold_builtin().
|
static |
Fold a call to the __st{r,p}ncpy_chk builtin. DEST, SRC, LEN, and SIZE are the arguments to the call. If MAXLEN is not NULL, it is maximum length passed as third argument. IGNORE is true if return value can be ignored. FCODE is the BUILT_IN_* code of the builtin.
References as_a(), builtin_decl_explicit(), get_maxval_strlen(), gimple_build_call(), gimple_call_lhs(), gsi_stmt(), integer_all_onesp(), known_lower(), NULL_TREE, replace_call_with_call_and_fold(), and SRK_INT_VALUE.
Referenced by gimple_fold_builtin().
|
static |
Attempt to fold a call statement referenced by the statement iterator GSI. The statement may be replaced by another statement, e.g., if the call simplifies to a constant value. Return true if any changes were made. It is assumed that the operands have been previously folded.
References arith_overflowed_p(), as_a(), build2_loc(), build_complex(), build_complex_type(), build_one_cst(), build_zero_cst(), BUILT_IN_MD, BUILT_IN_NORMAL, cfun, changed, create_tmp_var, dbg_cnt(), DECL_STATIC_CHAIN, drop_tree_overflow(), dump_enabled_p(), dump_file, dump_printf_loc(), fold_builtin_expect(), fold_convert, fold_internal_goacc_dim(), cgraph_node::get(), get_or_create_ssa_default_def(), gimple_build_assign(), gimple_build_builtin_unreachable(), gimple_build_nop(), gimple_call_addr_fndecl(), gimple_call_arg(), gimple_call_builtin_p(), gimple_call_chain(), gimple_call_fn(), gimple_call_fndecl(), gimple_call_fntype(), gimple_call_internal_fn(), gimple_call_internal_p(), gimple_call_lhs(), gimple_call_noreturn_p(), gimple_call_set_chain(), gimple_call_set_ctrl_altering(), gimple_call_set_fn(), gimple_call_set_fndecl(), gimple_call_set_fntype(), gimple_call_set_lhs(), gimple_fold_builtin(), gimple_fold_partial_load(), gimple_fold_partial_store(), gimple_location(), gimple_move_vops(), gimplify_and_update_call_from_tree(), gsi_insert_before(), gsi_replace(), GSI_SAME_STMT, gsi_stmt(), integer_all_onesp(), integer_onep(), integer_zero_node, integer_zerop(), maybe_remove_unused_call_args(), MSG_OPTIMIZED_LOCATIONS, NULL, NULL_TREE, OBJ_TYPE_REF_EXPR, offset, operand_equal_p(), possible_polymorphic_call_target_p(), possible_polymorphic_call_targets(), print_generic_expr(), print_gimple_stmt(), replace_call_with_value(), set_ssa_default_def(), SET_SSA_NAME_VAR_OR_IDENTIFIER, should_remove_lhs_p(), SSA_NAME_DEF_STMT, targetm, TDF_SLIM, TREE_CODE, tree_int_cst_le(), tree_int_cst_lt(), TREE_OVERFLOW, TREE_TYPE, TREE_VALUE, TYPE_ARG_TYPES, TYPE_PRECISION, TYPE_UNSIGNED, virtual_method_call_p(), void_type_node, and VOID_TYPE_P.
Referenced by fold_stmt_1().
Given a pointer value T, return a simplified version of an indirection through T, or NULL_TREE if no simplification is possible. Note that the resulting type may be different from the type pointed to in the sense that it is still compatible from the langhooks point of view.
References bitsize_int, build1(), build4(), DECL_P, fold_build1, fold_build2, fold_build3, gimple_fold_indirect_ref(), known_lt, NULL_TREE, offset, POINTER_TYPE_P, size_zero_node, STRIP_NOPS, wi::to_wide(), TREE_CODE, tree_fits_uhwi_p(), tree_int_cst_equal(), TREE_OPERAND, tree_to_shwi(), tree_to_uhwi(), TREE_TYPE, TYPE_DOMAIN, TYPE_MIN_VALUE, TYPE_REF_CAN_ALIAS_ALL, TYPE_SIZE, TYPE_SIZE_UNIT, TYPE_VECTOR_SUBPARTS(), useless_type_conversion_p(), and wide_int_to_tree().
Referenced by copy_tree_body_r(), expand_thunk(), gimple_fold_indirect_ref(), gimple_fold_indirect_ref_rhs(), and maybe_make_indirect().
|
static |
Try to fold IFN_{MASK,LEN}_LOAD call CALL. Return true on success. MASK_P indicates it's for MASK if true, otherwise it's for LEN.
References gimple_build_assign(), gimple_call_lhs(), gimple_fold_partial_load_store_mem_ref(), gimple_location(), gimple_move_vops(), gimple_set_location(), gsi_replace(), and TREE_TYPE.
Referenced by gimple_fold_call().
|
static |
If IFN_{MASK,LEN,MASK_LEN}_LOAD/STORE call CALL is unconditional, return a MEM_REF for the memory it references, otherwise return null. VECTYPE is the type of the memory vector. MASK_P indicates it's for MASK if true, otherwise it's for LEN.
References build_aligned_type(), build_zero_cst(), fold_build2, gcc_assert, GET_MODE_NUNITS(), gimple_call_arg(), gimple_call_internal_fn(), integer_all_onesp(), internal_fn_len_index(), internal_fn_mask_index(), NULL_TREE, offset, poly_int_tree_p(), wi::to_poly_widest(), wi::to_widest(), TREE_CODE, tree_fits_uhwi_p(), tree_to_uhwi(), TREE_TYPE, TYPE_ALIGN, and TYPE_MODE.
Referenced by gimple_fold_partial_load(), and gimple_fold_partial_store().
|
static |
Try to fold IFN_{MASK,LEN}_STORE call CALL. Return true on success. MASK_P indicates it's for MASK if true, otherwise it's for LEN.
References gimple_build_assign(), gimple_call_arg(), gimple_call_internal_fn(), gimple_fold_partial_load_store_mem_ref(), gimple_location(), gimple_move_vops(), gimple_set_location(), gsi_replace(), internal_fn_stored_value_index(), and TREE_TYPE.
Referenced by gimple_fold_call().
Fold STMT to a constant using VALUEIZE to valueize SSA names. Returns NULL_TREE if folding to a constant is not possible, otherwise returns a constant according to is_gimple_min_invariant.
References gimple_fold_stmt_to_constant_1(), is_gimple_min_invariant(), and NULL_TREE.
Referenced by object_sizes_execute().
tree gimple_fold_stmt_to_constant_1 | ( | gimple * | stmt, |
tree(* | valueize )(tree), | ||
tree(* | gvalueize )(tree) ) |
Fold STMT to a constant using VALUEIZE to valueize SSA names. Either NULL_TREE, a simplified but non-constant or a constant is returned. ??? This should go into a gimple-fold-inline.h file to be eventually privatized with the single valueize function used in the various TUs to avoid the indirect function call overhead.
References as_a(), build1_loc(), build_invariant_address(), build_zero_cst(), CONSTANT_CLASS_P, CONSTRUCTOR_ELTS, CONSTRUCTOR_NELTS, decl_address_invariant_p(), dump_file, dump_flags, EXPR_LOCATION, fndecl_built_in_p(), fold_binary_loc(), fold_build2, fold_builtin_call_array(), fold_const_aggregate_ref_1(), fold_convert, fold_ternary_loc(), fold_unary_loc(), FOR_EACH_CONSTRUCTOR_VALUE, gcc_unreachable, get_addr_base_and_unit_offset_1(), get_gimple_rhs_class(), get_symbol_constant_value(), gimple_assign_lhs(), gimple_assign_rhs1(), gimple_assign_rhs2(), gimple_assign_rhs3(), gimple_assign_rhs_code(), GIMPLE_BINARY_RHS, gimple_builtin_call_types_compatible_p(), gimple_call_arg(), gimple_call_fn(), gimple_call_internal_fn(), gimple_call_internal_p(), gimple_call_num_args(), gimple_call_return_type(), gimple_location(), gimple_simplified_result_is_gimple_val(), gimple_simplify(), GIMPLE_SINGLE_RHS, GIMPLE_TERNARY_RHS, GIMPLE_UNARY_RHS, i, integer_onep(), integer_zerop(), is_gimple_min_invariant(), known_eq, mprts_hook, NULL, NULL_TREE, OBJ_TYPE_REF_EXPR, offset, operand_equal_p(), gimple_match_op::ops, print_generic_expr(), print_gimple_expr(), ptr_type_node, STRIP_NOPS, tcc_declaration, tcc_reference, TDF_DETAILS, TDF_SLIM, TREE_CODE, TREE_CODE_CLASS, TREE_OPERAND, TREE_OVERFLOW, TREE_TYPE, TYPE_VECTOR_SUBPARTS(), unshare_expr(), and useless_type_conversion_p().
Referenced by back_propagate_equivalences(), ccp_fold(), copy_prop_visit_assignment(), gimple_fold_stmt_to_constant(), jt_state::register_equivs_stmt(), try_to_simplify(), pointer_equiv_analyzer::visit_stmt(), and visit_stmt().
Return a declaration of a function which an OBJ_TYPE_REF references. TOKEN is integer form of OBJ_TYPE_REF_TOKEN of the reference expression. KNOWN_BINFO carries the binfo describing the true type of OBJ_TYPE_REF_OBJECT(REF). Set CAN_REFER if non-NULL to false if method is not referable or if the virtual table is ill-formed (such as rewriten by non-C++ produced symbol). Otherwise just return NULL in that calse.
References BINFO_VTABLE, gimple_get_virt_method_for_vtable(), NULL_TREE, offset, and vtable_pointer_value_to_vtable().
Referenced by possible_polymorphic_call_targets(), record_target_from_binfo(), and record_targets_from_bases().
tree gimple_get_virt_method_for_vtable | ( | HOST_WIDE_INT | token, |
tree | v, | ||
unsigned HOST_WIDE_INT | offset, | ||
bool * | can_refer ) |
Lookup virtual method with index TOKEN in a virtual table V at OFFSET. Set CAN_REFER if non-NULL to false if method is not referable or if the virtual table is ill-formed (such as rewriten by non-C++ produced symbol). Otherwise just return NULL in that calse.
References builtin_decl_unreachable(), can_refer_decl_in_current_unit_p(), CONSTRUCTOR_ELT, CONSTRUCTOR_NELTS, ctor_for_folding(), DECL_VIRTUAL_P, error_mark_node, gcc_assert, gcc_checking_assert, cgraph_node::get_create(), integer_zerop(), NULL, NULL_TREE, offset, STRIP_NOPS, TREE_CODE, TREE_OPERAND, tree_to_uhwi(), TREE_TYPE, TYPE_DOMAIN, TYPE_MIN_VALUE, TYPE_SIZE, TYPE_SIZE_UNIT, and VAR_P.
Referenced by gimple_get_virt_method_for_binfo(), ipa_get_indirect_edge_target_1(), and try_make_edge_direct_virtual_call().
|
static |
Build and append gimple statements to STMTS that would load a first character of a memory location identified by STR. LOC is location of the statement.
References build_int_cst(), build_pointer_type_for_mode(), build_type_variant, create_tmp_reg_or_ssa_name(), fold_build2_loc(), gimple_assign_set_lhs(), gimple_build_assign(), gimple_seq_add_stmt_without_update(), NULL_TREE, ptr_mode, and unsigned_char_type_node.
Referenced by gimple_fold_builtin_string_compare().
Return true if the floating-point result of phi STMT is known to have 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_phi_arg_def(), gimple_phi_num_args(), i, and integer_valued_real_single_p().
Referenced by gimple_stmt_integer_valued_real_p().
|
static |
Return true if return value of call STMT 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 gimple_phi_arg_def(), gimple_phi_num_args(), i, and tree_single_nonnegative_warnv_p().
Referenced by gimple_stmt_nonnegative_warnv_p().
Return true if the floating-point value computed by STMT is known to have 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_assign_integer_valued_real_p(), gimple_call_integer_valued_real_p(), and gimple_phi_integer_valued_real_p().
Referenced by integer_valued_real_single_p().
Return true if STMT is known to compute a non-negative value. 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 get_global_range_query(), gimple_assign_nonnegative_warnv_p(), gimple_call_nonnegative_warnv_p(), gimple_phi_nonnegative_warnv_p(), gimple_range_type(), r, and frange::supports_p().
Referenced by fold_using_range::fold_stmt(), fold_using_range::range_of_call(), and tree_single_nonnegative_warnv_p().
void gimplify_and_update_call_from_tree | ( | gimple_stmt_iterator * | si_p, |
tree | expr ) |
Convert EXPR into a GIMPLE value suitable for substitution on the RHS of an assignment. Insert the necessary statements before iterator *SI_P. The statement at *SI_P, which must be a GIMPLE_CALL is replaced. If the call is expected to produces a result, then it is replaced by an assignment of the new RHS to the result variable. If the result is to be ignored, then the call is replaced by a GIMPLE_NOP. A proper VDEF chain is retained by making the first VUSE and the last VDEF of the whole sequence be the same as the replaced statement and using new SSA names for stores in between.
References CALL_EXPR_ARG, CALL_EXPR_FN, call_expr_nargs, cfun, finish_update_gimple_call(), force_gimple_operand(), gcc_assert, gimple_build_assign(), gimple_build_call_vec(), gimple_build_nop(), gimple_call_lhs(), gimple_in_ssa_p(), gimple_seq_empty_p(), gimplify_and_add(), GSI_CONTINUE_LINKING, gsi_insert_after_without_update(), gsi_last(), gsi_replace(), gsi_replace_with_seq_vops(), gsi_stmt(), i, is_gimple_call(), NULL, NULL_TREE, pop_gimplify_context(), push_gimplify_context(), release_defs(), unlink_stmt_vdef(), valid_gimple_call_p(), and vNULL.
Referenced by dynamic_object_sizes_execute_one(), ccp_folder::fold_stmt(), gimple_fold_builtin(), gimple_fold_call(), strlen_pass::handle_builtin_memcmp(), strlen_pass::handle_builtin_strchr(), strlen_pass::handle_builtin_strlen(), maybe_optimize_arith_overflow(), and simplify_builtin_call().
void gsi_replace_with_seq_vops | ( | gimple_stmt_iterator * | si_p, |
gimple_seq | stmts ) |
Replace a statement at *SI_P with a sequence of statements in STMTS, adjusting the replacement stmts location and virtual operands. If the statement has a lhs the last stmt in the sequence is expected to assign to that lhs.
References annotate_all_with_location(), cfun, ECF_CONST, ECF_NORETURN, ECF_NOVOPS, ECF_PURE, gimple_assign_lhs(), gimple_assign_single_p(), gimple_call_flags(), gimple_has_location(), gimple_has_mem_ops(), gimple_location(), gimple_set_modified(), gimple_set_vdef(), gimple_set_vuse(), gimple_vdef(), gimple_vop(), gimple_vuse(), gsi_end_p(), gsi_last(), gsi_next(), gsi_prev(), gsi_replace_with_seq(), gsi_start(), gsi_stmt(), i, is_gimple_call(), is_gimple_reg(), make_ssa_name(), NULL, release_ssa_name(), SSA_NAME_DEF_STMT, TREE_CODE, and unlink_stmt_vdef().
Referenced by gimple_fold_builtin_bzero(), gimple_fold_builtin_memchr(), gimple_fold_builtin_snprintf(), gimple_fold_builtin_sprintf(), gimple_fold_builtin_strcat(), gimple_fold_builtin_strchr(), gimple_fold_builtin_string_compare(), gimple_fold_builtin_strstr(), gimplify_and_update_call_from_tree(), and replace_stmt_with_simplification().
Return true whether NAME has a use on STMT. Note this can return false even though there's a use on STMT if SSA operands are not up-to-date.
References FOR_EACH_SSA_TREE_OPERAND, and SSA_OP_USE.
Referenced by replace_stmt_with_simplification().
Return true if LEN is known to be less than or equal to (or if STRICT is true, strictly less than) the lower bound of SIZE at compile time and false otherwise.
References get_range(), wi::leu_p(), wi::ltu_p(), and NULL_TREE.
Referenced by gimple_fold_builtin_memory_chk(), gimple_fold_builtin_snprintf(), gimple_fold_builtin_snprintf_chk(), gimple_fold_builtin_sprintf_chk(), gimple_fold_builtin_strncat(), gimple_fold_builtin_strncat_chk(), gimple_fold_builtin_stxcpy_chk(), and gimple_fold_builtin_stxncpy_chk().
|
static |
Add the lhs of each statement of SEQ to DCE_WORKLIST.
References bitmap_set_bit, dce_worklist, gimple_get_lhs(), gsi_end_p(), gsi_next(), gsi_start(), gsi_stmt(), i, SSA_NAME_VERSION, and TREE_CODE.
Referenced by replace_stmt_with_simplification().
Canonicalize MEM_REFs invariant address operand after propagation.
References wi::add(), array_ref_low_bound(), bitsizetype, build3_loc(), build_fold_addr_expr, build_int_cst(), EXPR_LOCATION, gcc_assert, gcc_checking_assert, gcc_unreachable, get_addr_base_and_unit_offset(), handled_component_p(), int_const_binop(), integer_zerop(), is_gimple_mem_ref_addr(), wi::les_p(), maybe_fold_tmr(), mem_ref_offset(), MR_DEPENDENCE_CLIQUE, wi::mul(), recompute_tree_invariant_for_addr_expr(), size_int, wi::sub(), wi::to_poly_wide(), wi::to_widest(), TREE_CODE, tree_int_cst_le(), TREE_OPERAND, TREE_THIS_VOLATILE, TREE_TYPE, TYPE_ALIGN, TYPE_MAIN_VARIANT, TYPE_REF_CAN_ALIAS_ALL, TYPE_SIZE, types_compatible_p(), VECTOR_TYPE_P, and wide_int_to_tree().
Referenced by fold_stmt_1().
tree maybe_fold_and_comparisons | ( | tree | type, |
enum tree_code | code1, | ||
tree | op1a, | ||
tree | op1b, | ||
enum tree_code | code2, | ||
tree | op2a, | ||
tree | op2b, | ||
basic_block | outer_cond_bb ) |
Try to simplify the AND of two comparisons, specified by (OP1A CODE1 OP1B) and (OP2B CODE2 OP2B), respectively. If this can be simplified to a single expression (without requiring introducing more SSA variables to hold intermediate values), return the resulting tree. Otherwise return NULL_TREE. If the result expression is non-null, it has boolean type.
References and_comparisons_1(), maybe_fold_comparisons_from_match_pd(), and NULL_TREE.
Referenced by and_var_with_comparison_1(), eliminate_redundant_comparison(), ifcombine_ifandif(), optimize_vec_cond_expr(), and simplify_1b().
|
static |
Helper function for maybe_fold_and_comparisons and maybe_fold_or_comparisons : try to simplify the AND/OR of the ssa variable VAR with the comparison specified by (OP2A CODE2 OP2B) from match.pd. Return NULL_EXPR if we can't simplify this to a single expression. As we are going to lower the cost of building SSA names / gimple stmts significantly, we need to allocate them ont the stack. This will cause the code to be a bit ugly.
References build2(), gimple_match_op::code, follow_all_ssa_edges(), follow_outer_ssa_edges(), fosa_bb, fosa_unwind, gimple_assign_lhs(), gimple_assign_set_lhs(), gimple_assign_set_rhs1(), gimple_assign_set_rhs2(), gimple_assign_set_rhs_code(), gimple_init(), gimple_set_bb(), gimple_simplified_result_is_gimple_val(), gimple_size(), init_ssa_name_imm_use(), code_helper::is_tree_code(), NULL, NULL_TREE, gimple_match_op::ops, gimple_match_op::resimplify(), tcc_comparison, TREE_CODE_CLASS, TREE_SET_CODE, TREE_TYPE, gimple_match_op::type, type(), and gimple_match_cond::UNCOND.
Referenced by maybe_fold_and_comparisons(), and maybe_fold_or_comparisons().
tree maybe_fold_or_comparisons | ( | tree | type, |
enum tree_code | code1, | ||
tree | op1a, | ||
tree | op1b, | ||
enum tree_code | code2, | ||
tree | op2a, | ||
tree | op2b, | ||
basic_block | outer_cond_bb ) |
Try to simplify the OR of two comparisons, specified by (OP1A CODE1 OP1B) and (OP2B CODE2 OP2B), respectively. If this can be simplified to a single expression (without requiring introducing more SSA variables to hold intermediate values), return the resulting tree. Otherwise return NULL_TREE. If the result expression is non-null, it has boolean type.
References maybe_fold_comparisons_from_match_pd(), NULL_TREE, and or_comparisons_1().
Referenced by eliminate_redundant_comparison(), fold_or_predicates(), optimize_vec_cond_expr(), and or_var_with_comparison_1().
Subroutine of fold_stmt. We perform constant folding of the memory reference tree EXPR.
References CONSTANT_CLASS_P, EXPR_LOCATION, fold_const_aggregate_ref(), fold_ternary_loc(), fold_unary_loc(), is_gimple_min_invariant(), NULL_TREE, TREE_CODE, TREE_OPERAND, and TREE_TYPE.
Referenced by fold_gimple_assign(), and fold_stmt_1().
Valueziation callback that ends up not following SSA edges.
References NULL_TREE.
Referenced by back_propagate_equivalences(), cleanup_control_expr_graph(), fold_stmt(), and fold_stmt_inplace().
Return true if stmt is __atomic_compare_exchange_N call which is suitable for conversion into ATOMIC_COMPARE_EXCHANGE if the second argument is &var where var is only addressable because of such calls.
References auto_var_in_fn_p(), BUILT_IN_NORMAL, current_function_decl, DECL_FUNCTION_CODE(), direct_optab_handler(), GET_MODE_BITSIZE(), GET_MODE_SIZE(), gimple_call_arg(), gimple_call_builtin_p(), gimple_call_fndecl(), gimple_call_num_args(), gimple_vdef(), gimple_vuse(), int_size_in_bytes(), integer_onep(), integer_zerop(), is_gimple_reg_type(), optab_handler(), SANITIZE_ADDRESS, sanitize_flags_p(), SANITIZE_THREAD, SCALAR_FLOAT_TYPE_P, SSA_VAR_P, TREE_CHAIN, TREE_CODE, TREE_OPERAND, TREE_THIS_VOLATILE, TREE_TYPE, TREE_VALUE, TYPE_ARG_TYPES, TYPE_MODE, TYPE_PRECISION, and VECTOR_TYPE_P.
Referenced by execute_update_addresses_taken().
|
static |
Try to simplify the OR of two comparisons defined by (OP1A CODE1 OP1B) and (OP2A CODE2 OP2B), respectively. If this can be done without constructing an intermediate value, return the resulting tree; otherwise NULL_TREE is returned. This function is deliberately asymmetric as it recurses on SSA_DEFs in the first comparison but not the second.
References boolean_true_node, boolean_type_node, CDI_DOMINATORS, combine_comparisons(), dom_info_available_p(), dominated_by_p(), fold_build2, gimple_bb(), gimple_phi_arg_def(), gimple_phi_num_args(), gimple_phi_result(), i, integer_nonzerop(), integer_onep(), integer_zerop(), NULL_TREE, operand_equal_p(), or_var_with_comparison(), same_bool_comparison_p(), same_bool_result_p(), SSA_NAME_DEF_STMT, SSA_NAME_IS_DEFAULT_DEF, swap_tree_comparison(), TREE_CODE, TREE_TYPE, truth_type_for(), and UNKNOWN_LOCATION.
Referenced by maybe_fold_or_comparisons(), and or_var_with_comparison_1().
|
static |
Helper function for or_comparisons_1: try to simplify the OR of the ssa variable VAR with the comparison specified by (OP2A CODE2 OP2B). If INVERT is true, invert the value of VAR before doing the OR. Return NULL_EXPR if we can't simplify this to a single expression.
References and_var_with_comparison_1(), canonicalize_bool(), invert_tree_comparison(), is_gimple_assign(), NULL_TREE, or_var_with_comparison_1(), and SSA_NAME_DEF_STMT.
Referenced by or_comparisons_1(), and or_var_with_comparison_1().
|
static |
Try to simplify the OR of the ssa variable defined by the assignment STMT with the comparison specified by (OP2A CODE2 OP2B). Return NULL_EXPR if we can't simplify this to a single expression.
References boolean_false_node, boolean_true_node, gimple_assign_lhs(), gimple_assign_rhs1(), gimple_assign_rhs2(), gimple_assign_rhs_code(), integer_nonzerop(), integer_onep(), integer_zerop(), is_gimple_assign(), maybe_fold_or_comparisons(), NULL_TREE, or_comparisons_1(), or_var_with_comparison(), same_bool_result_p(), SSA_NAME_DEF_STMT, tcc_comparison, TREE_CODE, TREE_CODE_CLASS, and TREE_TYPE.
Referenced by and_var_with_comparison(), and or_var_with_comparison().
|
static |
Replace the call at *GSI with the new call REPL and fold that again.
References as_a(), dump_transformation(), fold_stmt(), gimple_call_lhs(), gimple_call_set_lhs(), gimple_location(), gimple_move_vops(), gimple_set_location(), gsi_replace(), and gsi_stmt().
Referenced by gimple_fold_builtin_bcmp(), gimple_fold_builtin_bcopy(), gimple_fold_builtin_fprintf(), gimple_fold_builtin_fputs(), gimple_fold_builtin_memory_chk(), gimple_fold_builtin_printf(), gimple_fold_builtin_realloc(), gimple_fold_builtin_strcat_chk(), gimple_fold_builtin_strchr(), gimple_fold_builtin_strcpy(), gimple_fold_builtin_string_compare(), gimple_fold_builtin_strncat(), gimple_fold_builtin_strncat_chk(), gimple_fold_builtin_strncpy(), gimple_fold_builtin_strstr(), gimple_fold_builtin_stxcpy_chk(), and gimple_fold_builtin_stxncpy_chk().
void replace_call_with_value | ( | gimple_stmt_iterator * | gsi, |
tree | val ) |
Replace the call at *GSI with the gimple value VAL.
References fold_convert, gimple_build_assign(), gimple_build_nop(), gimple_call_lhs(), gimple_vdef(), gsi_replace(), gsi_stmt(), release_ssa_name(), TREE_CODE, TREE_TYPE, unlink_stmt_vdef(), and useless_type_conversion_p().
Referenced by fold_loop_internal_call(), ccp_folder::fold_stmt(), gimple_fold_builtin_acc_on_device(), gimple_fold_builtin_fprintf(), gimple_fold_builtin_fputs(), gimple_fold_builtin_memchr(), gimple_fold_builtin_memory_chk(), gimple_fold_builtin_memset(), gimple_fold_builtin_omp_is_initial_device(), gimple_fold_builtin_printf(), gimple_fold_builtin_strcat(), gimple_fold_builtin_strcat_chk(), gimple_fold_builtin_strchr(), gimple_fold_builtin_strcpy(), gimple_fold_builtin_string_compare(), gimple_fold_builtin_strlen(), gimple_fold_builtin_strncat(), gimple_fold_builtin_strncat_chk(), gimple_fold_builtin_strncpy(), gimple_fold_builtin_strstr(), gimple_fold_builtin_stxcpy_chk(), gimple_fold_call(), handle_builtin_alloca(), strlen_pass::handle_builtin_string_cmp(), object_sizes_execute(), optimize_stack_restore(), and propagate_tree_value_into_stmt().
|
static |
Worker for fold_stmt_1 dispatch to pattern based folding with gimple_simplify. Replaces *GSI with the simplification result in RCODE and OPS and the associated statements in *SEQ. Does the replacement according to INPLACE and returns true if the operation succeeded.
References build_zero_cst(), cfun, gimple_match_op::code, COMPARISON_CLASS_P, dce_worklist, dump_file, dump_flags, dyn_cast(), FLOAT_TYPE_P, gcc_assert, gcc_unreachable, get_gimple_rhs_num_ops(), gimple_assign_set_rhs_with_ops(), gimple_call_combined_fn(), gimple_call_num_args(), gimple_call_set_arg(), gimple_cond_make_false(), gimple_cond_make_true(), gimple_cond_set_condition(), gimple_get_lhs(), gimple_has_lhs(), gimple_num_ops(), gimple_seq_empty_p(), gsi_insert_seq_before(), gsi_replace_with_seq_vops(), GSI_SAME_STMT, gsi_stmt(), has_use_on_stmt(), i, integer_zerop(), code_helper::is_fn_code(), is_gimple_assign(), code_helper::is_tree_code(), mark_lhs_in_seq_for_dce(), maybe_build_generic_op(), maybe_push_res_to_seq(), NULL_TREE, gimple_match_op::num_ops, gimple_match_op::op_or_null(), operation_could_trap_p(), gimple_match_op::ops, print_gimple_seq(), print_gimple_stmt(), SSA_NAME_OCCURS_IN_ABNORMAL_PHI, tcc_comparison, TDF_DETAILS, TDF_SLIM, TREE_CODE, TREE_CODE_CLASS, TREE_OPERAND, and TREE_TYPE.
Referenced by fold_stmt_1().
gimple_seq rewrite_to_defined_overflow | ( | gimple * | stmt | ) |
References rewrite_to_defined_overflow().
void rewrite_to_defined_overflow | ( | gimple_stmt_iterator * | gsi | ) |
References gsi_stmt(), and rewrite_to_defined_overflow().
|
static |
Rewrite STMT, an assignment with a signed integer or pointer arithmetic operation that can be transformed to unsigned arithmetic by converting its operand, carrying out the operation in the corresponding unsigned type and converting the result back to the original type. If IN_PLACE is true, *GSI points to STMT, adjust the stmt in place and return NULL. Otherwise returns a sequence of statements that replace STMT and also contain a modified form of STMT itself.
References dump_file, dump_flags, gimple_assign_lhs(), gimple_assign_rhs_code(), gimple_assign_set_lhs(), gimple_assign_set_rhs_code(), gimple_build_assign(), gimple_convert(), gimple_num_ops(), gimple_op(), gimple_seq_add_stmt(), gimple_set_modified(), gimple_set_op(), gsi_insert_after(), gsi_insert_seq_before(), GSI_SAME_STMT, i, make_ssa_name(), NULL, print_gimple_stmt(), TDF_DETAILS, TDF_SLIM, TREE_TYPE, unsigned_type_for(), and update_stmt().
Referenced by final_value_replacement_loop(), move_computations_worker(), predicate_statements(), rewrite_to_defined_overflow(), rewrite_to_defined_overflow(), split_loop(), and update_range_test().
|
static |
Check to see if a boolean expression EXPR is logically equivalent to the comparison (OP1 CODE OP2). Check for various identities involving SSA_NAMEs.
References gimple_assign_rhs1(), gimple_assign_rhs2(), gimple_assign_rhs_code(), integer_nonzerop(), integer_zerop(), invert_tree_comparison(), is_gimple_assign(), operand_equal_p(), same_bool_comparison_p(), SSA_NAME_DEF_STMT, tcc_comparison, TREE_CODE, TREE_CODE_CLASS, TREE_OPERAND, and TREE_TYPE.
Referenced by and_comparisons_1(), or_comparisons_1(), same_bool_comparison_p(), and same_bool_result_p().
|
static |
Check to see if two boolean expressions OP1 and OP2 are logically equivalent.
References COMPARISON_CLASS_P, operand_equal_p(), same_bool_comparison_p(), TREE_CODE, and TREE_OPERAND.
Referenced by and_comparisons_1(), and_var_with_comparison_1(), or_comparisons_1(), and or_var_with_comparison_1().
Return TRUE if the SIZE argument, representing the size of an object, is in a range of values of which exactly zero is valid.
References cfun, get_range_query(), integer_zerop(), INTEGRAL_TYPE_P, irange::intersect(), wi::lshift(), wi::one(), path_range_query::range_of_expr(), irange::set_varying(), TREE_CODE, TREE_TYPE, TYPE_PRECISION, vrange::undefined_p(), wi::zero(), and irange::zero_p().
Referenced by gimple_fold_builtin_memory_op().
Return true if TYPE has padding bits aside from those in fields, elements, etc.
References bit_position(), clear_padding_bitint_needs_padding_p(), clear_padding_real_needs_padding_p(), DECL_CHAIN, DECL_PADDING_P, DECL_SIZE, int_const_binop(), simple_cst_equal(), size_zero_node, TREE_CODE, TREE_TYPE, TYPE_FIELDS, and TYPE_SIZE.
Referenced by categorize_ctor_elements_1().
bool update_gimple_call | ( | gimple_stmt_iterator * | si_p, |
tree | fn, | ||
int | nargs, | ||
... ) |
Update a GIMPLE_CALL statement at iterator *SI_P to call to FN with number of arguments NARGS, where the arguments in GIMPLE form follow NARGS argument.
References ap, as_a(), finish_update_gimple_call(), gcc_assert, gimple_build_call_valist(), gsi_stmt(), and is_gimple_call().
Referenced by strlen_pass::handle_builtin_memset(), strlen_pass::handle_builtin_strcat(), strlen_pass::handle_builtin_strcpy(), strlen_pass::handle_builtin_string_cmp(), and instrument_builtin_call().
Return true if EXPR is a CALL_EXPR suitable for representation as a single GIMPLE_CALL statement. If the arguments require further gimplification, return false.
References CALL_EXPR_ARG, call_expr_nargs, i, is_gimple_lvalue(), is_gimple_reg_type(), is_gimple_val(), TREE_CODE, and TREE_TYPE.
Referenced by gimplify_and_update_call_from_tree().
Return true if EXPR is an acceptable right-hand-side for a GIMPLE assignment. We validate the entire tree, not just the root node, thus catching expressions that embed complex operands that are not permitted in GIMPLE. This function is needed because the folding routines in fold-const.cc may return such expressions in some cases, e.g., an array access with an embedded index addition. It may make more sense to have folding routines that are sensitive to the constraints on GIMPLE operands, rather than abandoning any any attempt to fold if the usual folding turns out to be too aggressive.
References CONSTRUCTOR_ELTS, FOR_EACH_CONSTRUCTOR_VALUE, get_gimple_rhs_class(), GIMPLE_TERNARY_RHS, handled_component_p(), i, INTEGRAL_TYPE_P, is_gimple_id(), is_gimple_min_invariant(), is_gimple_val(), is_gimple_variable(), tcc_binary, tcc_comparison, tcc_constant, tcc_declaration, tcc_exceptional, tcc_expression, tcc_reference, tcc_unary, tcc_vl_exp, TREE_CODE, TREE_CODE_CLASS, TREE_OPERAND, TREE_TYPE, TYPE_PRECISION, and VECTOR_TYPE_P.
Referenced by fold_gimple_assign().
Return true if VAR is a VAR_DECL or a component thereof.
References DECL_P, handled_component_p(), TREE_CODE, and TREE_OPERAND.
Referenced by gimple_fold_builtin_memory_op(), and gimple_fold_builtin_memset().
|
static |
Buffer size on which __builtin_clear_padding folding code works.
Referenced by clear_padding_add_padding(), clear_padding_type(), and clear_padding_union().
|
staticconstexpr |
Number of bytes into which any type but aggregate, vector or _BitInt types should fit.
Referenced by clear_padding_flush(), and clear_padding_type().
|
static |
Referenced by follow_outer_ssa_edges(), and maybe_fold_comparisons_from_match_pd().
|
static |
Referenced by follow_outer_ssa_edges(), and maybe_fold_comparisons_from_match_pd().