https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103948

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rguenth at gcc dot gnu.org

--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
I guess that tree-vect-generic.c is not up-to-date with gimple-isel.cc.  We
should probably somehow factor out relevant pieces.

Note vector lowering will see

  _1 = a_2(D) > b_3(D);
  _4 = VEC_COND_EXPR <_1, { -1, -1 }, { 0, 0 }>;

and clearly a

  if (expand_vec_cond_expr_p (type, TREE_TYPE (a1), code))

that's just type/code based cannot know expanding just a comparison will work
fine.  It does look like expand_vector_condition from vector lowering needs
some work.  Maybe the following works though:

diff --git a/gcc/tree-vect-generic.c b/gcc/tree-vect-generic.c
index 6afb6999cd7..5814a71a5bb 100644
--- a/gcc/tree-vect-generic.c
+++ b/gcc/tree-vect-generic.c
@@ -1052,7 +1052,9 @@ expand_vector_condition (gimple_stmt_iterator *gsi,
bitmap dce_ssa_names)
        }
     }

-  if (expand_vec_cond_expr_p (type, TREE_TYPE (a1), code))
+  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;

obviously missing would be the case
cmp ? { 0, 0 } : { -1, -1 } via code inversion, not sure if we canonicalize
that way already and not sure if expansion later will pick that up correctly.

A vector mode with just vec_cmp and not vcond will be good to have to cover
all this with testcases ... ;)

If the above works it's pre-approved.

Reply via email to