]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Avoid costing vector stmts with count == 0
authorRichard Biener <rguenther@suse.de>
Fri, 5 Sep 2025 09:55:50 +0000 (11:55 +0200)
committerRichard Biener <rguenther@suse.de>
Fri, 5 Sep 2025 11:11:39 +0000 (13:11 +0200)
This avoids confusing the backends.

* tree-vect-slp.cc (vectorizable_bb_reduc_epilogue): Do not
cost zero remaining scalar stmts.
(vectorizable_slp_permutation): Do not cost zero actual
permutations.
* tree-vect-stmts.cc (vectorizable_load): Likewise.

gcc/tree-vect-slp.cc
gcc/tree-vect-stmts.cc

index 6258a8eb53de10d03d244682b60d68b5c6218883..59bca1dfce7c3a37d33207d90f9e95394d56fc04 100644 (file)
@@ -8701,8 +8701,9 @@ vectorizable_bb_reduc_epilogue (slp_instance instance,
 
   /* 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);
+  if (!instance->remain_defs.is_empty ())
+    record_stmt_cost (cost_vec, instance->remain_defs.length (), scalar_stmt,
+                     instance->root_stmts[0], 0, vect_body);
   return true;
 }
 
@@ -11370,7 +11371,7 @@ vectorizable_slp_permutation (vec_info *vinfo, gimple_stmt_iterator *gsi,
   if (nperms < 0)
     return false;
 
-  if (!gsi)
+  if (!gsi && nperms != 0)
     record_stmt_cost (cost_vec, nperms, vec_perm, node, vectype, 0, vect_body);
 
   return true;
index edc669ba3e474f6247d1703907b46bd54ca5a4de..9fcc2fd084987e564f496a02af7d2b8547c11cd5 100644 (file)
@@ -11387,8 +11387,9 @@ vectorizable_load (vec_info *vinfo,
        {
          vect_transform_slp_perm_load (vinfo, slp_node, vNULL, nullptr, vf,
                                        true, &n_perms, nullptr);
-         inside_cost = record_stmt_cost (cost_vec, n_perms, vec_perm,
-                                         slp_node, 0, vect_body);
+         if (n_perms != 0)
+           inside_cost = record_stmt_cost (cost_vec, n_perms, vec_perm,
+                                           slp_node, 0, vect_body);
        }
       else
        {