diff options
author | Ilya Leoshkevich <iii@linux.ibm.com> | 2019-10-07 15:01:15 +0000 |
---|---|---|
committer | Ilya Leoshkevich <iii@gcc.gnu.org> | 2019-10-07 15:01:15 +0000 |
commit | dcd2ca63ec5c467decb70db983fc19a8329f67dc (patch) | |
tree | 57e8c3ef3613a9b118825f76b0390c14d6429549 /gcc/optabs-tree.c | |
parent | 70e2a30ac8f474feefbcc392cbc59cf91271b92b (diff) | |
download | gcc-dcd2ca63ec5c467decb70db983fc19a8329f67dc.zip gcc-dcd2ca63ec5c467decb70db983fc19a8329f67dc.tar.gz gcc-dcd2ca63ec5c467decb70db983fc19a8329f67dc.tar.bz2 |
Introduce can_vcond_compare_p function
z13 supports only non-signaling vector comparisons. This means we
cannot vectorize LT, LE, GT, GE and LTGT when compiling for z13.
However, we cannot express this restriction today: the code only checks
whether vcond$a$b optab exists, but this does not say anything about the
operation.
Introduce a function that checks whether back-end supports vector
comparisons with individual rtx codes by matching vcond expander's third
argument with a fake comparison with the corresponding rtx code.
gcc/ChangeLog:
2019-10-07 Ilya Leoshkevich <iii@linux.ibm.com>
PR target/77918
* optabs-tree.c (vcond_icode_p): New function.
(vcond_eq_icode_p): Likewise.
(expand_vec_cond_expr_p): Use vcond_icode_p and
vcond_eq_icode_p.
* optabs.c (can_vcond_compare_p): New function.
* optabs.h (can_vcond_compare_p): Likewise.
From-SVN: r276660
Diffstat (limited to 'gcc/optabs-tree.c')
-rw-r--r-- | gcc/optabs-tree.c | 39 |
1 files changed, 33 insertions, 6 deletions
diff --git a/gcc/optabs-tree.c b/gcc/optabs-tree.c index 8157798..a5ecbf0 100644 --- a/gcc/optabs-tree.c +++ b/gcc/optabs-tree.c @@ -23,7 +23,10 @@ along with GCC; see the file COPYING3. If not see #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" @@ -329,6 +332,31 @@ expand_vec_cmp_expr_p (tree value_type, tree mask_type, enum tree_code code) return false; } +/* 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. */ + +static bool +vcond_icode_p (tree value_type, tree cmp_op_type, enum tree_code code) +{ + return can_vcond_compare_p (get_rtx_code (code, TYPE_UNSIGNED (cmp_op_type)), + TYPE_MODE (value_type), TYPE_MODE (cmp_op_type)); +} + +/* 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. */ + +static bool +vcond_eq_icode_p (tree value_type, tree cmp_op_type, enum tree_code code) +{ + if (code != EQ_EXPR && code != NE_EXPR) + return false; + + return get_vcond_eq_icode (TYPE_MODE (value_type), TYPE_MODE (cmp_op_type)) + != CODE_FOR_nothing; +} + /* 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. */ @@ -347,14 +375,13 @@ expand_vec_cond_expr_p (tree value_type, tree cmp_op_type, enum tree_code code) || maybe_ne (GET_MODE_NUNITS (value_mode), GET_MODE_NUNITS (cmp_op_mode))) return false; - if (get_vcond_icode (TYPE_MODE (value_type), TYPE_MODE (cmp_op_type), - TYPE_UNSIGNED (cmp_op_type)) == CODE_FOR_nothing - && ((code != EQ_EXPR && code != NE_EXPR) - || get_vcond_eq_icode (TYPE_MODE (value_type), - TYPE_MODE (cmp_op_type)) == CODE_FOR_nothing)) + if (TREE_CODE_CLASS (code) != tcc_comparison) + /* This may happen, for example, if code == SSA_NAME, in which case we + cannot be certain whether a vector insn is available. */ return false; - return true; + return vcond_icode_p (value_type, cmp_op_type, code) + || vcond_eq_icode_p (value_type, cmp_op_type, code); } /* Use the current target and options to initialize |