]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
The divmod pattern will break reduction constraints
authorRichard Biener <rguenther@suse.de>
Wed, 27 Aug 2025 12:39:00 +0000 (14:39 +0200)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 28 Aug 2025 08:30:18 +0000 (10:30 +0200)
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.

gcc/tree-vect-patterns.cc

index ffb320fbf2330522f25a9f4380f4744079a42306..3fffcac4b3aa35d5da6924c8789dd79b5848e74a 100644 (file)
@@ -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);