Blame SOURCES/gcc11-tremont1.patch

44ce1d
From cbd145b132c79c36e990a0eaf10c86159009f18d Mon Sep 17 00:00:00 2001
44ce1d
From: "H.J. Lu" <hjl.tools@gmail.com>
44ce1d
Date: Wed, 15 Sep 2021 14:15:10 +0800
44ce1d
Subject: [PATCH 1/3] x86: Update -mtune=tremont
44ce1d
44ce1d
Initial -mtune=tremont update
44ce1d
44ce1d
1. Use Haswell scheduling model.
44ce1d
2. Assume that stack engine allows to execute push&pop instructions in
44ce1d
parall.
44ce1d
3. Prepare for scheduling pass as -mtune=generic.
44ce1d
4. Use the same issue rate as -mtune=generic.
44ce1d
5. Enable partial_reg_dependency.
44ce1d
6. Disable accumulate_outgoing_args
44ce1d
7. Enable use_leave
44ce1d
8. Enable push_memory
44ce1d
9. Disable four_jump_limit
44ce1d
10. Disable opt_agu
44ce1d
11. Disable avoid_lea_for_addr
44ce1d
12. Disable avoid_mem_opnd_for_cmove
44ce1d
13. Enable misaligned_move_string_pro_epilogues
44ce1d
14. Enable use_cltd
44ce1d
16. Enable avoid_false_dep_for_bmi
44ce1d
17. Enable avoid_mfence
44ce1d
18. Disable expand_abs
44ce1d
19. Enable sse_typeless_stores
44ce1d
20. Enable sse_load0_by_pxor
44ce1d
21. Disable split_mem_opnd_for_fp_converts
44ce1d
22. Disable slow_pshufb
44ce1d
23. Enable partial_reg_dependency
44ce1d
44ce1d
This is the first patch to tune for Tremont.  With all patches applied,
44ce1d
performance impacts on SPEC CPU 2017 are:
44ce1d
44ce1d
500.perlbench_r         1.81%
44ce1d
502.gcc_r               0.57%
44ce1d
505.mcf_r               1.16%
44ce1d
520.omnetpp_r           0.00%
44ce1d
523.xalancbmk_r         0.00%
44ce1d
525.x264_r              4.55%
44ce1d
531.deepsjeng_r         0.00%
44ce1d
541.leela_r             0.39%
44ce1d
548.exchange2_r         1.13%
44ce1d
557.xz_r                0.00%
44ce1d
geomean for intrate     0.95%
44ce1d
503.bwaves_r            0.00%
44ce1d
507.cactuBSSN_r         6.94%
44ce1d
508.namd_r              12.37%
44ce1d
510.parest_r            1.01%
44ce1d
511.povray_r            3.70%
44ce1d
519.lbm_r               36.61%
44ce1d
521.wrf_r               8.79%
44ce1d
526.blender_r           2.91%
44ce1d
527.cam4_r              6.23%
44ce1d
538.imagick_r           0.28%
44ce1d
544.nab_r               21.99%
44ce1d
549.fotonik3d_r         3.63%
44ce1d
554.roms_r              -1.20%
44ce1d
geomean for fprate      7.50%
44ce1d
44ce1d
gcc/ChangeLog
44ce1d
44ce1d
	* common/config/i386/i386-common.c: Use Haswell scheduling model
44ce1d
	for Tremont.
44ce1d
	* config/i386/i386.c (ix86_sched_init_global): Prepare for Tremont
44ce1d
	scheduling pass.
44ce1d
	* config/i386/x86-tune-sched.c (ix86_issue_rate): Change Tremont
44ce1d
	issue rate to 4.
44ce1d
	(ix86_adjust_cost): Handle Tremont.
44ce1d
	* config/i386/x86-tune.def (X86_TUNE_SSE_PARTIAL_REG_DEPENDENCY):
44ce1d
	Enable for Tremont.
44ce1d
	(X86_TUNE_USE_LEAVE): Likewise.
44ce1d
	(X86_TUNE_PUSH_MEMORY): Likewise.
44ce1d
	(X86_TUNE_MISALIGNED_MOVE_STRING_PRO_EPILOGUES): Likewise.
44ce1d
	(X86_TUNE_USE_CLTD): Likewise.
44ce1d
	(X86_TUNE_AVOID_FALSE_DEP_FOR_BMI): Likewise.
44ce1d
	(X86_TUNE_AVOID_MFENCE): Likewise.
44ce1d
	(X86_TUNE_SSE_TYPELESS_STORES): Likewise.
44ce1d
	(X86_TUNE_SSE_LOAD0_BY_PXOR): Likewise.
44ce1d
	(X86_TUNE_ACCUMULATE_OUTGOING_ARGS): Disable for Tremont.
44ce1d
	(X86_TUNE_FOUR_JUMP_LIMIT): Likewise.
44ce1d
	(X86_TUNE_OPT_AGU): Likewise.
44ce1d
	(X86_TUNE_AVOID_LEA_FOR_ADDR): Likewise.
44ce1d
	(X86_TUNE_AVOID_MEM_OPND_FOR_CMOVE): Likewise.
44ce1d
	(X86_TUNE_EXPAND_ABS): Likewise.
44ce1d
	(X86_TUNE_SPLIT_MEM_OPND_FOR_FP_CONVERTS): Likewise.
44ce1d
	(X86_TUNE_SLOW_PSHUFB): Likewise.
44ce1d
---
44ce1d
 gcc/common/config/i386/i386-common.c |  2 +-
44ce1d
 gcc/config/i386/i386.c               |  1 +
44ce1d
 gcc/config/i386/x86-tune-sched.c     |  2 ++
44ce1d
 gcc/config/i386/x86-tune.def         | 37 ++++++++++++++--------------
44ce1d
 4 files changed, 23 insertions(+), 19 deletions(-)
44ce1d
44ce1d
diff --git a/gcc/common/config/i386/i386-common.c b/gcc/common/config/i386/i386-common.c
44ce1d
index 38dbb9d9263..ef382ec9a22 100644
44ce1d
--- a/gcc/common/config/i386/i386-common.c
44ce1d
+++ b/gcc/common/config/i386/i386-common.c
44ce1d
@@ -1916,7 +1916,7 @@ const pta processor_alias_table[] =
44ce1d
     M_CPU_TYPE (INTEL_GOLDMONT), P_PROC_SSE4_2},
44ce1d
   {"goldmont-plus", PROCESSOR_GOLDMONT_PLUS, CPU_GLM, PTA_GOLDMONT_PLUS,
44ce1d
     M_CPU_TYPE (INTEL_GOLDMONT_PLUS), P_PROC_SSE4_2},
