https://gcc.gnu.org/g:c6865e7e15bc9a1337df00d2ca03604e1712a2dd

commit r16-4156-gc6865e7e15bc9a1337df00d2ca03604e1712a2dd
Author: Richard Biener <[email protected]>
Date:   Wed Oct 1 11:26:45 2025 +0200

    tree-optimization/122110 - do not reject all bit-precision reductions
    
    We can handle bitwise-operation reductions and reductions on mask
    vectors just fine.
    
            PR tree-optimization/122110
            * tree-vect-loop.cc (vectorizable_reduction): Relax restriction
            to mode-precision operations.

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

diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
index 18360375e297..1d549e4a03e2 100644
--- a/gcc/tree-vect-loop.cc
+++ b/gcc/tree-vect-loop.cc
@@ -7187,7 +7187,11 @@ vectorizable_reduction (loop_vec_info loop_vinfo,
     return false;
 
   /* Do not try to vectorize bit-precision reductions.  */
-  if (!type_has_mode_precision_p (op.type))
+  if (!VECTOR_BOOLEAN_TYPE_P (vectype_out)
+      && !type_has_mode_precision_p (op.type)
+      && op.code != BIT_AND_EXPR
+      && op.code != BIT_IOR_EXPR
+      && op.code != BIT_XOR_EXPR)
     return false;
 
   /* Lane-reducing ops also never can be used in a SLP reduction group

Reply via email to