https://gcc.gnu.org/g:29b6d0f2abe64b24fbcefdbfe53a7a23baeb6bf3
commit r17-4996-g29b6d0f2abe64b24fbcefdbfe53a7a23baeb6bf3 Author: Richard Biener <[email protected]> Date: Thu Oct 8 10:57:32 2026 +0200 Fixup MULT_EXPR cost after MULT_HIGHPART_EXPR adjustment 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. 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. Diff: --- gcc/config/i386/i386.cc | 12 +++++++----- gcc/testsuite/gcc.target/i386/vect-mulq-1.c | 13 +++++++++++++ 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc index fdd7bcc020ae..553fa046fa94 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 000000000000..0ec961728f98 --- /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 } } */
