]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-optimization/111125 - properly cost BB reduction remain stmt handling
authorRichard Biener <rguenther@suse.de>
Thu, 24 Aug 2023 08:30:12 +0000 (10:30 +0200)
committerRichard Biener <rguenther@suse.de>
Thu, 24 Aug 2023 09:35:15 +0000 (11:35 +0200)
We assume that all root stmts which compose the total reduction chain
are vectorized but fail to account for the cost of adding back the
scalar defs we are not vectorizing.  The following rectifies this,
fixing the gcc.dg/tree-ssa/slsr-11.c FAIL on aarch64.

PR tree-optimization/111125
* tree-vect-slp.cc (vectorizable_bb_reduc_epilogue): Account
for the remain_defs processing.

gcc/tree-vect-slp.cc

index b5f9333fc22e5e4e8b1c223a4af055e64426a150..0bcc5301317821e676c9593fb1d5e839e5370b8c 100644 (file)
@@ -6406,6 +6406,11 @@ vectorizable_bb_reduc_epilogue (slp_instance instance,
                    vectype, 0, vect_body);
   record_stmt_cost (cost_vec, 1, vec_to_scalar, instance->root_stmts[0],
                    vectype, 0, vect_body);
+
+  /* Since we replace all stmts of a possibly longer scalar reduction
+     chain account for the extra scalar stmts for that.  */
+  record_stmt_cost (cost_vec, instance->remain_defs.length (), scalar_stmt,
+                   instance->root_stmts[0], 0, vect_body);
   return true;
 }