]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Cost truth_value exprs in i386 vectorizer costs.
authorJan Hubicka <hubicka@ucw.cz>
Wed, 23 Apr 2025 15:04:32 +0000 (17:04 +0200)
committerJan Hubicka <hubicka@ucw.cz>
Wed, 23 Apr 2025 15:05:31 +0000 (17:05 +0200)
this patch implements costing of truth_value exprs.  I.e.
  a = b < c;
Those seems to be now the most common operations that goes to the addss path
except for in->fp and fp->int conversions.

For integer we use setcc, for FP there is CMccSS and variants which sets the
destination register a s a mast (i.e. -1 on true and 0 on false).  Technically
these needs res&1 to get into 1 on true, 0 on false, but looking on examples
where this is used, it is common that the resulting code is optimized avoiding
need for this (except for cases wehre result is directly saved to memory).
For this reason I am accounting only one sse_op (CMccSS) itself.

gcc/ChangeLog:

* config/i386/i386.cc (ix86_vector_costs::add_stmt_cost): Cost truth_value
exprs.

gcc/config/i386/i386.cc

index aef41454d9d51bc2454eaafcec5179ac9e6a3e4f..3b4dfd9a99038f9a58003a8714ebb9d6de2fdcc7 100644 (file)
@@ -25464,7 +25464,25 @@ ix86_vector_costs::add_stmt_cost (int count, vect_cost_for_stmt kind,
          else
            stmt_cost = ix86_cost->add;
          break;
+
        default:
+         if (truth_value_p (subcode))
+           {
+             if (SSE_FLOAT_MODE_SSEMATH_OR_HFBF_P (mode))
+               /* CMPccS? insructions are cheap, so use sse_op.  While they
+                  produce a mask which may need to be turned to 0/1 by and,
+                  expect that this will be optimized away in a common case.  */
+               stmt_cost = ix86_cost->sse_op;
+             else if (X87_FLOAT_MODE_P (mode))
+               /* fcmp + setcc.  */
+               stmt_cost = ix86_cost->fadd + ix86_cost->add;
+             else if (VECTOR_MODE_P (mode))
+               stmt_cost = ix86_vec_cost (mode, ix86_cost->sse_op);
+             else
+               /* setcc.  */
+               stmt_cost = ix86_cost->add;
+             break;
+           }
          break;
        }
     }