aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRoger Sayle <roger@nextmovesoftware.com>2024-08-28 21:19:28 -0600
committerRoger Sayle <roger@nextmovesoftware.com>2024-08-28 21:19:28 -0600
commit3cb92be94e6581697369eeafdb67057c8cfba73f (patch)
treeacb838815e6ecbc2aaed7ffa35bfb51514843988 /gcc
parent155da081706e0e0527f01ad565b1cd6c217f5880 (diff)
downloadgcc-3cb92be94e6581697369eeafdb67057c8cfba73f.zip
gcc-3cb92be94e6581697369eeafdb67057c8cfba73f.tar.gz
gcc-3cb92be94e6581697369eeafdb67057c8cfba73f.tar.bz2
i386: Support wide immediate constants in STV.
This patch provides more accurate costs/gains for (wide) immediate constants in STV, suitably adjusting the costs/gains when the highpart and lowpart words are the same. 2024-08-28 Roger Sayle <roger@nextmovesoftware.com> gcc/ChangeLog * config/i386/i386-features.cc (timode_immed_const_gain): New function to determine the gain/cost on a CONST_WIDE_INT. (timode_scalar_chain::compute_convert_gain): Fix whitespace. <case CONST_WIDE_INT>: Provide more accurate estimates using timode_immed_const_gain. <case AND>: Handle CONSTANT_SCALAR_INT_P (src).
Diffstat (limited to 'gcc')
-rw-r--r--gcc/config/i386/i386-features.cc28
1 files changed, 27 insertions, 1 deletions
diff --git a/gcc/config/i386/i386-features.cc b/gcc/config/i386/i386-features.cc
index ca902ec..c09a5c7 100644
--- a/gcc/config/i386/i386-features.cc
+++ b/gcc/config/i386/i386-features.cc
@@ -1503,6 +1503,23 @@ general_scalar_chain::convert_insn (rtx_insn *insn)
df_insn_rescan (insn);
}
+/* Helper function to compute gain for loading an immediate constant.
+ Typically, two movabsq for TImode vs. vmovdqa for V1TImode, but
+ with numerous special cases. */
+
+static int
+timode_immed_const_gain (rtx cst)
+{
+ /* movabsq vs. movabsq+vmovq+vunpacklqdq. */
+ if (CONST_WIDE_INT_P (cst)
+ && CONST_WIDE_INT_NUNITS (cst) == 2
+ && CONST_WIDE_INT_ELT (cst, 0) == CONST_WIDE_INT_ELT (cst, 1))
+ return optimize_insn_for_size_p () ? -COSTS_N_BYTES (9)
+ : -COSTS_N_INSNS (2);
+ /* 2x movabsq ~ vmovdqa. */
+ return 0;
+}
+
/* Compute a gain for chain conversion. */
int
@@ -1549,7 +1566,14 @@ timode_scalar_chain::compute_convert_gain ()
case CONST_INT:
if (MEM_P (dst)
&& standard_sse_constant_p (src, V1TImode))
- igain = optimize_insn_for_size_p() ? COSTS_N_BYTES (11) : 1;
+ igain = optimize_insn_for_size_p () ? COSTS_N_BYTES (11) : 1;
+ break;
+
+ case CONST_WIDE_INT:
+ /* 2 x mov vs. vmovdqa. */
+ if (MEM_P (dst))
+ igain = optimize_insn_for_size_p () ? COSTS_N_BYTES (3)
+ : COSTS_N_INSNS (1);
break;
case NOT:
@@ -1562,6 +1586,8 @@ timode_scalar_chain::compute_convert_gain ()
case IOR:
if (!MEM_P (dst))
igain = COSTS_N_INSNS (1);
+ if (CONST_SCALAR_INT_P (XEXP (src, 1)))
+ igain += timode_immed_const_gain (XEXP (src, 1));
break;
case ASHIFT: