]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
vect: Add support for boolean reductions for VLA
authorTamar Christina <tamar.christina@arm.com>
Wed, 22 Oct 2025 09:49:26 +0000 (10:49 +0100)
committerTamar Christina <tamar.christina@arm.com>
Wed, 22 Oct 2025 09:49:26 +0000 (10:49 +0100)
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.

gcc/tree-vect-loop.cc

index 77c9e15601b3f60da52c7b8899fa0f5c174cad0f..9320bf8e878d22faa5e202311649ffc05dbd6094 100644 (file)
@@ -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))
     {