GCC Middle and Back End API Reference
optabs-tree.h File Reference
#include "optabs-query.h"
Include dependency graph for optabs-tree.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Enumerations

enum  optab_subtype { optab_default , optab_scalar , optab_vector , optab_vector_mixed_sign }
 

Functions

optab optab_for_tree_code (enum tree_code, const_tree, enum optab_subtype)
 
bool supportable_half_widening_operation (enum tree_code, tree, tree, enum tree_code *)
 
bool supportable_convert_operation (enum tree_code, tree, tree, enum tree_code *)
 
bool expand_vec_cmp_expr_p (tree, tree, enum tree_code)
 
bool expand_vec_cond_expr_p (tree, tree)
 
void init_tree_optimization_optabs (tree)
 
bool target_supports_op_p (tree, enum tree_code, enum optab_subtype=optab_default)
 
bool target_supports_mask_load_store_p (machine_mode, machine_mode, bool, internal_fn *, vec< int > *)
 
bool can_vec_mask_load_store_p (machine_mode, machine_mode, bool, internal_fn *=nullptr, vec< int > *=nullptr)
 
opt_machine_mode get_len_load_store_mode (machine_mode, bool, internal_fn *=nullptr, vec< int > *=nullptr)
 

Enumeration Type Documentation

◆ optab_subtype

Tree-based target query functions relating to optabs
   Copyright (C) 2001-2024 Free Software Foundation, Inc.

This file is part of GCC.

GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.

GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3.  If not see
<http://www.gnu.org/licenses/>.   
An extra flag to control optab_for_tree_code's behavior.  This is needed to
distinguish between machines with a vector shift that takes a scalar for the
shift amount vs. machines that take a vector for the shift amount.   
Enumerator
optab_default 
optab_scalar 
optab_vector 
optab_vector_mixed_sign 

Function Documentation

◆ can_vec_mask_load_store_p()

bool can_vec_mask_load_store_p ( machine_mode mode,
machine_mode mask_mode,
bool is_load,
internal_fn * ifn,
vec< int > * elsvals )
Return true if target supports vector masked load/store for mode.
An additional output in the last argument which is the IFN pointer.
We set IFN as MASK_{LOAD,STORE} or MASK_LEN_{LOAD,STORE} according
which optab is supported in the target.
If there is support and ELSVALS is nonzero store the possible else values
in the vector it points to.   

References opt_mode< T >::exists(), is_a(), related_vector_mode(), target_supports_mask_load_store_p(), targetm, and VECTOR_MODE_P.

Referenced by check_load_store_for_partial_vectors(), ifcvt_can_use_mask_load_store(), vect_recog_cond_store_pattern(), vectorizable_load(), and vectorizable_store().

◆ expand_vec_cmp_expr_p()

bool expand_vec_cmp_expr_p ( tree value_type,
tree mask_type,
enum tree_code code )
Return TRUE if appropriate vector insn is available
for vector comparison expr with vector type VALUE_TYPE
and resulting mask with MASK_TYPE.   

References vec_cmp_eq_icode_p(), and vec_cmp_icode_p().

Referenced by do_store_flag(), expand_vector_comparison(), expand_vector_divmod(), gimple_expand_vec_cond_expr(), vect_determine_mask_precision(), vect_verify_full_masking_avx512(), vectorizable_comparison_1(), and vectorizable_condition().

◆ expand_vec_cond_expr_p()

bool expand_vec_cond_expr_p ( tree value_type,
tree cmp_op_type )
Return TRUE iff, appropriate vector insns are available
for vector cond expr with vector type VALUE_TYPE and a comparison
with operand vector types in CMP_OP_TYPE.   

References get_vcond_mask_icode(), TYPE_MODE, and VECTOR_BOOLEAN_TYPE_P.

Referenced by expand_vector_condition(), expand_vector_divmod(), scan_store_can_perm_p(), vect_reduction_update_partial_vector_usage(), vectorizable_condition(), vectorizable_load(), and vectorizable_simd_clone_call().

◆ get_len_load_store_mode()

opt_machine_mode get_len_load_store_mode ( machine_mode mode,
bool is_load,
internal_fn * ifn,
vec< int > * elsvals )
If target supports vector load/store with length for vector mode MODE,
return the corresponding vector mode, otherwise return opt_machine_mode ().
There are two flavors for vector load/store with length, one is to measure
length with bytes, the other is to measure length with lanes.
As len_{load,store} optabs point out, for the flavor with bytes, we use
VnQI to wrap the other supportable same size vector modes.
An additional output in the last argument which is the IFN pointer.
We set IFN as LEN_{LOAD,STORE} or MASK_LEN_{LOAD,STORE} according
which optab is supported in the target.
If there is support and ELSVALS is nonzero store the possible else values
in the vector it points to.   

References gcc_assert, GET_MODE_SIZE(), related_vector_mode(), target_supports_len_load_store_p(), and VECTOR_MODE_P.

Referenced by check_load_store_for_partial_vectors(), vect_verify_loop_lens(), vectorizable_load(), and vectorizable_store().

◆ init_tree_optimization_optabs()

void init_tree_optimization_optabs ( tree optnode)
Use the current target and options to initialize
TREE_OPTIMIZATION_OPTABS (OPTNODE).   

References ggc_cleared_alloc(), ggc_free(), NULL, TREE_OPTIMIZATION_BASE_OPTABS, and TREE_OPTIMIZATION_OPTABS.

Referenced by invoke_set_current_function_hook().

◆ optab_for_tree_code()

