https://gcc.gnu.org/g:59afd44ffb1bd55fc84b4a36107a9bdba708e9a0

commit r15-4422-g59afd44ffb1bd55fc84b4a36107a9bdba708e9a0
Author: Richard Biener <rguent...@suse.de>
Date:   Thu Oct 17 14:27:13 2024 +0200

    Relax boolean processing in vect_maybe_update_slp_op_vectype
    
    The following makes VECTOR_BOOLEAN_TYPE_P processing consistent with
    what we do without SLP.  The original motivation for rejecting of
    VECTOR_BOOLEAN_TYPE_P extern defs was bad code generation.  But
    the non-SLP codepath happily goes along - but always hits the
    case of an uniform vector and this case specifically we can now
    code-generate optimally.  So the following allows single-lane
    externs as well.
    
    Requiring patterns to code-generate can have bad influence on
    the vectorization factor though a prototype patch of mine shows
    that generating vector compares externally isn't always trivial.
    
    The patch fixes the gcc.dg/vect/vect-early-break_82.c FAIL on x86_64
    when --param vect-force-slp=1 is in effect.
    
            PR tree-optimization/117171
            * tree-vect-stmts.cc (vect_maybe_update_slp_op_vectype):
            Relax vect_external_def VECTOR_BOOLEAN_TYPE_P constraint.

Diff:
---
 gcc/tree-vect-stmts.cc | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc
index 6967d50288e9..e7f14c3144c3 100644
--- a/gcc/tree-vect-stmts.cc
+++ b/gcc/tree-vect-stmts.cc
@@ -14290,9 +14290,12 @@ vect_maybe_update_slp_op_vectype (slp_tree op, tree 
vectype)
   if (SLP_TREE_VECTYPE (op))
     return types_compatible_p (SLP_TREE_VECTYPE (op), vectype);
   /* For external defs refuse to produce VECTOR_BOOLEAN_TYPE_P, those
-     should be handled by patters.  Allow vect_constant_def for now.  */
+     should be handled by patters.  Allow vect_constant_def for now
+     as well as the trivial single-lane uniform vect_external_def case
+     both of which we code-generate reasonably.  */
   if (VECTOR_BOOLEAN_TYPE_P (vectype)
-      && SLP_TREE_DEF_TYPE (op) == vect_external_def)
+      && SLP_TREE_DEF_TYPE (op) == vect_external_def
+      && SLP_TREE_LANES (op) > 1)
     return false;
   SLP_TREE_VECTYPE (op) = vectype;
   return true;

Reply via email to