GCC Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
gcc Performance Win

Fix i386 vector multiplication cost calculation

Correctly separates costs for different multiplication types on i386 to enable better vectorization.

The cost calculation for multiplication operations on the i386 architecture has been corrected to properly distinguish between MULT_EXPR and MULT_HIGHPART_EXPR. Previously, a change intended for high-part multiplication erroneously affected the cost of regular MULT_EXPR, hindering vectorization. This fix ensures accurate cost modeling, allowing the compiler to make better decisions about vectorizing multiplication operations.

In Details

This commit addresses PR target/127769 by refining the cost model for vector multiplication in ix86_vector_costs::add_stmt_cost. A recent adjustment to MULT_HIGHPART_EXPR costs, intended to account for DImode high-part multiplication, was incorrectly globbed with MULT_EXPR. This commit separates the handling for MULT_EXPR and MULT_HIGHPART_EXPR, ensuring that the cost of standard multiplications is not adversely affected, thereby improving the accuracy of cost-based vectorization decisions for i386.

For Context
i386
The Intel 80386 processor architecture, a foundational 32-bit x86 processor. GCC targets this architecture and its successors.
vectorization
An optimization technique that allows the compiler to perform the same operation on multiple data elements simultaneously using specialized SIMD (Single Instruction, Multiple Data) instructions. This can significantly speed up computations on large datasets.
MULT_EXPR
An internal GCC representation for a multiplication expression.
MULT_HIGHPART_EXPR
An internal GCC representation for the high-part of a multiplication expression, typically used for multiplying large integers where the result requires more bits than a standard integer type.
DImode
GCC's internal representation for a 64-bit integer type.
cost model
A component of the compiler's optimizer that estimates the performance cost (e.g., execution time, instruction count) of different code sequences or operations. This guides the optimizer in choosing the most efficient implementation.
Filed Under: i386optimizationvectorizationcost-model