Blame SOURCES/gcc11-tremont1.patch

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