]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
vect: Add extraction cost for slp reduc
authorKewen Lin <linkw@linux.ibm.com>
Tue, 17 Aug 2021 08:18:02 +0000 (03:18 -0500)
committerKewen Lin <linkw@linux.ibm.com>
Tue, 17 Aug 2021 08:18:02 +0000 (03:18 -0500)
As Richi pointed out, currently for BB reductions we don't
actually build a SLP node with IFN_REDUC_* information,
ideally we may end up with that eventually.

For now, it's costed as shuffles and reduc operations, it
misses the cost of lane extraction.  This patch is to add
one time of vec_to_scalar cost for lane extraction, it's to
make the costings consistent and conservative for now.

gcc/ChangeLog:

* tree-vect-slp.c (vectorizable_bb_reduc_epilogue): Add the cost for
value extraction.

gcc/tree-vect-slp.c

index d169bed8e94d9d63e522f97b3136f81335208fda..4dcc70c5dd70dce3d32accb21353008d45d5660a 100644 (file)
@@ -4861,12 +4861,14 @@ vectorizable_bb_reduc_epilogue (slp_instance instance,
     return false;
 
   /* There's no way to cost a horizontal vector reduction via REDUC_FN so
-     cost log2 vector operations plus shuffles.  */
+     cost log2 vector operations plus shuffles and one extraction.  */
   unsigned steps = floor_log2 (vect_nunits_for_cost (vectype));
   record_stmt_cost (cost_vec, steps, vector_stmt, instance->root_stmts[0],
                    vectype, 0, vect_body);
   record_stmt_cost (cost_vec, steps, vec_perm, instance->root_stmts[0],
                    vectype, 0, vect_body);
+  record_stmt_cost (cost_vec, 1, vec_to_scalar, instance->root_stmts[0],
+                   vectype, 0, vect_body);
   return true;
 }