From dcd2ca63ec5c467decb70db983fc19a8329f67dc Mon Sep 17 00:00:00 2001 From: Ilya Leoshkevich Date: Mon, 7 Oct 2019 15:01:15 +0000 Subject: 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 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 --- gcc/optabs.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'gcc/optabs.c') diff --git a/gcc/optabs.c b/gcc/optabs.c index 35921e6..d6701df 100644 --- a/gcc/optabs.c +++ b/gcc/optabs.c @@ -3819,6 +3819,25 @@ can_compare_p (enum rtx_code code, machine_mode mode, return 0; } +/* Return whether the backend can emit a vector comparison for code CODE, + comparing operands of mode CMP_OP_MODE and producing a result with + VALUE_MODE. */ + +bool +can_vcond_compare_p (enum rtx_code code, machine_mode value_mode, + machine_mode cmp_op_mode) +{ + enum insn_code icode; + bool unsigned_p = (code == LTU || code == LEU || code == GTU || code == GEU); + rtx reg1 = alloca_raw_REG (cmp_op_mode, LAST_VIRTUAL_REGISTER + 1); + rtx reg2 = alloca_raw_REG (cmp_op_mode, LAST_VIRTUAL_REGISTER + 2); + rtx test = alloca_rtx_fmt_ee (code, value_mode, reg1, reg2); + + return (icode = get_vcond_icode (value_mode, cmp_op_mode, unsigned_p)) + != CODE_FOR_nothing + && insn_operand_matches (icode, 3, test); +} + /* This function is called when we are going to emit a compare instruction that compares the values found in X and Y, using the rtl operator COMPARISON. -- cgit v1.1