The following makes sure to lower all VEC_COND_EXPRs that we cannot trivially expand.
Bootstrapped and tested on x86_64-unknown-linux-gnu. * tree-vect-generic.cc (expand_vector_condition): Lower vector conditions that we cannot trivially expand. --- gcc/tree-vect-generic.cc | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/gcc/tree-vect-generic.cc b/gcc/tree-vect-generic.cc index 72f251f0962..dc4e0e241fe 100644 --- a/gcc/tree-vect-generic.cc +++ b/gcc/tree-vect-generic.cc @@ -1033,6 +1033,13 @@ expand_vector_condition (gimple_stmt_iterator *gsi, bitmap dce_ssa_names) tree_code code = TREE_CODE (a); gassign *assign = NULL; + gcc_assert (VECTOR_BOOLEAN_TYPE_P (TREE_TYPE (a))); + + /* Mask typed, non-vector mode VEC_COND_EXPRs are expanded as bitwise + operations by ISEL. */ + if (VECTOR_BOOLEAN_TYPE_P (type) && !VECTOR_MODE_P (TYPE_MODE (type))) + return true; + if (code == SSA_NAME) { assign = dyn_cast<gassign *> (SSA_NAME_DEF_STMT (a)); @@ -1048,21 +1055,12 @@ expand_vector_condition (gimple_stmt_iterator *gsi, bitmap dce_ssa_names) } } - if (expand_vec_cond_expr_p (type, TREE_TYPE (a1), code) - || (integer_all_onesp (b) && integer_zerop (c) - && expand_vec_cmp_expr_p (type, TREE_TYPE (a1), code))) - { - gcc_assert (TREE_CODE (a) == SSA_NAME || TREE_CODE (a) == VECTOR_CST); - 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)) - && expand_vec_cmp_expr_p (TREE_TYPE (a1), TREE_TYPE (a), code)) + /* We are not lowering vector compares separately - those cannot be + generated by source without a wrapping vector condition. Simplifications + that separate the comparison need to verify we can code generate it. */ + if (expand_vec_cond_expr_p (type, TREE_TYPE (a)) + && (!a_is_comparison + || 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 -- 2.43.0