Correct costs for VnDI umul_highpart emulation on x86
Fixes x86 vectorization of unsigned multiply high part by using correct costs for VnDI operations.
This commit corrects a performance regression on Clearwater Forest processors by accurately costing the emulation of umul_highpart for VnDI (vector doubleword integer) operations. The previous cost estimation was too low, leading the vectorizer to incorrectly choose V4DI (vector quadword integer) which was slower than scalar code for the NTT loop in 750.sealcrypto_r. The fix uses mulss for widening multiplies and applies ix86_vec_cost to the entire cost calculation, respecting target tuning flags like X86_TUNE_AVX256_SPLIT_REGS and improving vectorization efficiency.
In Details
This commit adjusts the cost model in ix86_vector_costs::add_stmt_cost to correctly represent the cost of umul<mode>3_highpart for VnDI modes on x86. A regression in 750.sealcrypto_r on Clearwater Forest was traced to the vectorizer selecting V4DI due to an underestimated cost for the VnDI _MULH emulation. The fix ensures that mulss is used for these widening multiplies, similar to other VnDI multiply emulations, and that the entire cost is passed through ix86_vec_cost. This allows target-specific tuning like X86_TUNE_AVX256_SPLIT_REGS to be honored and results in more a…
- VnDI
- Vector Doubleword Integer. Refers to vector data types where each element is a doubleword (32-bit integer).
- V4DI
- Vector Quadword Integer. Refers to vector data types where each element is a quadword (64-bit integer).
- umul_highpart
- A multiplication operation that computes the upper (high-order) bits of the product of two integers.
- vectorizer
- A compiler component that automatically transforms scalar code into equivalent vector code, using SIMD (Single Instruction, Multiple Data) instructions to perform operations on multiple data elements simultaneously.
- NTT
- Number Theoretic Transform. A digital signal processing algorithm analogous to the Discrete Fourier Transform but operating in a finite field, often used in cryptography and polynomial multiplication.