optab optab_for_tree_code ( enum tree_code code,
const_tree type,
enum optab_subtype subtype )
Return the optab used for computing the given operation on the type given by
the second argument.  The third argument distinguishes between the types of
vector shifts and rotates.   
Tree-based target query functions relating to optabs
   Copyright (C) 1987-2024 Free Software Foundation, Inc.

This file is part of GCC.

GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.

GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
for more details.

You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3.  If not see
<http://www.gnu.org/licenses/>.   
Return the optab used for computing the operation given by the tree code,
CODE and the tree EXP.  This function is not always usable (for example, it
cannot give complete results for multiplication or division) but probably
ought to be relied on more widely throughout the expander.   

References gcc_assert, INTEGRAL_TYPE_P, optab_scalar, optab_vector, optab_vector_mixed_sign, TYPE_OVERFLOW_TRAPS, TYPE_SATURATING, TYPE_UNSIGNED, unknown_optab, and VECTOR_TYPE_P.

Referenced by add_rshift(), check_scan_store(), convert_plusminus_to_widen(), directly_supported_p(), directly_supported_p(), expand_expr_real_2(), expand_vector_conversion(), expand_vector_divmod(), expand_vector_operations_1(), expand_vector_ubsan_overflow(), expand_widen_pattern_expr(), optimize_vector_constructor(), simplify_vector_constructor(), supportable_half_widening_operation(), supportable_narrowing_operation(), supportable_widening_operation(), target_has_vecop_for_code(), target_supports_op_p(), undistribute_bitref_for_vector(), vect_recog_average_pattern(), vect_recog_divmod_pattern(), vect_recog_mult_pattern(), vect_recog_rotate_pattern(), vect_supportable_direct_optab_p(), vect_supportable_shift(), vectorizable_comparison_1(), vectorizable_condition(), vectorizable_operation(), and vectorizable_shift().

◆ supportable_convert_operation()

bool supportable_convert_operation ( enum tree_code code,
tree vectype_out,
tree vectype_in,
enum tree_code * code1 )
Function supportable_convert_operation

Check whether an operation represented by the code CODE is a
convert operation that is supported by the target platform in
vector form (i.e., when operating on arguments of type VECTYPE_IN
producing a result of type VECTYPE_OUT).

Convert operations we currently support directly are FIX_TRUNC and FLOAT.
This function checks if these operations are supported
by the target platform directly (via vector tree-codes).

Output:
- CODE1 is code of vector operation to be used when
vectorizing the operation, if available.   

References can_extend_p(), can_fix_p(), can_float_p(), convert_optab_handler(), gcc_assert, GET_MODE_UNIT_PRECISION, TYPE_MODE, TYPE_UNSIGNED, VECTOR_MODE_P, and VECTOR_TYPE_P.

Referenced by expand_vector_conversion(), simplify_vector_constructor(), supportable_half_widening_operation(), supportable_indirect_convert_operation(), and vectorizable_conversion().

◆ supportable_half_widening_operation()

bool supportable_half_widening_operation ( enum tree_code code,
tree vectype_out,
tree vectype_in,
enum tree_code * code1 )
Check whether an operation represented by CODE is a 'half' widening operation
in which the input vector type has half the number of bits of the output
vector type e.g. V8QI->V8HI.

This is handled by widening the inputs using NOP_EXPRs then using a
non-widening stmt e.g. MINUS_EXPR.  RTL fusing converts these to the widening
hardware instructions if supported.

The more typical case (handled in supportable_widening_operation) is where
the input vector type has the same number of bits as the output vector type.
In this case half the elements of the input vectors must be processed at a
time into respective vector outputs with elements twice as wide i.e. a
'hi'/'lo' pair using codes such as VEC_WIDEN_MINUS_HI/LO.

Supported widening operations:
 WIDEN_MULT_EXPR
 WIDEN_LSHIFT_EXPR

Output:
- CODE1 - The non-widened code, which will be used after the inputs are
  converted to the wide type.   

References gcc_assert, optab_for_tree_code(), optab_handler(), optab_vector, supportable_convert_operation(), TYPE_MODE, TYPE_VECTOR_SUBPARTS(), VECTOR_MODE_P, and VECTOR_TYPE_P.

Referenced by vectorizable_conversion().

◆ target_supports_mask_load_store_p()

bool target_supports_mask_load_store_p ( machine_mode mode,
machine_mode mask_mode,
bool is_load,
internal_fn * ifn,
vec< int > * elsvals )
Return true if the target has support for masked load/store.
We can support masked load/store by either mask{load,store}
or mask_len_{load,store}.
This helper function checks whether target supports masked
load/store and return corresponding IFN in the last argument
(IFN_MASK_{LOAD,STORE} or IFN_MASK_LEN_{LOAD,STORE}).
If there is support and ELSVALS is nonzero store the possible else values
in the vector it points to.   

References convert_optab_handler(), get_supported_else_vals(), and internal_fn_else_index().

Referenced by can_vec_mask_load_store_p().

◆ target_supports_op_p()

bool target_supports_op_p ( tree type,
enum tree_code code,
enum optab_subtype ot_subtype )
Return TRUE if the target has support for vector right shift of an
operand of type TYPE.  If OT_TYPE is OPTAB_DEFAULT, check for existence
of a shift by either a scalar or a vector.  Otherwise, check only
for a shift that matches OT_TYPE.   

References can_implement_p(), optab_for_tree_code(), TYPE_MODE, and unknown_optab.

Referenced by determine_max_movement().