GCC Middle and Back End API Reference
optabs-tree.cc File Reference
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "target.h"
#include "insn-codes.h"
#include "rtl.h"
#include "tree.h"
#include "memmodel.h"
#include "optabs.h"
#include "optabs-tree.h"
#include "stor-layout.h"
Include dependency graph for optabs-tree.cc:

Functions

optab optab_for_tree_code (enum tree_code code, const_tree type, enum optab_subtype subtype)
 
bool supportable_half_widening_operation (enum tree_code code, tree vectype_out, tree vectype_in, enum tree_code *code1)
 
bool supportable_convert_operation (enum tree_code code, tree vectype_out, tree vectype_in, enum tree_code *code1)
 
static bool vec_cmp_icode_p (tree value_type, tree mask_type, enum tree_code code)
 
static bool vec_cmp_eq_icode_p (tree value_type, tree mask_type, enum tree_code code)
 
bool expand_vec_cmp_expr_p (tree value_type, tree mask_type, enum tree_code code)
 
static bool vcond_icode_p (tree value_type, tree cmp_op_type, enum tree_code code)
 
static bool vcond_eq_icode_p (tree value_type, tree cmp_op_type, enum tree_code code)
 
bool expand_vec_cond_expr_p (tree value_type, tree cmp_op_type, enum tree_code code)
 
void init_tree_optimization_optabs (tree optnode)
 
bool target_supports_op_p (tree type, enum tree_code code, enum optab_subtype ot_subtype)
 
static bool target_supports_mask_load_store_p (machine_mode mode, machine_mode mask_mode, bool is_load, internal_fn *ifn)
 
bool can_vec_mask_load_store_p (machine_mode mode, machine_mode mask_mode, bool is_load, internal_fn *ifn)
 
static bool target_supports_len_load_store_p (machine_mode mode, bool is_load, internal_fn *ifn)
 
opt_machine_mode get_len_load_store_mode (machine_mode mode, bool is_load, internal_fn *ifn)
 

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 )
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.   

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(), 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 check_bool_pattern(), do_store_flag(), expand_vector_comparison(), expand_vector_condition(), 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,
enum tree_code code )

◆ get_len_load_store_mode()

opt_machine_mode get_len_load_store_mode ( machine_mode mode,
bool is_load,
internal_fn * ifn )
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.   

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 )
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(), 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_len_load_store_p()

static bool target_supports_len_load_store_p ( machine_mode mode,
bool is_load,
internal_fn * ifn )
static
Return true if the target has support for len load/store.
We can support len load/store by either len_{load,store}
or mask_len_{load,store}.
This helper function checks whether target supports len
load/store and return corresponding IFN in the last argument
(IFN_LEN_{LOAD,STORE} or IFN_MASK_LEN_{LOAD,STORE}).   

References convert_optab_handler(), direct_optab_handler(), and targetm.

Referenced by get_len_load_store_mode().

◆ target_supports_mask_load_store_p()

static bool target_supports_mask_load_store_p ( machine_mode mode,
machine_mode mask_mode,
bool is_load,
internal_fn * ifn )
static
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}).   

References convert_optab_handler().

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 optab_for_tree_code(), optab_handler(), TYPE_MODE, and unknown_optab.

Referenced by determine_max_movement().

◆ vcond_eq_icode_p()

static bool vcond_eq_icode_p ( tree value_type,
tree cmp_op_type,
enum tree_code code )
static
Return true iff vcondeq_optab can handle a vector comparison for code CODE,
comparing operands of type CMP_OP_TYPE and producing a result of type
VALUE_TYPE.   

References get_vcond_eq_icode(), and TYPE_MODE.

Referenced by expand_vec_cond_expr_p().

◆ vcond_icode_p()

static bool vcond_icode_p ( tree value_type,
tree cmp_op_type,
enum tree_code code )
static
Return true iff vcond_optab/vcondu_optab can handle a vector
comparison for code CODE, comparing operands of type CMP_OP_TYPE and
producing a result of type VALUE_TYPE.   

References can_vcond_compare_p(), get_rtx_code_1(), TYPE_MODE, and TYPE_UNSIGNED.

Referenced by expand_vec_cond_expr_p().

◆ vec_cmp_eq_icode_p()

static bool vec_cmp_eq_icode_p ( tree value_type,
tree mask_type,
enum tree_code code )
static
Return true iff vec_cmpeq_optab can handle a vector comparison for code
CODE, comparing operands of type VALUE_TYPE and producing a result of type
MASK_TYPE.   

References get_vec_cmp_eq_icode(), and TYPE_MODE.

Referenced by expand_vec_cmp_expr_p().

◆ vec_cmp_icode_p()

static bool vec_cmp_icode_p ( tree value_type,
tree mask_type,
enum tree_code code )
static
Return true iff vec_cmp_optab/vec_cmpu_optab can handle a vector comparison
for code CODE, comparing operands of type VALUE_TYPE and producing a result
of type MASK_TYPE.   

References can_vec_cmp_compare_p(), get_rtx_code_1(), TYPE_MODE, and TYPE_UNSIGNED.

Referenced by expand_vec_cmp_expr_p().