vect: Support complex fused multiply-subtract with non-accumulating destinations
Enables vectorization of a specific form of complex fused multiply-subtract operations, improving performance for complex arithmetic.
This commit extends the vectorizer’s capability to support an additional form of complex fused multiply-subtract (FMS) operations. Specifically, it enables matching FMS where reassocations result in the top-level operation being a PLUS_MINUS, occurring when the accumulator is different from the destination. This support is crucial for optimizing code that performs complex arithmetic, such as c.real + (a.imag * b.imag - a.real * b.real), especially when the accumulator is not the same as the destination register.
In Details
The complex_fms_pattern::matches function in tree-vect-slp-patterns.cc has been updated to recognize an FMS pattern where reassoc has resulted in a PLUS_MINUS operation at the top level. This scenario arises when the accumulator used in the FMS is distinct from the destination, leading to expressions like c -= a * b. The change ensures that such forms, common in out-of-place complex arithmetic, are correctly identified and potentially vectorized.
- Fused Multiply-Subtract (FMS)
- An arithmetic operation that combines multiplication and subtraction (or addition) into a single instruction. FMS instructions can improve performance and accuracy by reducing intermediate rounding errors.
- Complex numbers
- Numbers that can be expressed in the form a + bi, where 'a' is the real part, 'b' is the imaginary part, and 'i' is the imaginary unit (the square root of -1). They are used in various scientific and engineering fields.
- Vectorizer
- A compiler component responsible for transforming scalar code into vector code, enabling the execution of multiple data operations in parallel using SIMD instructions.
- Reassociation
- An optimization technique that rearranges the grouping of operations in an expression without changing the mathematical result. For example,
(a + b) + cmight be reassociated toa + (b + c).