diff options
author | Richard Biener <rguenther@suse.de> | 2024-10-11 11:46:45 +0200 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2024-10-11 12:35:23 +0200 |
commit | c64ae8377210bde44714d265311ee7bfa2733df9 (patch) | |
tree | ee01915929902fc198943307d6303c0b4b3532c5 /gcc | |
parent | dd2d4b3fd87241dca658b68b4f9eef533b7fad36 (diff) | |
download | gcc-c64ae8377210bde44714d265311ee7bfa2733df9.zip gcc-c64ae8377210bde44714d265311ee7bfa2733df9.tar.gz gcc-c64ae8377210bde44714d265311ee7bfa2733df9.tar.bz2 |
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.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/match.pd | 45 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/torture/pr117086.c | 12 |
2 files changed, 36 insertions, 21 deletions
diff --git a/gcc/match.pd b/gcc/match.pd index 5138eec..5ed1ea0 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 0000000..cee19c9 --- /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; +} |