From: Richard Biener Date: Fri, 11 Oct 2024 09:46:45 +0000 (+0200) Subject: middle-end/117086 - fixup vec_cond simplifications X-Git-Tag: basepoints/gcc-16~5293 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c64ae8377210bde44714d265311ee7bfa2733df9;p=thirdparty%2Fgcc.git middle-end/117086 - fixup vec_cond simplifications The following adds missing checks for a vector type result type to simplifications that end up creating a vec_cond. 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. --- diff --git a/gcc/match.pd b/gcc/match.pd index 5138eec577b..5ed1ea03305 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -5699,35 +5699,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; +}