44ce1d
-  {"tremont", PROCESSOR_TREMONT, CPU_GLM, PTA_TREMONT,
44ce1d
+  {"tremont", PROCESSOR_TREMONT, CPU_HASWELL, PTA_TREMONT,
44ce1d
     M_CPU_TYPE (INTEL_TREMONT), P_PROC_SSE4_2},
44ce1d
   {"knl", PROCESSOR_KNL, CPU_SLM, PTA_KNL,
44ce1d
     M_CPU_TYPE (INTEL_KNL), P_PROC_AVX512F},
44ce1d
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
44ce1d
index 42c47d2b12b..fc2a27b5cbf 100644
44ce1d
--- a/gcc/config/i386/i386.c
44ce1d
+++ b/gcc/config/i386/i386.c
44ce1d
@@ -16732,6 +16732,7 @@ ix86_sched_init_global (FILE *, int, int)
44ce1d
     case PROCESSOR_NEHALEM:
44ce1d
     case PROCESSOR_SANDYBRIDGE:
44ce1d
     case PROCESSOR_HASWELL:
44ce1d
+    case PROCESSOR_TREMONT:
44ce1d
     case PROCESSOR_GENERIC:
44ce1d
       /* Do not perform multipass scheduling for pre-reload schedule
44ce1d
          to save compile time.  */
44ce1d
diff --git a/gcc/config/i386/x86-tune-sched.c b/gcc/config/i386/x86-tune-sched.c
44ce1d
index 2bcc64b865a..278035eec0b 100644
44ce1d
--- a/gcc/config/i386/x86-tune-sched.c
44ce1d
+++ b/gcc/config/i386/x86-tune-sched.c
44ce1d
@@ -71,6 +71,7 @@ ix86_issue_rate (void)
44ce1d
     case PROCESSOR_NEHALEM:
44ce1d
     case PROCESSOR_SANDYBRIDGE:
44ce1d
     case PROCESSOR_HASWELL:
44ce1d
+    case PROCESSOR_TREMONT:
44ce1d
     case PROCESSOR_GENERIC:
44ce1d
       return 4;
44ce1d
 
44ce1d
@@ -430,6 +431,7 @@ ix86_adjust_cost (rtx_insn *insn, int dep_type, rtx_insn *dep_insn, int cost,
44ce1d
     case PROCESSOR_NEHALEM:
44ce1d
     case PROCESSOR_SANDYBRIDGE:
44ce1d
     case PROCESSOR_HASWELL:
44ce1d
+    case PROCESSOR_TREMONT:
44ce1d
     case PROCESSOR_GENERIC:
44ce1d
       /* Stack engine allows to execute push&pop instructions in parall.  */
44ce1d
       if ((insn_type == TYPE_PUSH || insn_type == TYPE_POP)
44ce1d
diff --git a/gcc/config/i386/x86-tune.def b/gcc/config/i386/x86-tune.def
44ce1d
index eb057a67750..6bd7087a03f 100644
44ce1d
--- a/gcc/config/i386/x86-tune.def
44ce1d
+++ b/gcc/config/i386/x86-tune.def
44ce1d
@@ -62,7 +62,7 @@ DEF_TUNE (X86_TUNE_PARTIAL_REG_DEPENDENCY, "partial_reg_dependency",
44ce1d
    that can be partly masked by careful scheduling of moves.  */
44ce1d
 DEF_TUNE (X86_TUNE_SSE_PARTIAL_REG_DEPENDENCY, "sse_partial_reg_dependency",
44ce1d
           m_PPRO | m_P4_NOCONA | m_CORE_ALL | m_BONNELL | m_AMDFAM10
44ce1d
-	  | m_BDVER | m_ZNVER | m_GENERIC)
44ce1d
+	  | m_BDVER | m_ZNVER | m_TREMONT | m_GENERIC)
44ce1d
 
44ce1d
 /* X86_TUNE_SSE_SPLIT_REGS: Set for machines where the type and dependencies
44ce1d
    are resolved on SSE register parts instead of whole registers, so we may
44ce1d
@@ -136,7 +136,7 @@ DEF_TUNE (X86_TUNE_FUSE_ALU_AND_BRANCH, "fuse_alu_and_branch",
44ce1d
 
44ce1d
 DEF_TUNE (X86_TUNE_ACCUMULATE_OUTGOING_ARGS, "accumulate_outgoing_args",
44ce1d
 	  m_PPRO | m_P4_NOCONA | m_BONNELL | m_SILVERMONT | m_KNL | m_KNM | m_INTEL
44ce1d
-	  | m_GOLDMONT | m_GOLDMONT_PLUS | m_TREMONT | m_ATHLON_K8)
44ce1d
+	  | m_GOLDMONT | m_GOLDMONT_PLUS | m_ATHLON_K8)
44ce1d
 
44ce1d
 /* X86_TUNE_PROLOGUE_USING_MOVE: Do not use push/pop in prologues that are
44ce1d
    considered on critical path.  */
44ce1d
@@ -150,14 +150,15 @@ DEF_TUNE (X86_TUNE_EPILOGUE_USING_MOVE, "epilogue_using_move",
44ce1d
 
44ce1d
 /* X86_TUNE_USE_LEAVE: Use "leave" instruction in epilogues where it fits.  */
44ce1d
 DEF_TUNE (X86_TUNE_USE_LEAVE, "use_leave",
44ce1d
-	  m_386 | m_CORE_ALL | m_K6_GEODE | m_AMD_MULTIPLE | m_GENERIC)
44ce1d
+	  m_386 | m_CORE_ALL | m_K6_GEODE | m_AMD_MULTIPLE | m_TREMONT
44ce1d
+	  | m_GENERIC)
44ce1d
 
44ce1d
 /* X86_TUNE_PUSH_MEMORY: Enable generation of "push mem" instructions.
44ce1d
    Some chips, like 486 and Pentium works faster with separate load
44ce1d
    and push instructions.  */
44ce1d
 DEF_TUNE (X86_TUNE_PUSH_MEMORY, "push_memory",
44ce1d
           m_386 | m_P4_NOCONA | m_CORE_ALL | m_K6_GEODE | m_AMD_MULTIPLE
44ce1d
-          | m_GENERIC)
44ce1d
+          | m_TREMONT | m_GENERIC)
44ce1d
 
44ce1d
 /* X86_TUNE_SINGLE_PUSH: Enable if single push insn is preferred
44ce1d
    over esp subtraction.  */
44ce1d
@@ -198,8 +199,7 @@ DEF_TUNE (X86_TUNE_PAD_RETURNS, "pad_returns",
44ce1d
    than 4 branch instructions in the 16 byte window.  */
44ce1d
 DEF_TUNE (X86_TUNE_FOUR_JUMP_LIMIT, "four_jump_limit",
44ce1d
           m_PPRO | m_P4_NOCONA | m_BONNELL | m_SILVERMONT | m_KNL | m_KNM
44ce1d
-	  | m_GOLDMONT | m_GOLDMONT_PLUS | m_TREMONT | m_INTEL | m_ATHLON_K8
44ce1d
-	  | m_AMDFAM10)
44ce1d
+	  | m_GOLDMONT | m_GOLDMONT_PLUS | m_INTEL | m_ATHLON_K8 | m_AMDFAM10)
44ce1d
 
44ce1d
 /*****************************************************************************/
44ce1d
 /* Integer instruction selection tuning                                      */
44ce1d
@@ -240,11 +240,11 @@ DEF_TUNE (X86_TUNE_INTEGER_DFMODE_MOVES, "integer_dfmode_moves",
44ce1d
 /* X86_TUNE_OPT_AGU: Optimize for Address Generation Unit. This flag
44ce1d
    will impact LEA instruction selection. */
44ce1d
 DEF_TUNE (X86_TUNE_OPT_AGU, "opt_agu", m_BONNELL | m_SILVERMONT | m_KNL
44ce1d
-	 | m_KNM | m_GOLDMONT | m_GOLDMONT_PLUS | m_TREMONT | m_INTEL)
44ce1d
+	 | m_KNM | m_GOLDMONT | m_GOLDMONT_PLUS | m_INTEL)
44ce1d
 
44ce1d
 /* X86_TUNE_AVOID_LEA_FOR_ADDR: Avoid lea for address computation.  */
44ce1d
 DEF_TUNE (X86_TUNE_AVOID_LEA_FOR_ADDR, "avoid_lea_for_addr",
44ce1d
-	  m_BONNELL | m_SILVERMONT | m_GOLDMONT | m_GOLDMONT_PLUS | m_TREMONT
44ce1d
+	  m_BONNELL | m_SILVERMONT | m_GOLDMONT | m_GOLDMONT_PLUS
44ce1d
 	  | m_KNL | m_KNM)
44ce1d
 
44ce1d
 /* X86_TUNE_SLOW_IMUL_IMM32_MEM: Imul of 32-bit constant and memory is
44ce1d
@@ -263,7 +263,7 @@ DEF_TUNE (X86_TUNE_SLOW_IMUL_IMM8, "slow_imul_imm8",
44ce1d
    a conditional move.  */
44ce1d
 DEF_TUNE (X86_TUNE_AVOID_MEM_OPND_FOR_CMOVE, "avoid_mem_opnd_for_cmove",
44ce1d
 	  m_BONNELL | m_SILVERMONT | m_GOLDMONT | m_GOLDMONT_PLUS | m_KNL
44ce1d
-	  | m_KNM | m_TREMONT | m_INTEL)
44ce1d
+	  | m_KNM | m_INTEL)
44ce1d
 
44ce1d
 /* X86_TUNE_SINGLE_STRINGOP: Enable use of single string operations, such
44ce1d
    as MOVS and STOS (without a REP prefix) to move/set sequences of bytes.  */
44ce1d
@@ -282,7 +282,8 @@ DEF_TUNE (X86_TUNE_PREFER_KNOWN_REP_MOVSB_STOSB,
44ce1d
    FIXME: This may actualy be a win on more targets than listed here.  */
44ce1d
 DEF_TUNE (X86_TUNE_MISALIGNED_MOVE_STRING_PRO_EPILOGUES,
44ce1d
 	  "misaligned_move_string_pro_epilogues",
44ce1d
-	  m_386 | m_486 | m_CORE_ALL | m_AMD_MULTIPLE | m_GENERIC)
44ce1d
+	  m_386 | m_486 | m_CORE_ALL | m_AMD_MULTIPLE | m_TREMONT
44ce1d
+	  | m_GENERIC)
44ce1d
 
44ce1d
 /* X86_TUNE_USE_SAHF: Controls use of SAHF.  */
44ce1d
 DEF_TUNE (X86_TUNE_USE_SAHF, "use_sahf",
44ce1d
@@ -294,7 +295,7 @@ DEF_TUNE (X86_TUNE_USE_SAHF, "use_sahf",
44ce1d
 /* X86_TUNE_USE_CLTD: Controls use of CLTD and CTQO instructions.  */
44ce1d
 DEF_TUNE (X86_TUNE_USE_CLTD, "use_cltd",
44ce1d
 	  ~(m_PENT | m_LAKEMONT | m_BONNELL | m_SILVERMONT | m_KNL | m_KNM | m_INTEL
44ce1d
-	    | m_K6 | m_GOLDMONT | m_GOLDMONT_PLUS | m_TREMONT))
44ce1d
+	    | m_K6 | m_GOLDMONT | m_GOLDMONT_PLUS))
44ce1d
 
44ce1d
 /* X86_TUNE_USE_BT: Enable use of BT (bit test) instructions.  */
44ce1d
 DEF_TUNE (X86_TUNE_USE_BT, "use_bt",
44ce1d
@@ -305,7 +306,7 @@ DEF_TUNE (X86_TUNE_USE_BT, "use_bt",
44ce1d
 /* X86_TUNE_AVOID_FALSE_DEP_FOR_BMI: Avoid false dependency
44ce1d
    for bit-manipulation instructions.  */
44ce1d
 DEF_TUNE (X86_TUNE_AVOID_FALSE_DEP_FOR_BMI, "avoid_false_dep_for_bmi",
44ce1d
-	  m_SANDYBRIDGE | m_CORE_AVX2 | m_GENERIC)
44ce1d
+	  m_SANDYBRIDGE | m_CORE_AVX2 | m_TREMONT | m_GENERIC)
44ce1d
 
44ce1d
 /* X86_TUNE_ADJUST_UNROLL: This enables adjusting the unroll factor based
44ce1d
    on hardware capabilities. Bdver3 hardware has a loop buffer which makes
44ce1d
@@ -321,14 +322,14 @@ DEF_TUNE (X86_TUNE_ONE_IF_CONV_INSN, "one_if_conv_insn",
44ce1d
 
44ce1d
 /* X86_TUNE_AVOID_MFENCE: Use lock prefixed instructions instead of mfence.  */
44ce1d
 DEF_TUNE (X86_TUNE_AVOID_MFENCE, "avoid_mfence",
44ce1d
-	 m_CORE_ALL | m_BDVER | m_ZNVER | m_GENERIC)
44ce1d
+	 m_CORE_ALL | m_BDVER | m_ZNVER | m_TREMONT | m_GENERIC)
44ce1d
 
44ce1d
 /* X86_TUNE_EXPAND_ABS: This enables a new abs pattern by
44ce1d
    generating instructions for abs (x) = (((signed) x >> (W-1) ^ x) -
44ce1d
    (signed) x >> (W-1)) instead of cmove or SSE max/abs instructions.  */
44ce1d
 DEF_TUNE (X86_TUNE_EXPAND_ABS, "expand_abs",
44ce1d
 	  m_CORE_ALL | m_SILVERMONT | m_KNL | m_KNM | m_GOLDMONT
44ce1d
-	  | m_GOLDMONT_PLUS | m_TREMONT )
44ce1d
+	  | m_GOLDMONT_PLUS)
44ce1d
 
