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 "ssa.h"
#include "cgraph.h"
#include "vec-perm-indices.h"
#include "fold-const.h"
#include "fold-const-call.h"
#include "stor-layout.h"
#include "gimple-iterator.h"
#include "gimple-fold.h"
#include "calls.h"
#include "tree-dfa.h"
#include "builtins.h"
#include "gimple-match.h"
#include "tree-pass.h"
#include "internal-fn.h"
#include "case-cfn-macros.h"
#include "gimplify.h"
#include "optabs-tree.h"
#include "tree-eh.h"
#include "dbgcnt.h"
#include "tm.h"
#include "gimple-range.h"
#include "langhooks.h"
Variables | |
tree(* | mprts_hook )(gimple_match_op *) |
bool associative_binary_op_p | ( | code_helper | code, |
tree | type ) |
Return true if CODE is a binary operation that is associative when operating on type TYPE.
References associated_internal_fn(), associative_binary_fn_p(), associative_tree_code(), and code_helper::is_tree_code().
Referenced by vectorizable_reduction().
|
static |
Try to build RES_OP, which is known to be a call to FN. Return null if the target doesn't support the function.
References cfun, direct_internal_fn_p(), direct_internal_fn_supported_p(), direct_internal_fn_types(), gimple_build_call_internal(), MAX_FIXED_MODE_SIZE, NULL, gimple_match_op::num_ops, gimple_match_op::op_or_null(), gimple_match_op::ops, OPTIMIZE_FOR_BOTH, PROP_gimple_lbitint, TREE_CODE, TREE_TYPE, gimple_match_op::type, and TYPE_PRECISION.
Referenced by maybe_push_res_to_seq().
code_helper canonicalize_code | ( | code_helper | code, |
tree | type ) |
Return a canonical form for CODE when operating on TYPE. The idea is to remove redundant ways of representing the same operation so that code_helpers can be hashed and compared for equality. The only current canonicalization is to replace built-in functions with internal functions, in cases where internal-fn.def defines such an internal function. Note that the new code_helper cannot necessarily be used in place of the original code_helper. For example, the new code_helper might be an internal function that the target does not support.
References associated_internal_fn(), and code_helper::is_fn_code().
Referenced by check_reduction_path(), and vect_transform_reduction().
bool commutative_binary_op_p | ( | code_helper | code, |
tree | type ) |
Return true if CODE is a binary operation and if CODE is commutative when operating on type TYPE.
References associated_internal_fn(), commutative_binary_fn_p(), commutative_tree_code(), and code_helper::is_tree_code().
Referenced by gimple_resimplify2(), vect_transform_reduction(), and vectorizable_reduction().
bool commutative_ternary_op_p | ( | code_helper | code, |
tree | type ) |
Return true if CODE represents a ternary operation and if the first two operands are commutative when CODE is operating on TYPE.
References associated_internal_fn(), commutative_ternary_fn_p(), commutative_ternary_tree_code(), and code_helper::is_tree_code().
Return whether T is a constant that we'll dispatch to fold to evaluate fully constant expressions.
References CONSTANT_CLASS_P, TREE_CODE, and TREE_OPERAND.
Referenced by gimple_resimplify1(), gimple_resimplify2(), gimple_resimplify3(), gimple_simplify(), gimple_simplify(), gimple_simplify(), gimple_simplify(), gimple_simplify(), and gimple_simplify().
|
static |
Try to convert conditional operation ORIG_OP into an IFN_COND_* operation. Return true on success, storing the new operation in NEW_OP.
References as_combined_fn(), as_internal_fn(), gimple_match_cond::bias, gimple_match_op::code, gimple_match_cond::cond, gimple_match_op::cond, gimple_match_cond::else_value, get_conditional_internal_fn(), get_len_internal_fn(), i, internal_fn_p(), code_helper::is_tree_code(), gimple_match_cond::len, gimple_match_op::num_ops, gimple_match_op::ops, gimple_match_op::set_op(), targetm, and gimple_match_op::type.
Referenced by maybe_resimplify_conditional_op().
bool directly_supported_p | ( | code_helper | code, |
tree | otype, | ||
tree | itype, | ||
optab_subtype | query_type ) |
As above, overloading the function for conversion-type optabs.
References associated_internal_fn(), convert_optab_handler(), direct_internal_fn_p(), direct_internal_fn_supported_p(), gcc_assert, code_helper::is_tree_code(), optab_default, optab_for_tree_code(), optab_scalar, optab_vector, OPTIMIZE_FOR_SPEED, TYPE_MODE, unknown_optab, and VECTOR_TYPE_P.
bool directly_supported_p | ( | code_helper | code, |
tree | type, | ||
optab_subtype | query_type ) |
Return true if the target directly supports operation CODE on type TYPE. QUERY_TYPE acts as for optab_for_tree_code.
References associated_internal_fn(), direct_internal_fn_p(), direct_internal_fn_supported_p(), gcc_assert, code_helper::is_tree_code(), optab_default, optab_for_tree_code(), optab_handler(), optab_scalar, optab_vector, OPTIMIZE_FOR_SPEED, TYPE_MODE, unknown_optab, and VECTOR_TYPE_P.
Referenced by vect_build_slp_tree_1(), vect_create_epilog_for_reduction(), vect_find_reusable_accumulator(), vect_is_emulated_mixed_dot_prod(), vect_model_reduction_cost(), vect_supportable_conv_optab_p(), vectorizable_induction(), vectorizable_nonlinear_induction(), and vectorizable_reduction().
Helper for the autogenerated code, valueize OP.
References TREE_CODE.
Helper for gimple_simplify valueizing OP using VALUEIZE and setting VALUEIZED to true if valueization changed OP.
References TREE_CODE.
Referenced by gimple_bitwise_inverted_equal_p(), gimple_simplify(), and object_sizes_execute().
int first_commutative_argument | ( | code_helper | code, |
tree | type ) |
If CODE is commutative in two consecutive operands, return the index of the first, otherwise return -1.
References associated_internal_fn(), commutative_ternary_tree_code(), commutative_tree_code(), first_commutative_argument(), and code_helper::is_tree_code().
Referenced by first_commutative_argument(), fold_stmt_1(), gimple_resimplify3(), gimple_resimplify4(), gimple_resimplify5(), gimple_resimplify6(), gimple_resimplify7(), and vect_get_and_check_slp_defs().
internal_fn get_conditional_internal_fn | ( | code_helper | code, |
tree | type ) |
A wrapper around the internal-fn.cc versions of get_conditional_internal_fn for a code_helper CODE operating on type TYPE.
References associated_internal_fn(), get_conditional_internal_fn(), and code_helper::is_tree_code().
Referenced by convert_conditional_op(), convert_scalar_cond_reduction(), get_conditional_internal_fn(), ifcvt_can_predicate(), predicate_rhs_code(), vect_reduction_update_partial_vector_usage(), vect_transform_reduction(), vectorizable_call(), and vectorizable_operation().
|
inline |
Common subroutine of gimple_extract_op and gimple_simplify. Try to describe STMT in RES_OP, returning true on success. Before recording an operand, call: - VALUEIZE_CONDITION for a COND_EXPR condition - VALUEIZE_OP for every other top-level operand Both routines take a tree argument and returns a tree.
References as_combined_fn(), boolean_type_node, BUILT_IN_NORMAL, DECL_BUILT_IN_CLASS, DECL_FUNCTION_CODE(), gcc_unreachable, gimple_assign_lhs(), gimple_assign_rhs1(), gimple_assign_rhs2(), gimple_assign_rhs3(), gimple_assign_rhs_class(), 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_lhs(), gimple_call_num_args(), gimple_cond_code(), gimple_cond_lhs(), gimple_cond_rhs(), GIMPLE_SINGLE_RHS, GIMPLE_TERNARY_RHS, GIMPLE_UNARY_RHS, i, is_gimple_min_invariant(), NULL_TREE, gimple_match_op::ops, REF_REVERSE_STORAGE_ORDER, gimple_match_op::set_op(), TREE_CODE, TREE_OPERAND, TREE_TYPE, and valueize_op().
Referenced by gimple_extract_op(), and gimple_simplify().
bool gimple_extract_op | ( | gimple * | stmt, |
gimple_match_op * | res_op ) |
Try to describe STMT in RES_OP, returning true on success. For GIMPLE_CONDs, describe the condition that is being tested. For GIMPLE_ASSIGNs, describe the rhs of the assignment. For GIMPLE_CALLs, describe the call.
References gimple_extract().
Referenced by check_reduction_path(), factor_out_conditional_operation(), vect_is_simple_reduction(), vect_mark_pattern_stmts(), vect_model_reduction_cost(), vect_transform_reduction(), and vectorizable_reduction().
|
static |
Forward declarations of the private auto-generated matchers. They expect valueized operands in canonical order and do not perform simplification of all-constant operands.
Helper that matches and simplifies the toplevel result from a gimple_simplify run (where we don't want to build a stmt in case it's used in in-place folding). Replaces RES_OP with a simplified and/or canonicalized result and returns whether any change was made.
References gimple_match_op::code, const_unop(), CONSTANT_CLASS_P, constant_for_folding(), drop_tree_overflow(), dump_file, dump_flags, fold_const_call(), gimple_simplify(), IS_EXPR_CODE_CLASS, code_helper::is_tree_code(), maybe_resimplify_conditional_op(), NULL_TREE, gimple_match_op::ops, gimple_match_op::set_value(), TDF_FOLDING, TREE_CODE_CLASS, TREE_CODE_LENGTH, TREE_OVERFLOW_P, and gimple_match_op::type.
Referenced by gimple_match_op::resimplify(), and try_conditional_simplification().
|
static |
Helper that matches and simplifies the toplevel result from a gimple_simplify run (where we don't want to build a stmt in case it's used in in-place folding). Replaces RES_OP with a simplified and/or canonicalized result and returns whether any change was made.
References gimple_match_op::code, commutative_binary_op_p(), const_binop(), CONSTANT_CLASS_P, constant_for_folding(), drop_tree_overflow(), dump_file, dump_flags, fold_const_call(), gimple_simplify(), IS_EXPR_CODE_CLASS, code_helper::is_tree_code(), maybe_resimplify_conditional_op(), NULL_TREE, gimple_match_op::ops, gimple_match_op::set_value(), swap_tree_comparison(), tcc_comparison, TDF_FOLDING, TREE_CODE_CLASS, TREE_CODE_LENGTH, TREE_OVERFLOW_P, tree_swap_operands_p(), and gimple_match_op::type.
Referenced by gimple_simplify(), gimple_match_op::resimplify(), and try_conditional_simplification().
|
static |
Helper that matches and simplifies the toplevel result from a gimple_simplify run (where we don't want to build a stmt in case it's used in in-place folding). Replaces RES_OP with a simplified and/or canonicalized result and returns whether any change was made.
References gimple_match_op::code, CONSTANT_CLASS_P, constant_for_folding(), drop_tree_overflow(), dump_file, dump_flags, first_commutative_argument(), fold_const_call(), fold_ternary, gimple_simplify(), IS_EXPR_CODE_CLASS, code_helper::is_tree_code(), maybe_resimplify_conditional_op(), NULL_TREE, gimple_match_op::ops, gimple_match_op::set_value(), TDF_FOLDING, TREE_CODE_CLASS, TREE_CODE_LENGTH, TREE_OVERFLOW_P, tree_swap_operands_p(), and gimple_match_op::type.
Referenced by maybe_resimplify_conditional_op(), gimple_match_op::resimplify(), and try_conditional_simplification().
|
static |
Helper that matches and simplifies the toplevel result from a gimple_simplify run (where we don't want to build a stmt in case it's used in in-place folding). Replaces RES_OP with a simplified and/or canonicalized result and returns whether any change was made.
References gimple_match_op::code, dump_file, dump_flags, first_commutative_argument(), gimple_simplify(), maybe_resimplify_conditional_op(), gimple_match_op::ops, TDF_FOLDING, tree_swap_operands_p(), and gimple_match_op::type.
Referenced by gimple_match_op::resimplify().
|
static |
Helper that matches and simplifies the toplevel result from a gimple_simplify run (where we don't want to build a stmt in case it's used in in-place folding). Replaces RES_OP with a simplified and/or canonicalized result and returns whether any change was made.
References gimple_match_op::code, first_commutative_argument(), gimple_simplify(), maybe_resimplify_conditional_op(), gimple_match_op::ops, tree_swap_operands_p(), and gimple_match_op::type.
Referenced by gimple_match_op::resimplify().
|
static |
Helper that matches and simplifies the toplevel result from a gimple_simplify run (where we don't want to build a stmt in case it's used in in-place folding). Replaces RES_OP with a simplified and/or canonicalized result and returns whether any change was made.
References gimple_match_op::code, first_commutative_argument(), gimple_simplify(), maybe_resimplify_conditional_op(), gimple_match_op::ops, tree_swap_operands_p(), and gimple_match_op::type.
Referenced by gimple_match_op::resimplify().
|
static |
Helper that matches and simplifies the toplevel result from a gimple_simplify run (where we don't want to build a stmt in case it's used in in-place folding). Replaces RES_OP with a simplified and/or canonicalized result and returns whether any change was made.
References gimple_match_op::code, first_commutative_argument(), gimple_simplify(), maybe_resimplify_conditional_op(), gimple_match_op::ops, tree_swap_operands_p(), and gimple_match_op::type.
Referenced by gimple_match_op::resimplify().
tree gimple_simplify | ( | combined_fn | fn, |
tree | type, | ||
tree | arg0, | ||
gimple_seq * | seq, | ||
tree(* | valueize )(tree) ) |
Builtin or internal function with one argument.
References CONSTANT_CLASS_P, constant_for_folding(), fold_const_call(), gimple_simplify(), maybe_push_res_to_seq(), and NULL_TREE.
tree gimple_simplify | ( | combined_fn | fn, |
tree | type, | ||
tree | arg0, | ||
tree | arg1, | ||
gimple_seq * | seq, | ||
tree(* | valueize )(tree) ) |
Builtin or internal function with two arguments.
References CONSTANT_CLASS_P, constant_for_folding(), fold_const_call(), gimple_simplify(), maybe_push_res_to_seq(), and NULL_TREE.
tree gimple_simplify | ( | combined_fn | fn, |
tree | type, | ||
tree | arg0, | ||
tree | arg1, | ||
tree | arg2, | ||
gimple_seq * | seq, | ||
tree(* | valueize )(tree) ) |
Builtin or internal function with three arguments.
References CONSTANT_CLASS_P, constant_for_folding(), fold_const_call(), gimple_simplify(), maybe_push_res_to_seq(), and NULL_TREE.
tree gimple_simplify | ( | enum tree_code | code, |
tree | type, | ||
tree | op0, | ||
gimple_seq * | seq, | ||
tree(* | valueize )(tree) ) |
Functions that are needed by gimple-match but that are exported and used in other places in the compiler.
Public API overloads follow for operation being tree_code or built_in_function and for one to three operands or arguments. They return NULL_TREE if nothing could be simplified or the resulting simplified value with parts pushed to SEQ. If SEQ is NULL then if the simplification needs to create new stmts it will fail. If VALUEIZE is non-NULL then all SSA names will be valueized using that hook prior to applying simplifications.
Unary ops.
References const_unop(), CONSTANT_CLASS_P, constant_for_folding(), gimple_simplify(), maybe_push_res_to_seq(), and NULL_TREE.
Referenced by cleanup_control_expr_graph(), fold_stmt_1(), gimple_build(), gimple_build(), gimple_build(), gimple_build(), gimple_build(), gimple_build(), gimple_fold_stmt_to_constant_1(), gimple_resimplify1(), gimple_resimplify2(), gimple_resimplify3(), gimple_resimplify4(), gimple_resimplify5(), gimple_resimplify6(), gimple_resimplify7(), gimple_simplify(), gimple_simplify(), gimple_simplify(), gimple_simplify(), gimple_simplify(), gimple_simplify(), and process_bb().
tree gimple_simplify | ( | enum tree_code | code, |
tree | type, | ||
tree | op0, | ||
tree | op1, | ||
tree | op2, | ||
gimple_seq * | seq, | ||
tree(* | valueize )(tree) ) |
Ternary ops.
References commutative_ternary_tree_code(), CONSTANT_CLASS_P, constant_for_folding(), fold_ternary, gimple_simplify(), maybe_push_res_to_seq(), NULL_TREE, and tree_swap_operands_p().
bool gimple_simplify | ( | gimple * | stmt, |
gimple_match_op * | res_op, | ||
gimple_seq * | seq, | ||
tree(* | valueize )(tree), | ||
tree(* | top_valueize )(tree) ) |
The main STMT based simplification entry. It is used by the fold_stmt and the fold_stmt_to_constant APIs.
References build2(), gimple_match_op::code, gimple_match_op::cond, do_valueize(), gimple_extract(), gimple_resimplify2(), code_helper::is_internal_fn(), code_helper::is_tree_code(), gimple_match_op::num_ops, gimple_match_op::ops, gimple_match_op::resimplify(), gimple_match_op::reverse, tcc_comparison, TREE_CODE, TREE_CODE_CLASS, TREE_OPERAND, TREE_TYPE, try_conditional_simplification(), and valueize_op().
|
extern |
|
extern |
|
extern |
|
extern |
|
extern |
|
extern |
|
extern |
void maybe_build_generic_op | ( | gimple_match_op * | res_op | ) |
If in GIMPLE the operation described by RES_OP should be single-rhs, build a GENERIC tree for that expression and update RES_OP accordingly.
References build1(), build3(), gimple_match_op::code, gimple_match_op::ops, REF_REVERSE_STORAGE_ORDER, gimple_match_op::reverse, gimple_match_op::set_value(), and gimple_match_op::type.
Referenced by maybe_push_res_to_seq(), and replace_stmt_with_simplification().
tree maybe_push_res_to_seq | ( | gimple_match_op * | res_op, |
gimple_seq * | seq, | ||
tree | res ) |
Push the exploded expression described by RES_OP as a statement to SEQ if necessary and return a gimple value denoting the value of the expression. If RES is not NULL then the result will be always RES and even gimple values are pushed to SEQ.
References as_builtin_fn(), as_internal_fn(), build_call_internal(), builtin_decl_implicit(), cfun, gimple_match_op::code, gimple_match_cond::cond, gimple_match_op::cond, create_tmp_reg(), ECF_CONST, flags_from_decl_or_type(), gcc_assert, gimple_build_assign(), gimple_build_call(), gimple_call_set_lhs(), gimple_in_ssa_p(), gimple_seq_add_stmt_without_update(), gimple_simplified_result_is_gimple_val(), i, internal_fn_flags(), internal_fn_p(), code_helper::is_tree_code(), make_ssa_name(), maybe_build_generic_op(), mprts_hook, NULL, NULL_TREE, gimple_match_op::num_ops, gimple_match_op::op_or_null(), gimple_match_op::ops, SSA_NAME_OCCURS_IN_ABNORMAL_PHI, TREE_CODE, and gimple_match_op::type.
Referenced by factor_out_conditional_operation(), gimple_simplify(), gimple_simplify(), gimple_simplify(), gimple_simplify(), gimple_simplify(), gimple_simplify(), gimple_simplify_phiopt(), replace_stmt_with_simplification(), tree_vec_extract(), and vn_nary_build_or_lookup_1().
|
static |
RES_OP is the result of a simplification. If it is conditional, try to replace it with the equivalent UNCOND form, such as an IFN_COND_* call or a VEC_COND_EXPR. Also try to resimplify the result of the replacement if appropriate, adding any new statements to SEQ and using VALUEIZE as the valueization function. Return true if this resimplification occurred and resulted in at least one change.
References gimple_match_cond::bias, gimple_match_op::code, gimple_match_cond::cond, gimple_match_op::cond, convert_conditional_op(), gimple_match_cond::else_value, FLOAT_TYPE_P, generic_expr_could_trap_p(), gimple_resimplify3(), gimple_simplified_result_is_gimple_val(), INTEGRAL_TYPE_P, code_helper::is_tree_code(), gimple_match_cond::len, NULL_TREE, gimple_match_op::op_or_null(), operation_could_trap_p(), gimple_match_op::ops, gimple_match_op::set_op(), gimple_match_op::type, TYPE_OVERFLOW_TRAPS, and VECTOR_TYPE_P.
Referenced by gimple_resimplify1(), gimple_resimplify2(), gimple_resimplify3(), gimple_resimplify4(), gimple_resimplify5(), gimple_resimplify6(), gimple_resimplify7(), and try_conditional_simplification().
|
static |
If RES_OP is a call to a conditional internal function, try simplifying the associated unconditional operation and using the result to build a new conditional operation. For example, if RES_OP is: IFN_COND_ADD (COND, A, B, ELSE) try simplifying (plus A B) and using the result to build a replacement for the whole IFN_COND_ADD. Return true if this approach led to a simplification, otherwise leave RES_OP unchanged (and so suitable for other simplifications). When returning true, add any new statements to SEQ and use VALUEIZE as the valueization function. RES_OP is known to be a call to IFN.
References as_combined_fn(), conditional_internal_fn_code(), gcc_unreachable, get_unconditional_internal_fn(), gimple_resimplify1(), gimple_resimplify2(), gimple_resimplify3(), internal_fn_len_index(), maybe_resimplify_conditional_op(), NULL_TREE, gimple_match_op::num_ops, gimple_match_op::ops, and gimple_match_op::type.
Referenced by gimple_simplify().
tree(* mprts_hook) (gimple_match_op *) | ( | gimple_match_op * | ) |
Helpers for the autogenerated gimple-match.cc file. Copyright (C) 2023-2025 Free Software Foundation, Inc. This file is part of GCC. GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GCC; see the file COPYING3. If not see <http://www.gnu.org/licenses/>.
Referenced by gimple_fold_stmt_to_constant_1(), maybe_push_res_to_seq(), try_to_simplify(), vn_lookup_simplify_result(), and vn_nary_build_or_lookup_1().