match.pd: Require constant FMAX/FMIN reductions to fold.
Ensures FMAX and FMIN reductions involving constants are folded to avoid introducing runtime reductions.
This commit modifies match.pd to require that constant reductions for FMAX and FMIN operations must fold. This prevents a situation where a single runtime reduction is unnecessarily expanded into two runtime reductions and one operation. By enforcing folding, all eight reduction types can now share a common simplification rule, improving the consistency and efficiency of reduction folding. A new test case for AArch64 is included.
In Details
This change updates the match.pd pattern definition for REDUC (@0 op VECTOR_CST). Previously, FMAX and FMIN were excluded from the requirement that constant reductions must fold due to concerns about forming inverse reduction-pair rule cycles. This commit extends the requirement to FMAX and FMIN, ensuring that when a VECTOR_CST is used with these reductions, the constant part must fold into the reduction. This avoids transforming a single runtime reduction like .REDUC_FMAX(v, C) into two runtime reductions and an explicit .FMAX(r1, r2) operation, unifying the simplification…
- match.pd
- A file within GCC that contains pattern definitions for instruction matching and optimization. It describes how to recognize and transform patterns of operations into target-specific instructions.
- FMAX
- Floating-point maximum. An operation that returns the larger of two floating-point values.
- FMIN
- Floating-point minimum. An operation that returns the smaller of two floating-point values.
- reduction
- A type of operation that combines elements of a vector or sequence into a single scalar value using a binary operation (e.g., sum, product, max, min). In GCC, vector reductions can be optimized to fold constants.
- VECTOR_CST
- Represents a constant vector in GCC's internal tree representation, used in pattern matching for optimizations.