diff --git a/gcc/testsuite/gcc.target/aarch64/sve/pr109176.c b/gcc/testsuite/gcc.target/aarch64/sve/pr109176.c new file mode 100644 index 0000000000000000000000000000000000000000..958edb86ce3ea21d603ef5126bfe693ef3cecf5f --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/sve/pr109176.c @@ -0,0 +1,12 @@ +/* PR tree-optimization/109176 */ +/* { dg-do compile } */ +/* { dg-additional-options "-O2" } */ + +#include <arm_sve.h> + +svbool_t +foo (svint8_t a, svint8_t b, svbool_t c) +{ + svbool_t d = svcmplt_s8 (svptrue_pat_b8 (SV_ALL), a, b); + return svsel_b (d, c, d); +} diff --git a/gcc/tree-vect-generic.cc b/gcc/tree-vect-generic.cc index 519a824ec727d4d4f28c14077dc3e970bed75ef6..67f138a9332d6e30a65a7aac8f317273e81bab4d 100644 --- a/gcc/tree-vect-generic.cc +++ b/gcc/tree-vect-generic.cc @@ -1063,6 +1063,15 @@ expand_vector_condition (gimple_stmt_iterator *gsi, bitmap dce_ssa_names) return true; } + /* If a has vector boolean type and is a comparison, above + expand_vec_cond_expr_p might fail, even if both the comparison and + VEC_COND_EXPR could be supported individually. See PR109176. */ + if (a_is_comparison + && VECTOR_BOOLEAN_TYPE_P (TREE_TYPE (a)) + && expand_vec_cond_expr_p (type, TREE_TYPE (a), SSA_NAME) + && expand_vec_cmp_expr_p (TREE_TYPE (a1), TREE_TYPE (a), code)) + return true; + /* Handle vector boolean types with bitmasks. If there is a comparison and we can expand the comparison into the vector boolean bitmask, or otherwise if it is compatible with type, we can transform