https://gcc.gnu.org/g:674b1d73e437cbdbe86da45dbb67364297bb2216

commit r16-3427-g674b1d73e437cbdbe86da45dbb67364297bb2216
Author: Richard Biener <rguent...@suse.de>
Date:   Wed Aug 27 14:39:00 2025 +0200

    The divmod pattern will break reduction constraints
    
    When we apply a divmod pattern this will break reductions by introducing
    multiple uses of the reduction var, so avoid this pattern in reductions.
    
            * tree-vect-patterns.cc (vect_recog_divmod_pattern): Avoid
            for stmts participating in a reduction.

Diff:
---
 gcc/tree-vect-patterns.cc | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/gcc/tree-vect-patterns.cc b/gcc/tree-vect-patterns.cc
index ffb320fbf233..3fffcac4b3aa 100644
--- a/gcc/tree-vect-patterns.cc
+++ b/gcc/tree-vect-patterns.cc
@@ -4818,7 +4818,9 @@ vect_recog_divmod_pattern (vec_info *vinfo,
   tree q, cst;
   int prec;
 
-  if (!is_gimple_assign (last_stmt))
+  if (!is_gimple_assign (last_stmt)
+      /* The pattern will disrupt the reduction chain with multiple uses.  */
+      || vect_is_reduction (stmt_vinfo))
     return NULL;
 
   rhs_code = gimple_assign_rhs_code (last_stmt);

Reply via email to