match.pd: Improve MIN/MAX narrowing for vector types
Code generation for MIN/MAX operations on wide vector types is improved to handle conversions more effectively.
This change modifies the MIN/MAX narrowing in match.pd to use MIN/MAX followed by a convert operation. Previously, the narrowing was limited to single uses of the result, failing to support scenarios with explicit vector type conversions like converting between v2si and v2di. The new approach generates more efficient assembly by first performing the minmax on the wider type and then converting to the narrower type, resolving issues with PR middle-end/126906.
In Details
The match.pd pattern for minmax operations on vector types has been revised. Previously, it applied narrowing directly within the minmax operation, limiting its scope. The updated pattern (wide_type) minmax (a, b) now correctly handles cases where a and b might need explicit conversion to wide_type before the minmax operation, and the result is then converted back to the original type. This improves code generation for __builtin_convertvector uses with vector types, particularly for integer widening and narrowing, addressing issues in PR middle-end/126906.
- match.pd
- A pattern-matching file within GCC used for optimizing GIMPLE (GCC's intermediate representation) code. It defines rules to recognize and transform specific code patterns into more efficient forms.
- GIMPLE
- GCC's Internal Gimple Representation. It's a three-address, low-level intermediate representation used by the compiler's optimization passes.
- vector types
- Data types that represent collections of homogenous elements, typically used for Single Instruction, Multiple Data (SIMD) operations to speed up computations by processing multiple data points simultaneously.
- PR middle-end/126906
- A bug report filed against the middle-end of the GCC compiler, specifically concerning an issue with vector type conversions and MIN/MAX operations.