aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJan Hubicka <hubicka@ucw.cz>2025-04-23 17:04:32 +0200
committerJan Hubicka <hubicka@ucw.cz>2025-04-23 17:05:31 +0200
commit9b9d605d68cf27a24e8ed9d4f1ead1f00131cec1 (patch)
tree60c0fd4ce9f20c322fbf75ed97f7981f44ade56e /gcc
parentb07b5d14e3a3222a6ae681d61a36ace8b477712d (diff)
downloadgcc-9b9d605d68cf27a24e8ed9d4f1ead1f00131cec1.zip
gcc-9b9d605d68cf27a24e8ed9d4f1ead1f00131cec1.tar.gz
gcc-9b9d605d68cf27a24e8ed9d4f1ead1f00131cec1.tar.bz2
Cost truth_value exprs in i386 vectorizer costs.
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.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/config/i386/i386.cc18
1 files changed, 18 insertions, 0 deletions
diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc
index aef4145..3b4dfd9 100644
--- a/gcc/config/i386/i386.cc
+++ b/gcc/config/i386/i386.cc
@@ -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;
}
}