GCC Middle and Back End API Reference
|
|
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(), CDI_DOMINATORS, combine_comparisons(), dom_info_available_p(), dominated_by_p(), gimple_phi_arg_def(), gimple_phi_num_args(), gimple_phi_result(), integer_nonzerop(), integer_onep(), integer_zerop(), operand_equal_p(), same_bool_comparison_p(), same_bool_result_p(), swap_tree_comparison(), tree_int_cst_compare(), and truth_type_for().
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(), and or_var_with_comparison_1().
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(), 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(), same_bool_result_p(), and tcc_comparison.
Referenced by and_var_with_comparison(), and or_var_with_comparison().
|
static |
@verbatim Statement simplification on GIMPLE.
Copyright (C) 2010-2013 Free Software Foundation, Inc. Split out from tree-ssa-ccp.c.
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/.
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 copmilation 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 cgraph_function_flags_ready, cgraph_get_node(), symtab_node_base::definition, cgraph_node::global, cgraph_global_info::inlined_to, cgraph_node::symbol, varpool_node::symbol, symtab_get_node(), and varpool_get_node().
Referenced by canonicalize_constructor_val(), and gimple_get_virt_method_for_binfo().
|
static |
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 build_int_cst(), integer_nonzerop(), integer_zerop(), invert_tree_comparison(), and tcc_comparison.
Referenced by and_var_with_comparison(), and or_var_with_comparison().
tree canonicalize_constructor_val | ( | ) |
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 can_refer_decl_in_current_unit_p(), cgraph_get_create_real_symbol_node(), get_base_address(), is_gimple_min_invariant(), and useless_type_conversion_p().
Referenced by fold_ctor_reference(), get_symbol_constant_value(), ipa_make_edge_direct_to_target(), and record_reference().
|
static |
CTOR is CONSTRUCTOR of an array type. Fold reference of type TYPE and size SIZE to the memory at bit OFFSET.
References build_zero_cst(), double_int::cmp(), double_int::ext(), fold_ctor_reference(), double_int::from_uhwi(), HOST_WIDE_INT, double_int::slt(), double_int::to_uhwi(), tree_to_double_int(), and double_int::udiv().
Referenced by fold_ctor_reference().
tree fold_const_aggregate_ref | ( | ) |
References fold_const_aggregate_ref_1().
Referenced by 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(), double_int::fits_shwi(), 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(), host_integerp(), HOST_WIDE_INT, offset, tcc_declaration, and double_int::to_shwi().
Referenced by fold_const_aggregate_ref(), fold_const_aggregate_ref_1(), and gimple_fold_stmt_to_constant_1().
|
static |
The following set of functions are supposed to fold references using their constant initializers.
CTOR is value initializing memory, fold reference of type TYPE and size SIZE to the memory at bit OFFSET.
References canonicalize_constructor_val(), fold_array_ctor_reference(), fold_nonarray_ctor_reference(), fold_string_cst_ctor_reference(), operand_equal_p(), unshare_expr(), and useless_type_conversion_p().
Referenced by fold_array_ctor_reference(), fold_const_aggregate_ref_1(), fold_nonarray_ctor_reference(), and gimple_get_virt_method_for_binfo().
|
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 build_fold_addr_expr_loc(), build_int_cst(), build_vector_from_ctor(), fold(), fold_binary_loc(), fold_defer_overflow_warnings(), fold_ternary_loc(), fold_unary_loc(), fold_undefer_overflow_warnings(), 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_expr_type(), GIMPLE_INVALID_RHS, gimple_location(), GIMPLE_SINGLE_RHS, GIMPLE_TERNARY_RHS, GIMPLE_UNARY_RHS, gsi_stmt(), integer_onep(), integer_zerop(), is_gimple_condexpr(), is_gimple_min_invariant(), maybe_fold_reference(), useless_type_conversion_p(), and valid_gimple_rhs_p().
Referenced by fold_stmt_1().
|
static |
Attempt to fold a conditional statement. Return true if any changes were made. We only attempt to fold the condition expression, and do not perform any transformation that would require alteration of the cfg. It is assumed that the operands have been previously folded.
References fold_binary_loc(), gimple_cond_code(), gimple_cond_lhs(), gimple_cond_rhs(), gimple_cond_set_condition_from_tree(), gimple_location(), is_gimple_condexpr(), and valid_gimple_rhs_p().
Referenced by fold_stmt_1().
|
static |
CTOR is CONSTRUCTOR of an aggregate or vector. Fold reference of type TYPE and size SIZE to the memory at bit OFFSET.
References build_zero_cst(), double_int::cmp(), fold_ctor_reference(), double_int::from_uhwi(), HOST_WIDE_INT, double_int::slt(), double_int::to_uhwi(), and tree_to_double_int().
Referenced by fold_ctor_reference().
bool fold_stmt | ( | ) |
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().
Referenced by fold_marked_statements(), forward_propagate_into_comparison(), gimplify_call_expr(), gimplify_modify_expr(), optimize_stmt(), replace_uses_by(), simplify_bitfield_ref(), and substitute_and_fold().
|
static |
Worker for both fold_stmt and fold_stmt_inplace. The INPLACE argument distinguishes both cases.
References changed, commutative_ternary_tree_code(), commutative_tree_code(), fold_gimple_assign(), fold_gimple_cond(), get_gimple_rhs_num_ops(), gimple_asm_input_op(), gimple_asm_ninputs(), gimple_asm_noutputs(), gimple_asm_output_op(), gimple_assign_lhs(), gimple_assign_rhs1(), gimple_assign_rhs2(), gimple_assign_rhs_code(), gimple_assign_set_rhs1(), gimple_assign_set_rhs2(), gimple_assign_set_rhs_from_tree(), gimple_debug_bind_get_value(), gimple_debug_bind_p(), gimple_debug_bind_set_value(), gimple_fold_call(), gimple_get_lhs(), gimple_has_lhs(), gimple_num_ops(), gimple_set_lhs(), gsi_stmt(), maybe_fold_reference(), parse_input_constraint(), tree_swap_operands_p(), and useless_type_conversion_p().
Referenced by fold_stmt(), and fold_stmt_inplace().
bool fold_stmt_inplace | ( | ) |
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(), and gsi_stmt().
Referenced by associate_plusminus(), associate_pointerplus(), create_expression_by_pieces(), execute_cse_reciprocals(), forward_propagate_addr_expr_1(), graphite_copy_stmts_from_block(), insert_debug_temp_for_var_def(), propagate_into_all_uses(), propagate_rhs_into_lhs(), replace_reciprocal(), and ssa_forward_propagate_and_combine().
|
static |
CTOR is STRING_CST. Fold reference of type TYPE and size SIZE to the memory at bit OFFSET. We do only simple job of folding byte accesses.
References build_int_cst_type(), build_zero_cst(), and HOST_WIDE_INT.
Referenced by fold_ctor_reference().
|
static |
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 ctor_for_folding(), get_ref_base_and_extent(), host_integerp(), HOST_WIDE_INT, integer_zerop(), double_int::low, and mem_ref_offset().
Referenced by fold_const_aggregate_ref_1().
|
static |
Return the string length, maximum string length or maximum value of ARG in LENGTH. If ARG is an SSA name variable, follow its use-def chains. If LENGTH is not NULL and, for TYPE == 0, its value is not equal to the length we determine or if we are unable to determine the length or value, return false. VISITED is a bitmap of visited variables. TYPE is 0 if string length should be returned, 1 for maximum string length and 2 for maximum value ARG can have.
References bitmap_set_bit(), c_strlen(), phi_arg_d::def, 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(), integer_zerop(), name_registered_for_update_p(), simple_cst_equal(), tree_int_cst_lt(), and tree_int_cst_sgn().
Referenced by gimple_fold_builtin().
tree get_symbol_constant_value | ( | ) |
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(), is_gimple_min_invariant(), and unshare_expr().
Referenced by fold_const_aggregate_ref_1(), fold_gimple_assign(), get_default_value(), and gimple_fold_stmt_to_constant_1().
tree gimple_extract_devirt_binfo_from_cst | ( | ) |
Return a binfo to be used for devirtualization of calls based on an object represented by a declaration (i.e. a global or automatically allocated one) or NULL if it cannot be found or is not safe. CST is expected to be an ADDR_EXPR of such object or the function will return NULL. Currently it is safe to use such binfo only if it has no base binfo (i.e. no ancestors) EXPECTED_TYPE is type of the class virtual belongs to.
References get_ref_base_and_extent(), HOST_WIDE_INT, int_bit_position(), offset, tree_low_cst(), type(), and types_same_for_odr().
Referenced by gimple_fold_call(), ipa_get_indirect_edge_target_1(), and try_make_edge_direct_virtual_call().
tree gimple_fold_builtin | ( | ) |
Fold builtin call in statement STMT. Returns a simplified tree. We may return a non-constant expression, including another call to a different function and with different arguments, e.g., substituting memcpy for strcpy when the string length is known. Note that some builtins expand into inline code that may not be valid in GIMPLE. Callers must take care.
References avoid_folding_inline_builtin(), bitmap_clear(), BUILT_IN_MD, fold_builtin_fputs(), fold_builtin_memory_chk(), fold_builtin_strcpy(), fold_builtin_strncpy(), fold_builtin_stxcpy_chk(), fold_builtin_stxncpy_chk(), fold_call_stmt(), fold_ignored_result(), get_maxval_strlen(), gimple_call_arg(), gimple_call_fndecl(), gimple_call_lhs(), gimple_call_num_args(), gimple_fold_builtin_snprintf_chk(), gimple_location(), is_gimple_call(), is_gimple_val(), memset(), type(), and visited.
Referenced by execute_fold_all_builtins(), and gimple_fold_call().
|
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 BUILT_IN_MD, changed, gimple_call_addr_fndecl(), gimple_call_arg(), gimple_call_fn(), gimple_call_fndecl(), gimple_call_num_args(), gimple_call_set_arg(), gimple_call_set_fn(), gimple_call_set_fndecl(), gimple_extract_devirt_binfo_from_cst(), gimple_fold_builtin(), gimple_get_virt_method_for_binfo(), gimplify_and_update_call_from_tree(), gsi_stmt(), HOST_WIDE_INT, maybe_fold_reference(), obj_type_ref_class(), targetm, update_call_from_tree(), and virtual_method_call_p().
Referenced by fold_stmt_1().
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(), and is_gimple_min_invariant().
Referenced by vrp_visit_assignment_or_call().
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 build_call_array_loc(), build_fold_addr_expr_loc(), build_invariant_address(), decl_address_invariant_p(), fold_binary_loc(), fold_call_expr(), fold_const_aggregate_ref_1(), fold_ternary_loc(), fold_unary_ignore_overflow_loc(), fold_unary_loc(), 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_call_arg(), gimple_call_fn(), gimple_call_internal_p(), gimple_call_num_args(), gimple_call_return_type(), gimple_expr_type(), gimple_location(), GIMPLE_SINGLE_RHS, GIMPLE_TERNARY_RHS, GIMPLE_UNARY_RHS, HOST_WIDE_INT, is_gimple_min_invariant(), offset, tcc_declaration, tcc_reference, and unshare_expr().
Referenced by ccp_fold(), gimple_fold_stmt_to_constant(), and try_to_simplify().
tree gimple_get_virt_method_for_binfo | ( | ) |
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).
References can_refer_decl_in_current_unit_p(), cgraph_get_create_node(), ctor_for_folding(), fold_ctor_reference(), HOST_WIDE_INT, integer_zerop(), offset, and tree_low_cst().
Referenced by gimple_fold_call(), ipa_get_indirect_edge_target_1(), ipa_intraprocedural_devirtualization(), possible_polymorphic_call_targets(), record_binfo(), and try_make_edge_direct_virtual_call().
bool gimple_val_nonnegative_real_p | ( | ) |
Return true iff VAL is a gimple expression that is known to be non-negative. Restricted to floating-point inputs.
References BUILT_IN_NORMAL, gimple_assign_rhs1(), gimple_assign_rhs2(), gimple_assign_rhs_code(), gimple_call_arg(), gimple_call_fndecl(), HOST_WIDE_INT, is_gimple_assign(), is_gimple_call(), operand_equal_p(), real_from_integer(), real_identical(), real_to_integer(), and tree_expr_nonnegative_p().
Referenced by gimple_expand_builtin_pow().
void gimplify_and_update_call_from_tree | ( | ) |
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 annotate_all_with_location(), cfun, get_initialized_tmp_var(), gimple_assign_lhs(), gimple_assign_single_p(), gimple_build_nop(), gimple_call_flags(), gimple_call_lhs(), gimple_has_location(), gimple_has_mem_ops(), gimple_in_ssa_p(), gimple_location(), gimple_seq_empty_p(), gimple_set_modified(), gimple_set_vdef(), gimple_set_vuse(), gimple_vdef(), gimple_vop(), gimple_vuse(), gimplify_and_add(), GSI_CONTINUE_LINKING, gsi_end_p(), gsi_insert_after_without_update(), gsi_next(), gsi_prev(), gsi_replace(), gsi_replace_with_seq(), gsi_stmt(), gimplify_ctx::into_ssa, is_gimple_call(), is_gimple_reg(), make_ssa_name(), pop_gimplify_context(), push_gimplify_context(), release_defs(), release_ssa_name(), and unlink_stmt_vdef().
Referenced by execute_fold_all_builtins(), gimple_fold_call(), handle_builtin_strchr(), and handle_builtin_strlen().
tree maybe_fold_and_comparisons | ( | enum tree_code | code1, |
tree | op1a, | ||
tree | op1b, | ||
enum tree_code | code2, | ||
tree | op2a, | ||
tree | op2b | ||
) |
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().
Referenced by and_var_with_comparison_1(), eliminate_redundant_comparison(), and ifcombine_ifandif().
tree maybe_fold_or_comparisons | ( | enum tree_code | code1, |
tree | op1a, | ||
tree | op1b, | ||
enum tree_code | code2, | ||
tree | op2a, | ||
tree | op2b | ||
) |
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 or_comparisons_1().
Referenced by eliminate_redundant_comparison(), fold_or_predicates(), and or_var_with_comparison_1().
|
static |
Subroutine of fold_stmt. We perform several simplifications of the memory reference tree EXPR and make sure to re-gimplify them properly after propagation of constant addresses. IS_LHS is true if the reference is supposed to be an lvalue.
References fold_const_aggregate_ref(), fold_ternary_loc(), fold_unary_loc(), handled_component_p(), integer_zerop(), is_gimple_mem_ref_addr(), is_gimple_min_invariant(), maybe_fold_tmr(), and types_compatible_p().
Referenced by fold_gimple_assign(), fold_stmt_1(), and gimple_fold_call().
|
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 CDI_DOMINATORS, combine_comparisons(), dom_info_available_p(), dominated_by_p(), gimple_phi_arg_def(), gimple_phi_num_args(), gimple_phi_result(), integer_nonzerop(), integer_onep(), integer_zerop(), operand_equal_p(), or_var_with_comparison(), same_bool_comparison_p(), same_bool_result_p(), swap_tree_comparison(), tree_int_cst_compare(), and truth_type_for().
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(), and or_var_with_comparison_1().
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 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(), or_comparisons_1(), or_var_with_comparison(), same_bool_result_p(), and tcc_comparison.
Referenced by and_var_with_comparison(), and or_var_with_comparison().
|
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(), and tcc_comparison.
Referenced by and_comparisons_1(), or_comparisons_1(), and same_bool_result_p().
|
static |
Check to see if two boolean expressions OP1 and OP2 are logically equivalent.
References operand_equal_p(), same_bool_comparison_p(), and tcc_comparison.
Referenced by and_comparisons_1(), and_var_with_comparison_1(), or_comparisons_1(), and or_var_with_comparison_1().