expand_mult: Look through vector mode for constant multipliers
GCC's `expand_mult` now correctly determines shift amounts for vector constants by examining the scalar operand's mode.
GCC’s expand_mult function has been improved to correctly handle constant vector multipliers. When the scalar operand is a CONST_WIDE_INT, the function now looks through the vector mode to determine the scalar mode for calculating the shift amount. This ensures accurate code generation for vector operations, as highlighted by a new test case for a bug that previously miscalculated shift amounts.
In Details
In expmed.cc, the expand_mult function, when processing a constant vector multiplier with a CONST_WIDE_INT scalar operand, now correctly inspects the scalar operand's mode to determine the shift amount. Previously, it would use the vector mode, which is incorrect for scalar calculations within the vector context. This change ensures that the shift amount is correctly derived from the scalar's actual mode, not the vector's, before passing to expand_shift which requires the vector mode. This addresses PR middle-end/127474.
- expand_mult
- A GCC compiler function responsible for expanding multiplication operations into lower-level intermediate representation (IR) instructions, particularly handling complex cases like constant multipliers and vector types.
- vector mode
- In GCC's intermediate representation, this refers to the data type information associated with vector operations, indicating that multiple elements are being processed in parallel.
- CONST_WIDE_INT
- An intermediate representation constant in GCC that represents an integer value of arbitrary precision, which might exceed the native machine word size.
- shift amount
- The number of positions by which the bits of a number are shifted left or right in a bitwise shift operation.
- scalar mode
- The data type information for a single, non-vectorized value.