The following adds missing checks for a vector type result type to simplifications that end up creating a vec_cond.
Bootstrap and regtest running on x86_64-unknown-linux-gnu. PR middle-end/117086 * match.pd ((op (vec_cond ...) ..) -> (vec_cond ...)): Add missing checks for VECTOR_TYPE_P (type). * gcc.dg/torture/pr117086.c: New testcase. --- gcc/match.pd | 45 +++++++++++++------------ gcc/testsuite/gcc.dg/torture/pr117086.c | 12 +++++++ 2 files changed, 36 insertions(+), 21 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/torture/pr117086.c diff --git a/gcc/match.pd b/gcc/match.pd index 8a7569ce387..d8be7a8f6f7 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -5690,35 +5690,38 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) /* (c ? a : b) op (c ? d : e) --> c ? (a op d) : (b op e) */ (simplify (op (vec_cond:s @0 @1 @2) (vec_cond:s @0 @3 @4)) - (if (TREE_CODE_CLASS (op) != tcc_comparison - || types_match (type, TREE_TYPE (@1)) - || expand_vec_cond_expr_p (type, TREE_TYPE (@0), ERROR_MARK) - || (optimize_vectors_before_lowering_p () - /* The following is optimistic on the side of non-support, we are - missing the legacy vcond{,u,eq} cases. Do this only when - lowering will be able to fixup.. */ - && !expand_vec_cond_expr_p (TREE_TYPE (@1), - TREE_TYPE (@0), ERROR_MARK))) + (if (VECTOR_TYPE_P (type) + && (TREE_CODE_CLASS (op) != tcc_comparison + || types_match (type, TREE_TYPE (@1)) + || expand_vec_cond_expr_p (type, TREE_TYPE (@0), ERROR_MARK) + || (optimize_vectors_before_lowering_p () + /* The following is optimistic on the side of non-support, we are + missing the legacy vcond{,u,eq} cases. Do this only when + lowering will be able to fixup.. */ + && !expand_vec_cond_expr_p (TREE_TYPE (@1), + TREE_TYPE (@0), ERROR_MARK)))) (vec_cond @0 (op! @1 @3) (op! @2 @4)))) /* (c ? a : b) op d --> c ? (a op d) : (b op d) */ (simplify (op (vec_cond:s @0 @1 @2) @3) - (if (TREE_CODE_CLASS (op) != tcc_comparison - || types_match (type, TREE_TYPE (@1)) - || expand_vec_cond_expr_p (type, TREE_TYPE (@0), ERROR_MARK) - || (optimize_vectors_before_lowering_p () - && !expand_vec_cond_expr_p (TREE_TYPE (@1), - TREE_TYPE (@0), ERROR_MARK))) + (if (VECTOR_TYPE_P (type) + && (TREE_CODE_CLASS (op) != tcc_comparison + || types_match (type, TREE_TYPE (@1)) + || expand_vec_cond_expr_p (type, TREE_TYPE (@0), ERROR_MARK) + || (optimize_vectors_before_lowering_p () + && !expand_vec_cond_expr_p (TREE_TYPE (@1), + TREE_TYPE (@0), ERROR_MARK)))) (vec_cond @0 (op! @1 @3) (op! @2 @3)))) (simplify (op @3 (vec_cond:s @0 @1 @2)) - (if (TREE_CODE_CLASS (op) != tcc_comparison - || types_match (type, TREE_TYPE (@1)) - || expand_vec_cond_expr_p (type, TREE_TYPE (@0), ERROR_MARK) - || (optimize_vectors_before_lowering_p () - && !expand_vec_cond_expr_p (TREE_TYPE (@1), - TREE_TYPE (@0), ERROR_MARK))) + (if (VECTOR_TYPE_P (type) + && (TREE_CODE_CLASS (op) != tcc_comparison + || types_match (type, TREE_TYPE (@1)) + || expand_vec_cond_expr_p (type, TREE_TYPE (@0), ERROR_MARK) + || (optimize_vectors_before_lowering_p () + && !expand_vec_cond_expr_p (TREE_TYPE (@1), + TREE_TYPE (@0), ERROR_MARK)))) (vec_cond @0 (op! @3 @1) (op! @3 @2))))) #if GIMPLE diff --git a/gcc/testsuite/gcc.dg/torture/pr117086.c b/gcc/testsuite/gcc.dg/torture/pr117086.c new file mode 100644 index 00000000000..cee19c91de2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr117086.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-march=znver5" { target { x86_64-*-* i?86-*-* } } } */ + +void fancy_abort(const char *, int, const char *); +int usage_insns_0_0; +void inherit_in_ebb() { + int abis = 0; + for (int i = 0; i < 8; ++i) + if (i > usage_insns_0_0) + abis |= i; + abis ? fancy_abort("", 0, __FUNCTION__), 0 : 0; +} -- 2.43.0