]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
i386: Adjust rtx cost for imulq and imulw [PR115749]
authorLingling Kong <lingling.kong@intel.com>
Thu, 25 Jul 2024 01:42:06 +0000 (09:42 +0800)
committerThomas Koenig <tkoenig@gcc.gnu.org>
Sun, 28 Jul 2024 17:05:55 +0000 (19:05 +0200)
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.

gcc/config/i386/x86-tune-costs.h
gcc/testsuite/gcc.target/i386/pr115749.c [new file with mode: 0644]

index 769f334e5318e76559eff1d37317704e894df0bc..2bfaee554d53601f2b289d75d772752becbc9e3f 100644 (file)
@@ -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 (file)
index 0000000..82505d6
--- /dev/null
@@ -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;
+}
+