GCC Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
match.pd Performance Win

match.pd: Sink float/fix_trunc conversions into VEC_COND_EXPR

Improves vectorization by sinking float and fix_trunc conversions into VEC_COND_EXPR arms.

This commit enhances GCC’s match.pd pattern matching to improve vectorization of conditional expressions. Previously, it could sink conversions and unary operations into VEC_COND_EXPR if both arms folded, but it did not handle FLOAT_EXPR or FIX_TRUNC_EXPR. The change extends this sinking capability to these conversion types, allowing vector code like !(a[i] >= b[i]) to be vectorized more efficiently by selecting float constants directly, rather than integer constants followed by a conversion.

In Details

The match.pd pattern driver optimizes expressions. This change extends the convert sink capability to handle FLOAT_EXPR and FIX_TRUNC_EXPR within VEC_COND_EXPR. Previously, if a VEC_COND_EXPR involved these float/fixed conversions and both arms folded, the conversion was not sunk. This led to suboptimal vector code generation, e.g., expanding (vector(4) float) _1 where _1 was a VEC_COND_EXPR of integer constants. The fix ensures these conversions are sunk if the mask matches the result type and the new VEC_COND_EXPR is expandable, leading to selects of float constants.

For Context
match.pd
The pattern-driven matching component of GCC's middle-end, responsible for simplifying and optimizing expressions by matching them against predefined patterns.
VEC_COND_EXPR
GCC's internal representation for a vector conditional expression, equivalent to a masked select operation on vector elements.
FLOAT_EXPR
GCC's internal representation for a floating-point expression, such as a conversion from an integer to a float.
FIX_TRUNC_EXPR
GCC's internal representation for a fixed-point or truncated integer-to-integer conversion expression.
vectorizer
A compiler component that attempts to find and execute operations on multiple data elements simultaneously using SIMD (Single Instruction, Multiple Data) instructions.
Filed Under: optimizationvectorizationmatch.pd