https://gcc.gnu.org/g:1b387bd897857742bce85ef50725841af1329351

commit r16-4558-g1b387bd897857742bce85ef50725841af1329351
Author: Tamar Christina <[email protected]>
Date:   Wed Oct 22 10:49:26 2025 +0100

    vect: Add support for boolean reductions for VLA
    
    The support for the new boolean reduction optabs didn't quite work for VLA
    because the code later on insists on the target still having a 
shift-and-insert
    optab.
    
    This is however not needed if the target can do the reduction using the new
    optabs, and the initial reduction value matches the neutral value and we
    have one SLP lane while not having a reduction chain.
    
    gcc/ChangeLog:
    
            * tree-vect-loop.cc (vectorizable_reduction): Don't always require
            IFN_VEC_SHL_INSERT when using reduc sbool optabs.

Diff:
---
 gcc/tree-vect-loop.cc | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
index 77c9e15601b3..9320bf8e878d 100644
--- a/gcc/tree-vect-loop.cc
+++ b/gcc/tree-vect-loop.cc
@@ -7581,6 +7581,8 @@ vectorizable_reduction (loop_vec_info loop_vinfo,
      values into the low-numbered elements.  */
   if ((double_reduc || neutral_op)
       && !nunits_out.is_constant ()
+      && (SLP_TREE_LANES (slp_node) != 1 && !reduc_chain)
+      && !operand_equal_p (neutral_op, vect_phi_initial_value (reduc_def_phi))
       && !direct_internal_fn_supported_p (IFN_VEC_SHL_INSERT,
                                          vectype_out, OPTIMIZE_FOR_SPEED))
     {

Reply via email to