|
|
a46658 |
From c4c7244349999f91ef2a7cd2108eee0372490be9 Mon Sep 17 00:00:00 2001
|
|
|
a46658 |
From: "H.J. Lu" <hjl.tools@gmail.com>
|
|
|
a46658 |
Date: Wed, 15 Sep 2021 14:18:21 +0800
|
|
|
a46658 |
Subject: [PATCH 3/3] x86: Add TARGET_SSE_PARTIAL_REG_[FP_]CONVERTS_DEPENDENCY
|
|
|
a46658 |
|
|
|
a46658 |
1. Replace TARGET_SSE_PARTIAL_REG_DEPENDENCY with
|
|
|
a46658 |
TARGET_SSE_PARTIAL_REG_FP_CONVERTS_DEPENDENCY in SSE FP to FP splitters.
|
|
|
a46658 |
2. Replace TARGET_SSE_PARTIAL_REG_DEPENDENCY with
|
|
|
a46658 |
TARGET_SSE_PARTIAL_REG_CONVERTS_DEPENDENCY in SSE INT to FP splitters.
|
|
|
a46658 |
|
|
|
a46658 |
gcc/
|
|
|
a46658 |
|
|
|
a46658 |
* config/i386/i386.h (TARGET_SSE_PARTIAL_REG_FP_CONVERTS_DEPENDENCY):
|
|
|
a46658 |
New.
|
|
|
a46658 |
(TARGET_SSE_PARTIAL_REG_CONVERTS_DEPENDENCY): Likewise.
|
|
|
a46658 |
* config/i386/i386.md (SSE FP to FP splitters): Replace
|
|
|
a46658 |
TARGET_SSE_PARTIAL_REG_DEPENDENCY with
|
|
|
a46658 |
TARGET_SSE_PARTIAL_REG_FP_CONVERTS_DEPENDENCY.
|
|
|
a46658 |
(SSE INT to FP splitter): Replace TARGET_SSE_PARTIAL_REG_DEPENDENCY
|
|
|
a46658 |
with TARGET_SSE_PARTIAL_REG_CONVERTS_DEPENDENCY.
|
|
|
a46658 |
* config/i386/x86-tune.def
|
|
|
a46658 |
(X86_TUNE_SSE_PARTIAL_REG_FP_CONVERTS_DEPENDENCY): New.
|
|
|
a46658 |
(X86_TUNE_SSE_PARTIAL_REG_CONVERTS_DEPENDENCY): Likewise.
|
|
|
a46658 |
|
|
|
a46658 |
gcc/testsuite/
|
|
|
a46658 |
|
|
|
a46658 |
* gcc.target/i386/sse-covert-1.c: Likewise.
|
|
|
a46658 |
* gcc.target/i386/sse-fp-covert-1.c: Likewise.
|
|
|
a46658 |
* gcc.target/i386/sse-int-covert-1.c: Likewise.
|
|
|
a46658 |
---
|
|
|
a46658 |
gcc/config/i386/i386.h | 4 ++++
|
|
|
a46658 |
gcc/config/i386/i386.md | 9 ++++++---
|
|
|
a46658 |
gcc/config/i386/x86-tune.def | 15 +++++++++++++++
|
|
|
a46658 |
gcc/testsuite/gcc.target/i386/sse-covert-1.c | 19 +++++++++++++++++++
|
|
|
a46658 |
.../gcc.target/i386/sse-fp-covert-1.c | 15 +++++++++++++++
|
|
|
a46658 |
.../gcc.target/i386/sse-int-covert-1.c | 14 ++++++++++++++
|
|
|
a46658 |
6 files changed, 73 insertions(+), 3 deletions(-)
|
|
|
a46658 |
create mode 100644 gcc/testsuite/gcc.target/i386/sse-covert-1.c
|
|
|
a46658 |
create mode 100644 gcc/testsuite/gcc.target/i386/sse-fp-covert-1.c
|
|
|
a46658 |
create mode 100644 gcc/testsuite/gcc.target/i386/sse-int-covert-1.c
|
|
|
a46658 |
|
|
|
a46658 |
diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h
|
|
|
a46658 |
index 73e118900f7..5b992195df7 100644
|
|
|
a46658 |
--- a/gcc/config/i386/i386.h
|
|
|
a46658 |
+++ b/gcc/config/i386/i386.h
|
|
|
a46658 |
@@ -553,6 +553,10 @@ extern unsigned char ix86_tune_features[X86_TUNE_LAST];
|
|
|
a46658 |
ix86_tune_features[X86_TUNE_PARTIAL_REG_DEPENDENCY]
|
|
|
a46658 |
#define TARGET_SSE_PARTIAL_REG_DEPENDENCY \
|
|
|
a46658 |
ix86_tune_features[X86_TUNE_SSE_PARTIAL_REG_DEPENDENCY]
|
|
|
a46658 |
+#define TARGET_SSE_PARTIAL_REG_FP_CONVERTS_DEPENDENCY \
|
|
|
a46658 |
+ ix86_tune_features[X86_TUNE_SSE_PARTIAL_REG_FP_CONVERTS_DEPENDENCY]
|
|
|
a46658 |
+#define TARGET_SSE_PARTIAL_REG_CONVERTS_DEPENDENCY \
|
|
|
a46658 |
+ ix86_tune_features[X86_TUNE_SSE_PARTIAL_REG_CONVERTS_DEPENDENCY]
|
|
|
a46658 |
#define TARGET_SSE_UNALIGNED_LOAD_OPTIMAL \
|
|
|
a46658 |
ix86_tune_features[X86_TUNE_SSE_UNALIGNED_LOAD_OPTIMAL]
|
|
|
a46658 |
#define TARGET_SSE_UNALIGNED_STORE_OPTIMAL \
|
|
|
a46658 |
diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
|
|
|
a46658 |
index 97325e38676..053bec1c1e1 100644
|
|
|
a46658 |
--- a/gcc/config/i386/i386.md
|
|
|
a46658 |
+++ b/gcc/config/i386/i386.md
|
|
|
a46658 |
@@ -4378,7 +4378,8 @@
|
|
|
a46658 |
(float_extend:DF
|
|
|
a46658 |
(match_operand:SF 1 "nonimmediate_operand")))]
|
|
|
a46658 |
"!TARGET_AVX
|
|
|
a46658 |
- && TARGET_SSE_PARTIAL_REG_DEPENDENCY && epilogue_completed
|
|
|
a46658 |
+ && TARGET_SSE_PARTIAL_REG_FP_CONVERTS_DEPENDENCY
|
|
|
a46658 |
+ && epilogue_completed
|
|
|
a46658 |
&& optimize_function_for_speed_p (cfun)
|
|
|
a46658 |
&& (!REG_P (operands[1])
|
|
|
a46658 |
|| (!TARGET_AVX && REGNO (operands[0]) != REGNO (operands[1])))
|
|
|
a46658 |
@@ -4540,7 +4541,8 @@
|
|
|
a46658 |
(float_truncate:SF
|
|
|
a46658 |
(match_operand:DF 1 "nonimmediate_operand")))]
|
|
|
a46658 |
"!TARGET_AVX
|
|
|
a46658 |
- && TARGET_SSE_PARTIAL_REG_DEPENDENCY && epilogue_completed
|
|
|
a46658 |
+ && TARGET_SSE_PARTIAL_REG_FP_CONVERTS_DEPENDENCY
|
|
|
a46658 |
+ && epilogue_completed
|
|
|
a46658 |
&& optimize_function_for_speed_p (cfun)
|
|
|
a46658 |
&& (!REG_P (operands[1])
|
|
|
a46658 |
|| (!TARGET_AVX && REGNO (operands[0]) != REGNO (operands[1])))
|
|
|
a46658 |
@@ -5053,7 +5055,8 @@
|
|
|
a46658 |
[(set (match_operand:MODEF 0 "sse_reg_operand")
|
|
|
a46658 |
(float:MODEF (match_operand:SWI48 1 "nonimmediate_operand")))]
|
|
|
a46658 |
"!TARGET_AVX
|
|
|
a46658 |
- && TARGET_SSE_PARTIAL_REG_DEPENDENCY && epilogue_completed
|
|
|
a46658 |
+ && TARGET_SSE_PARTIAL_REG_CONVERTS_DEPENDENCY
|
|
|
a46658 |
+ && epilogue_completed
|
|
|
a46658 |
&& optimize_function_for_speed_p (cfun)
|
|
|
a46658 |
&& (!EXT_REX_SSE_REG_P (operands[0])
|
|
|
a46658 |
|| TARGET_AVX512VL)"
|
|
|
a46658 |
diff --git a/gcc/config/i386/x86-tune.def b/gcc/config/i386/x86-tune.def
|
|
|
a46658 |
index 636e0c788bf..b5166fb1316 100644
|
|
|
a46658 |
--- a/gcc/config/i386/x86-tune.def
|
|
|
a46658 |
+++ b/gcc/config/i386/x86-tune.def
|
|
|
a46658 |
@@ -64,6 +64,21 @@ 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_TREMONT | m_GENERIC)
|
|
|
a46658 |
|
|
|
a46658 |
+/* X86_TUNE_SSE_PARTIAL_REG_FP_CONVERTS_DEPENDENCY: This knob avoids
|
|
|
a46658 |
+ partial write to the destination in scalar SSE conversion from FP
|
|
|
a46658 |
+ to FP. */
|
|
|
a46658 |
+DEF_TUNE (X86_TUNE_SSE_PARTIAL_REG_FP_CONVERTS_DEPENDENCY,
|
|
|
a46658 |
+ "sse_partial_reg_fp_converts_dependency",
|
|
|
a46658 |
+ m_PPRO | m_P4_NOCONA | m_CORE_ALL | m_BONNELL | m_AMDFAM10
|
|
|
a46658 |
+ | m_BDVER | m_ZNVER | m_GENERIC)
|
|
|
a46658 |
+
|
|
|
a46658 |
+/* X86_TUNE_SSE_PARTIAL_REG_CONVERTS_DEPENDENCY: This knob avoids partial
|
|
|
a46658 |
+ write to the destination in scalar SSE conversion from integer to FP. */
|
|
|
a46658 |
+DEF_TUNE (X86_TUNE_SSE_PARTIAL_REG_CONVERTS_DEPENDENCY,
|
|
|
a46658 |
+ "sse_partial_reg_converts_dependency",
|
|
|
a46658 |
+ m_PPRO | m_P4_NOCONA | m_CORE_ALL | m_BONNELL | m_AMDFAM10
|
|
|
a46658 |
+ | m_BDVER | m_ZNVER | 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 |
maintain just lower part of scalar values in proper format leaving the
|
|
|
a46658 |
diff --git a/gcc/testsuite/gcc.target/i386/sse-covert-1.c b/gcc/testsuite/gcc.target/i386/sse-covert-1.c
|
|
|
a46658 |
new file mode 100644
|
|
|
a46658 |
index 00000000000..c30af694505
|
|
|
a46658 |
--- /dev/null
|
|
|
a46658 |
+++ b/gcc/testsuite/gcc.target/i386/sse-covert-1.c
|
|
|
a46658 |
@@ -0,0 +1,19 @@
|
|
|
a46658 |
+/* { dg-do compile } */
|
|
|
a46658 |
+/* { dg-options "-O2 -march=x86-64 -mfpmath=sse -mtune-ctrl=^sse_partial_reg_fp_converts_dependency,^sse_partial_reg_converts_dependency" } */
|
|
|
a46658 |
+
|
|
|
a46658 |
+extern float f;
|
|
|
a46658 |
+extern double d;
|
|
|
a46658 |
+extern int i;
|
|
|
a46658 |
+
|
|
|
a46658 |
+void
|
|
|
a46658 |
+foo (void)
|
|
|
a46658 |
+{
|
|
|
a46658 |
+ d = f;
|
|
|
a46658 |
+ f = i;
|
|
|
a46658 |
+}
|
|
|
a46658 |
+
|
|
|
a46658 |
+/* { dg-final { scan-assembler "cvtss2sd" } } */
|
|
|
a46658 |
+/* { dg-final { scan-assembler "cvtsi2ssl" } } */
|
|
|
a46658 |
+/* { dg-final { scan-assembler-not "cvtps2pd" } } */
|
|
|
a46658 |
+/* { dg-final { scan-assembler-not "cvtdq2ps" } } */
|
|
|
a46658 |
+/* { dg-final { scan-assembler-not "pxor" } } */
|
|
|
a46658 |
diff --git a/gcc/testsuite/gcc.target/i386/sse-fp-covert-1.c b/gcc/testsuite/gcc.target/i386/sse-fp-covert-1.c
|
|
|
a46658 |
new file mode 100644
|
|
|
a46658 |
index 00000000000..b6567e60e3e
|
|
|
a46658 |
--- /dev/null
|
|
|
a46658 |
+++ b/gcc/testsuite/gcc.target/i386/sse-fp-covert-1.c
|
|
|
a46658 |
@@ -0,0 +1,15 @@
|
|
|
a46658 |
+/* { dg-do compile } */
|
|
|
a46658 |
+/* { dg-options "-O2 -march=x86-64 -mfpmath=sse -mtune-ctrl=^sse_partial_reg_fp_converts_dependency" } */
|
|
|
a46658 |
+
|
|
|
a46658 |
+extern float f;
|
|
|
a46658 |
+extern double d;
|
|
|
a46658 |
+
|
|
|
a46658 |
+void
|
|
|
a46658 |
+foo (void)
|
|
|
a46658 |
+{
|
|
|
a46658 |
+ d = f;
|
|
|
a46658 |
+}
|
|
|
a46658 |
+
|
|
|
a46658 |
+/* { dg-final { scan-assembler "cvtss2sd" } } */
|
|
|
a46658 |
+/* { dg-final { scan-assembler-not "cvtps2pd" } } */
|
|
|
a46658 |
+/* { dg-final { scan-assembler-not "pxor" } } */
|
|
|
a46658 |
diff --git a/gcc/testsuite/gcc.target/i386/sse-int-covert-1.c b/gcc/testsuite/gcc.target/i386/sse-int-covert-1.c
|
|
|
a46658 |
new file mode 100644
|
|
|
a46658 |
index 00000000000..107f7241def
|
|
|
a46658 |
--- /dev/null
|
|
|
a46658 |
+++ b/gcc/testsuite/gcc.target/i386/sse-int-covert-1.c
|
|
|
a46658 |
@@ -0,0 +1,14 @@
|
|
|
a46658 |
+/* { dg-do compile } */
|
|
|
a46658 |
+/* { dg-options "-O2 -march=x86-64 -mfpmath=sse -mtune-ctrl=^sse_partial_reg_converts_dependency" } */
|
|
|
a46658 |
+
|
|
|
a46658 |
+extern float f;
|
|
|
a46658 |
+extern int i;
|
|
|
a46658 |
+
|
|
|
a46658 |
+void
|
|
|
a46658 |
+foo (void)
|
|
|
a46658 |
+{
|
|
|
a46658 |
+ f = i;
|
|
|
a46658 |
+}
|
|
|
a46658 |
+
|
|
|
a46658 |
+/* { dg-final { scan-assembler "cvtsi2ssl" } } */
|
|
|
a46658 |
+/* { dg-final { scan-assembler-not "pxor" } } */
|
|
|
a46658 |
--
|
|
|
a46658 |
2.18.2
|
|
|
a46658 |
|