]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Add u-arch tune prefer_bcst_from_integer.
authorliuhongt <hongtao.liu@intel.com>
Mon, 19 Jan 2026 08:02:21 +0000 (00:02 -0800)
committerliuhongt <hongtao.liu@intel.com>
Thu, 22 Jan 2026 01:08:40 +0000 (17:08 -0800)
/* X86_TUNE_PREFER_BCST_FROM_INTEGER: Enable broadcast from integer for
   128/256/512-bit vector, if disabled, the move will be done by
   broadcast/load from constant pool

   broadcast from integer:
      mov    $0xa,%eax
      vmovd  %eax,%xmm0
      vpbroadcastd %xmm0,%xmm0

   broadcast/load from constant pool:
      vpbroadcastd CST.0(%rip), %xmm0  */

The tune is on by default.

gcc/ChangeLog:

PR target/123631
* config/i386/i386-expand.cc (ix86_vector_duplicate_value):
Don't force CONST_INT to reg !TARGET_PREFER_BCST_FROM_INTEGER,
force it to mem instead.
* config/i386/i386.h (TARGET_PREFER_BCST_FROM_INTEGER): New macro.
* config/i386/x86-tune.def
(X86_TUNE_PREFER_BCST_FROM_INTEGER): New tune.

gcc/config/i386/i386-expand.cc
gcc/config/i386/i386.h
gcc/config/i386/x86-tune.def

index d6525ddcdd00020b43656874dd36eb7d6f0a0a6a..a82bb4399c9bc2c920c9a0724ea965fd0cd4a2c1 100644 (file)
@@ -17361,12 +17361,21 @@ ix86_vector_duplicate_value (machine_mode mode, rtx target, rtx val)
       machine_mode innermode = GET_MODE_INNER (mode);
       rtx reg;
 
-      /* If that fails, force VAL into a register.  */
+      /* If that fails, force VAL into a register or mem.  */
 
       start_sequence ();
-      reg = force_reg (innermode, val);
-      if (GET_MODE (reg) != innermode)
-       reg = gen_lowpart (innermode, reg);
+
+      if (!TARGET_PREFER_BCST_FROM_INTEGER && CONST_INT_P (val)
+         && GET_MODE_BITSIZE (innermode) <= HOST_BITS_PER_WIDE_INT
+         && GET_MODE_BITSIZE(mode) >= 128)
+       reg = validize_mem (force_const_mem (innermode, val));
+      else
+       {
+         reg = force_reg (innermode, val);
+         if (GET_MODE (reg) != innermode)
+           reg = gen_lowpart (innermode, reg);
+       }
+
       SET_SRC (PATTERN (insn)) = gen_vec_duplicate (mode, reg);
       seq = end_sequence ();
       if (seq)
index 71bacc2205246a1726ca2b396c2dee7fe2c8df2f..888edfed88f00db6322f84cc2a353e986aebfad9 100644 (file)
@@ -409,6 +409,9 @@ extern unsigned char ix86_tune_features[X86_TUNE_LAST];
        ix86_tune_features[X86_TUNE_INTER_UNIT_MOVES_FROM_VEC]
 #define TARGET_INTER_UNIT_CONVERSIONS \
        ix86_tune_features[X86_TUNE_INTER_UNIT_CONVERSIONS]
+#define TARGET_PREFER_BCST_FROM_INTEGER \
+  ix86_tune_features[X86_TUNE_PREFER_BCST_FROM_INTEGER]
+
 #define TARGET_FOUR_JUMP_LIMIT ix86_tune_features[X86_TUNE_FOUR_JUMP_LIMIT]
 #define TARGET_SCHEDULE                ix86_tune_features[X86_TUNE_SCHEDULE]
 #define TARGET_USE_BT          ix86_tune_features[X86_TUNE_USE_BT]
index a1944620daff33112e9fdc91227343979a56ad88..53cf1a19433048d3842a0f8397c64f930ab665c4 100644 (file)
@@ -488,6 +488,21 @@ DEF_TUNE (X86_TUNE_INTER_UNIT_MOVES_FROM_VEC, "inter_unit_moves_from_vec",
 DEF_TUNE (X86_TUNE_INTER_UNIT_CONVERSIONS, "inter_unit_conversions",
           ~(m_AMDFAM10 | m_BDVER))
 
+/* X86_TUNE_PREFER_BCST_FROM_INTEGER: Enable broadcast from integer for
+   128/256/512-bit vector, if disabled, the move will be done by
+   broadcast/load from constant pool
+
+   broadcast from integer:
+      mov    $0xa,%eax
+      vmovd  %eax,%xmm0
+      vpbroadcastd %xmm0,%xmm0
+
+   broadcast/load from constant pool:
+      vpbroadcastd CST.0(%rip), %xmm0  */
+
+DEF_TUNE (X86_TUNE_PREFER_BCST_FROM_INTEGER, "prefer_bcst_from_integer",
+          m_ALL)
+
 /* X86_TUNE_SPLIT_MEM_OPND_FOR_FP_CONVERTS: Try to split memory operand for
    fp converts to destination register.  */
 DEF_TUNE (X86_TUNE_SPLIT_MEM_OPND_FOR_FP_CONVERTS, "split_mem_opnd_for_fp_converts",