]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
adjust OMP SIMD call cost
authorRichard Biener <rguenther@suse.de>
Wed, 6 May 2026 11:43:27 +0000 (13:43 +0200)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 11 May 2026 09:03:36 +0000 (11:03 +0200)
The following adds special handling to OMP SIMD vector call costs
which were not costed at all and for which a single simple vector
stmt isn't appropriate.  PR125174 shows that even when AVX imposes
more overhead (from also slightly bogus costing) than SSE, when
there's two OMP SIMD calls involved doing less of those should trump
that.

PR target/125174
* config/i386/i386.cc (ix86_vector_costs::add_stmt_cost):
Cost calls as 10 times FMA.

gcc/config/i386/i386.cc

index e73c2d7f7d04c9096514371f12eb885e3a37aa42..9aecd51119f3f85525910f29c0ca02ebf1cb9f7f 100644 (file)
@@ -26591,20 +26591,32 @@ ix86_vector_costs::add_stmt_cost (int count, vect_cost_for_stmt kind,
   if ((kind == vector_stmt || kind == scalar_stmt)
       && stmt_info
       && stmt_info->stmt
-      && (cfn = gimple_call_combined_fn (stmt_info->stmt)) != CFN_LAST)
-    switch (cfn)
-      {
-      case CFN_FMA:
-       stmt_cost = ix86_vec_cost (mode,
-                                  mode == SFmode ? ix86_cost->fmass
-                                  : ix86_cost->fmasd);
-       break;
-      case CFN_MULH:
-       stmt_cost = ix86_multiplication_cost (ix86_cost, mode);
-       break;
-      default:
-       break;
-      }
+      && is_gimple_call (stmt_info->stmt))
+    {
+      tree fndecl = gimple_call_fndecl (stmt_info->stmt);
+      cgraph_node *node;
+      if ((fndecl
+          && (node = cgraph_node::get (fndecl))
+          && node->simd_clones)
+         || gimple_call_internal_p (stmt_info->stmt, IFN_MASK_CALL))
+       stmt_cost = 10 * ix86_vec_cost (mode,
+                                       mode == SFmode ? ix86_cost->fmass
+                                       : ix86_cost->fmasd);
+      else if ((cfn = gimple_call_combined_fn (stmt_info->stmt)) != CFN_LAST)
+       switch (cfn)
+         {
+         case CFN_FMA:
+           stmt_cost = ix86_vec_cost (mode,
+                                      mode == SFmode ? ix86_cost->fmass
+                                      : ix86_cost->fmasd);
+           break;
+         case CFN_MULH:
+           stmt_cost = ix86_multiplication_cost (ix86_cost, mode);
+           break;
+         default:
+           break;
+         }
+    }
 
   if (kind == vec_promote_demote)
     {