ab0a6b213a
This patch adds support for a dot product where the sign of the multiplication arguments differ. i.e. one is signed and one is unsigned but the precisions are the same. #define N 480 #define SIGNEDNESS_1 unsigned #define SIGNEDNESS_2 signed #define SIGNEDNESS_3 signed #define SIGNEDNESS_4 unsigned SIGNEDNESS_1 int __attribute__ ((noipa)) f (SIGNEDNESS_1 int res, SIGNEDNESS_3 char *restrict a, SIGNEDNESS_4 char *restrict b) { for (__INTPTR_TYPE__ i = 0; i < N; ++i) { int av = a[i]; int bv = b[i]; SIGNEDNESS_2 short mult = av * bv; res += mult; } return res; } The operations are performed as if the operands were extended to a 32-bit value. As such this operation isn't valid if there is an intermediate conversion to an unsigned value. i.e. if SIGNEDNESS_2 is unsigned. more over if the signs of SIGNEDNESS_3 and SIGNEDNESS_4 are flipped the same optab is used but the operands are flipped in the optab expansion. To support this the patch extends the dot-product detection to optionally ignore operands with different signs and stores this information in the optab subtype which is now made a bitfield. The subtype can now additionally controls which optab an EXPR can expand to. gcc/ChangeLog: * optabs.def (usdot_prod_optab): New. * doc/md.texi: Document it and clarify other dot prod optabs. * optabs-tree.h (enum optab_subtype): Add optab_vector_mixed_sign. * optabs-tree.c (optab_for_tree_code): Support usdot_prod_optab. * optabs.c (expand_widen_pattern_expr): Likewise. * tree-cfg.c (verify_gimple_assign_ternary): Likewise. * tree-vect-loop.c (vectorizable_reduction): Query dot-product kind. * tree-vect-patterns.c (vect_supportable_direct_optab_p): Take optional optab subtype. (vect_widened_op_tree): Optionally ignore mismatch types. (vect_recog_dot_prod_pattern): Support usdot_prod_optab.
52 lines
1.8 KiB
C
52 lines
1.8 KiB
C
/* Tree-based target query functions relating to optabs
|
|
Copyright (C) 2001-2021 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/>. */
|
|
|
|
#ifndef GCC_OPTABS_TREE_H
|
|
#define GCC_OPTABS_TREE_H
|
|
|
|
#include "optabs-query.h"
|
|
|
|
/* 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. */
|
|
enum optab_subtype
|
|
{
|
|
optab_default,
|
|
optab_scalar,
|
|
optab_vector,
|
|
optab_vector_mixed_sign
|
|
};
|
|
|
|
/* 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. */
|
|
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, enum tree_code);
|
|
void init_tree_optimization_optabs (tree);
|
|
bool target_supports_op_p (tree, enum tree_code,
|
|
enum optab_subtype = optab_default);
|
|
|
|
#endif
|