aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLingling Kong <lingling.kong@intel.com>2024-07-25 09:42:06 +0800
committerThomas Koenig <tkoenig@gcc.gnu.org>2024-07-28 19:05:55 +0200
commit2d397e3279ed9641f14a45dbf66feb8697253fd6 (patch)
tree6a75ec707c1feb922210325b3cb89e378a63ee3d
parent583c572b7a0e8035956a45b624a05e5e6f8742ed (diff)
downloadgcc-2d397e3279ed9641f14a45dbf66feb8697253fd6.zip
gcc-2d397e3279ed9641f14a45dbf66feb8697253fd6.tar.gz
gcc-2d397e3279ed9641f14a45dbf66feb8697253fd6.tar.bz2
i386: Adjust rtx cost for imulq and imulw [PR115749]
gcc/ChangeLog: PR target/115749 * config/i386/x86-tune-costs.h (struct processor_costs): Adjust rtx_cost of imulq and imulw for COST_N_INSNS (4) to COST_N_INSNS (3). gcc/testsuite/ChangeLog: * gcc.target/i386/pr115749.c: New test.
-rw-r--r--gcc/config/i386/x86-tune-costs.h16
-rw-r--r--gcc/testsuite/gcc.target/i386/pr115749.c16
2 files changed, 24 insertions, 8 deletions
diff --git a/gcc/config/i386/x86-tune-costs.h b/gcc/config/i386/x86-tune-costs.h
index 769f334..2bfaee5 100644
--- a/gcc/config/i386/x86-tune-costs.h
+++ b/gcc/config/i386/x86-tune-costs.h
@@ -2182,7 +2182,7 @@ struct processor_costs skylake_cost = {
COSTS_N_INSNS (1), /* variable shift costs */
COSTS_N_INSNS (1), /* constant shift costs */
{COSTS_N_INSNS (3), /* cost of starting multiply for QI */
- COSTS_N_INSNS (4), /* HI */
+ COSTS_N_INSNS (3), /* HI */
COSTS_N_INSNS (3), /* SI */
COSTS_N_INSNS (3), /* DI */
COSTS_N_INSNS (3)}, /* other */
@@ -2310,7 +2310,7 @@ struct processor_costs icelake_cost = {
COSTS_N_INSNS (1), /* variable shift costs */
COSTS_N_INSNS (1), /* constant shift costs */
{COSTS_N_INSNS (3), /* cost of starting multiply for QI */
- COSTS_N_INSNS (4), /* HI */
+ COSTS_N_INSNS (3), /* HI */
COSTS_N_INSNS (3), /* SI */
COSTS_N_INSNS (3), /* DI */
COSTS_N_INSNS (3)}, /* other */
@@ -2434,9 +2434,9 @@ struct processor_costs alderlake_cost = {
COSTS_N_INSNS (1), /* variable shift costs */
COSTS_N_INSNS (1), /* constant shift costs */
{COSTS_N_INSNS (3), /* cost of starting multiply for QI */
- COSTS_N_INSNS (4), /* HI */
+ COSTS_N_INSNS (3), /* HI */
COSTS_N_INSNS (3), /* SI */
- COSTS_N_INSNS (4), /* DI */
+ COSTS_N_INSNS (3), /* DI */
COSTS_N_INSNS (4)}, /* other */
0, /* cost of multiply per each bit set */
{COSTS_N_INSNS (16), /* cost of a divide/mod for QI */
@@ -3234,9 +3234,9 @@ struct processor_costs tremont_cost = {
COSTS_N_INSNS (1), /* variable shift costs */
COSTS_N_INSNS (1), /* constant shift costs */
{COSTS_N_INSNS (3), /* cost of starting multiply for QI */
- COSTS_N_INSNS (4), /* HI */
+ COSTS_N_INSNS (3), /* HI */
COSTS_N_INSNS (3), /* SI */
- COSTS_N_INSNS (4), /* DI */
+ COSTS_N_INSNS (3), /* DI */
COSTS_N_INSNS (4)}, /* other */
0, /* cost of multiply per each bit set */
{COSTS_N_INSNS (16), /* cost of a divide/mod for QI */
@@ -3816,9 +3816,9 @@ struct processor_costs generic_cost = {
COSTS_N_INSNS (1), /* variable shift costs */
COSTS_N_INSNS (1), /* constant shift costs */
{COSTS_N_INSNS (3), /* cost of starting multiply for QI */
- COSTS_N_INSNS (4), /* HI */
+ COSTS_N_INSNS (3), /* HI */
COSTS_N_INSNS (3), /* SI */
- COSTS_N_INSNS (4), /* DI */
+ COSTS_N_INSNS (3), /* DI */
COSTS_N_INSNS (4)}, /* other */
0, /* cost of multiply per each bit set */
{COSTS_N_INSNS (16), /* cost of a divide/mod for QI */
diff --git a/gcc/testsuite/gcc.target/i386/pr115749.c b/gcc/testsuite/gcc.target/i386/pr115749.c
new file mode 100644
index 0000000..82505d6
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr115749.c
@@ -0,0 +1,16 @@
+/* PR target/115749 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -mtune=generic" } */
+/* { dg-final { scan-assembler-times "imul" 2 } } */
+/* { dg-final { scan-assembler-not "sal" } } */
+
+unsigned long func(unsigned long x)
+{
+ return x % 240;
+}
+
+unsigned short func2(unsigned short x)
+{
+ return x * 240;
+}
+