44ce1d
 /*****************************************************************************/
44ce1d
 /* 387 instruction selection tuning                                          */
44ce1d
@@ -386,13 +387,13 @@ DEF_TUNE (X86_TUNE_SSE_PACKED_SINGLE_INSN_OPTIMAL, "sse_packed_single_insn_optim
44ce1d
 
44ce1d
 /* X86_TUNE_SSE_TYPELESS_STORES: Always movaps/movups for 128bit stores.   */
44ce1d
 DEF_TUNE (X86_TUNE_SSE_TYPELESS_STORES, "sse_typeless_stores",
44ce1d
-	  m_AMD_MULTIPLE | m_CORE_ALL | m_GENERIC)
44ce1d
+	  m_AMD_MULTIPLE | m_CORE_ALL | m_TREMONT | m_GENERIC)
44ce1d
 
44ce1d
 /* X86_TUNE_SSE_LOAD0_BY_PXOR: Always use pxor to load0 as opposed to
44ce1d
    xorps/xorpd and other variants.  */
44ce1d
 DEF_TUNE (X86_TUNE_SSE_LOAD0_BY_PXOR, "sse_load0_by_pxor",
44ce1d
 	  m_PPRO | m_P4_NOCONA | m_CORE_ALL | m_BDVER | m_BTVER | m_ZNVER
44ce1d
-	  | m_GENERIC)
44ce1d
+	  | m_TREMONT | m_GENERIC)
44ce1d
 
