diff options
author | Victor Do Nascimento <victor.donascimento@arm.com> | 2024-05-22 10:06:57 +0100 |
---|---|---|
committer | Victor Do Nascimento <victor.donascimento@arm.com> | 2024-09-30 15:59:42 +0100 |
commit | c7fba0e96641e57164fc72bdbffd9a1cea244818 (patch) | |
tree | fecce3d409cf91ec05492fead19b7fc5dcb2938d /gcc/tree-vect-patterns.cc | |
parent | 2f68d69e47b5b627c6bb71a6bb3d7b2e0e641b2f (diff) | |
download | gcc-c7fba0e96641e57164fc72bdbffd9a1cea244818.zip gcc-c7fba0e96641e57164fc72bdbffd9a1cea244818.tar.gz gcc-c7fba0e96641e57164fc72bdbffd9a1cea244818.tar.bz2 |
autovectorizer: Add basic support for convert optabs
Given the shift from modeling dot products as direct optabs to
treating them as conversion optabs, we make necessary changes to the
autovectorizer code to ensure that given the relevant tree code,
together with the input and output data modes, we can retrieve the
relevant optab and subsequently the insn_code for it.
gcc/ChangeLog:
* gimple-match-exports.cc (directly_supported_p): Add overload
for conversion-type optabs.
* gimple-match.h (directly_supported_p): Add new function
prototype.
* optabs.cc (expand_widen_pattern_expr): Make the
DOT_PROD_EXPR tree code use `find_widening_optab_handler' to
retrieve icode.
* tree-vect-loop.cc (vect_is_emulated_mixed_dot_prod): make it
call conversion-type overloaded `directly_supported_p'.
* tree-vect-patterns.cc (vect_supportable_conv_optab_p): New.
(vect_recog_dot_prod_pattern): s/direct/conv/ in call to
`vect_supportable_direct_optab_p'.
Diffstat (limited to 'gcc/tree-vect-patterns.cc')
-rw-r--r-- | gcc/tree-vect-patterns.cc | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/gcc/tree-vect-patterns.cc b/gcc/tree-vect-patterns.cc index b174ff1..9bf8526 100644 --- a/gcc/tree-vect-patterns.cc +++ b/gcc/tree-vect-patterns.cc @@ -262,6 +262,35 @@ vect_supportable_direct_optab_p (vec_info *vinfo, tree otype, tree_code code, return true; } +/* Return true if the target supports a vector version of CODE, + where CODE is known to map to a conversion optab with the given SUBTYPE. + ITYPE specifies the type of (some of) the scalar inputs and OTYPE + specifies the type of the scalar result. + + When returning true, set *VECOTYPE_OUT to the vector version of OTYPE. + Also set *VECITYPE_OUT to the vector version of ITYPE if VECITYPE_OUT + is nonnull. */ + +static bool +vect_supportable_conv_optab_p (vec_info *vinfo, tree otype, tree_code code, + tree itype, tree *vecotype_out, + tree *vecitype_out = NULL, + enum optab_subtype subtype = optab_default) +{ + tree vecitype = get_vectype_for_scalar_type (vinfo, itype); + tree vecotype = get_vectype_for_scalar_type (vinfo, otype); + if (!vecitype || !vecotype) + return false; + + if (!directly_supported_p (code, vecotype, vecitype, subtype)) + return false; + + *vecotype_out = vecotype; + if (vecitype_out) + *vecitype_out = vecitype; + return true; +} + /* Round bit precision PRECISION up to a full element. */ static unsigned int @@ -1282,13 +1311,13 @@ vect_recog_dot_prod_pattern (vec_info *vinfo, half_type = signed_type_for (half_type); tree half_vectype; - if (!vect_supportable_direct_optab_p (vinfo, type, DOT_PROD_EXPR, half_type, + if (!vect_supportable_conv_optab_p (vinfo, type, DOT_PROD_EXPR, half_type, type_out, &half_vectype, subtype)) { /* We can emulate a mixed-sign dot-product using a sequence of signed dot-products; see vect_emulate_mixed_dot_prod for details. */ if (subtype != optab_vector_mixed_sign - || !vect_supportable_direct_optab_p (vinfo, signed_type_for (type), + || !vect_supportable_conv_optab_p (vinfo, signed_type_for (type), DOT_PROD_EXPR, half_type, type_out, &half_vectype, optab_vector)) |