I've missed MULT_EXPR handling is globbed with MULT_HIGHPART_EXPR
handling, but the DImode highpart multiplication change should of
course not apply to MULT_EXPR.

Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.

        PR target/127769
        * config/i386/i386.cc (ix86_vector_costs::add_stmt_cost):
        Separate MULT_EXPR and MULT_HIGHPART_EXPR handling.

        * gcc.target/i386/vect-mulq-1.c: New testcase.
---
 gcc/config/i386/i386.cc                     | 12 +++++++-----
 gcc/testsuite/gcc.target/i386/vect-mulq-1.c | 13 +++++++++++++
 2 files changed, 20 insertions(+), 5 deletions(-)
 create mode 100644 gcc/testsuite/gcc.target/i386/vect-mulq-1.c

diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc
index fdd7bcc020a..553fa046fa9 100644
--- a/gcc/config/i386/i386.cc
+++ b/gcc/config/i386/i386.cc
@@ -26708,9 +26708,6 @@ ix86_vector_costs::add_stmt_cost (int count, 
vect_cost_for_stmt kind,
                                       : ix86_cost->sse_op);
          break;
 
-       case MULT_EXPR:
-         /* For MULT_HIGHPART_EXPR, x86 only supports pmulhw,
-            take it as MULT_EXPR.  */
        case MULT_HIGHPART_EXPR:
          if (kind == vector_stmt && GET_MODE_INNER (mode) == DImode)
            {
@@ -26721,10 +26718,15 @@ ix86_vector_costs::add_stmt_cost (int count, 
vect_cost_for_stmt kind,
              stmt_cost += ix86_vec_cost (mode, ix86_cost->sse_op) * 10;
            }
          else
+           /* For MULT_HIGHPART_EXPR, x86 only supports pmulhw,
+              take it as MULT_EXPR.  */
            stmt_cost = ix86_multiplication_cost (ix86_cost, mode);
          break;
-         /* There's no direct instruction for WIDEN_MULT_EXPR,
-            take emulation into account.  */
+       case MULT_EXPR:
+         stmt_cost = ix86_multiplication_cost (ix86_cost, mode);
+         break;
+       /* There's no direct instruction for WIDEN_MULT_EXPR,
+          take emulation into account.  */
        case WIDEN_MULT_EXPR:
          stmt_cost = ix86_widen_mult_cost (ix86_cost, mode,
                                            TYPE_UNSIGNED (vectype));
diff --git a/gcc/testsuite/gcc.target/i386/vect-mulq-1.c 
b/gcc/testsuite/gcc.target/i386/vect-mulq-1.c
new file mode 100644
index 00000000000..0ec961728f9
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/vect-mulq-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -mavx512vl -mavx512dq" } */
+
+typedef unsigned long long u64;
+
+void
+mul64_slp2 (u64 *__restrict r, u64 *a, u64 *b)
+{
+  r[0] = a[0] * b[0];
+  r[1] = a[1] * b[1];
+}
+
+/* { dg-final { scan-assembler-times "pmullq" 1 } } */
-- 
2.51.0

Reply via email to