44ce1d
 /* X86_TUNE_INTER_UNIT_MOVES_TO_VEC: Enable moves in from integer
44ce1d
    to SSE registers.  If disabled, the moves will be done by storing
44ce1d
@@ -419,7 +420,7 @@ DEF_TUNE (X86_TUNE_INTER_UNIT_CONVERSIONS, "inter_unit_conversions",
44ce1d
    fp converts to destination register.  */
44ce1d
 DEF_TUNE (X86_TUNE_SPLIT_MEM_OPND_FOR_FP_CONVERTS, "split_mem_opnd_for_fp_converts",
44ce1d
 	  m_SILVERMONT | m_KNL | m_KNM | m_GOLDMONT | m_GOLDMONT_PLUS
44ce1d
-	  | m_TREMONT | m_INTEL)
44ce1d
+	  | m_INTEL)
44ce1d
 
44ce1d
 /* X86_TUNE_USE_VECTOR_FP_CONVERTS: Prefer vector packed SSE conversion
44ce1d
    from FP to FP.  This form of instructions avoids partial write to the
44ce1d
@@ -434,7 +435,7 @@ DEF_TUNE (X86_TUNE_USE_VECTOR_CONVERTS, "use_vector_converts", m_AMDFAM10)
44ce1d
 /* X86_TUNE_SLOW_SHUFB: Indicates tunings with slow pshufb instruction.  */
44ce1d
 DEF_TUNE (X86_TUNE_SLOW_PSHUFB, "slow_pshufb",
44ce1d
 	  m_BONNELL | m_SILVERMONT | m_KNL | m_KNM | m_GOLDMONT
44ce1d
-	  | m_GOLDMONT_PLUS | m_TREMONT | m_INTEL)
44ce1d
+	  | m_GOLDMONT_PLUS | m_INTEL)
44ce1d
 
44ce1d
 /* X86_TUNE_AVOID_4BYTE_PREFIXES: Avoid instructions requiring 4+ bytes of prefixes.  */
44ce1d
 DEF_TUNE (X86_TUNE_AVOID_4BYTE_PREFIXES, "avoid_4byte_prefixes",
44ce1d
-- 
44ce1d
2.18.2
44ce1d