GCC Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
match Performance Win

Remove redundant comparison check in vec_cond pattern

Simplifies a pattern matching a conditional vector expression by removing an unnecessary comparison.

A pattern in the match.pd file used for matching conditional vector expressions has been simplified. The inner comparison within the VCE (Vector Conditional Expression) construct was found to be redundant for the purpose of VEC_COND matching and has been removed. This change may lead to slightly more optimized generated code by genmatch and could potentially improve matching for certain bitwise operations.

In Details

The pattern ((VCE (a cmp b ? -1 : 0)) < 0) ? c : d in match.pd has been simplified by removing the (a cmp b) part. The VEC_COND constructor in the generated matcher does not rely on the specific comparison result (-1 or 0) but rather on the sign of the result when the condition is evaluated, making the explicit comparison redundant for this pattern's purpose.

For Context
match.pd
A file containing patterns used by GCC's genmatch tool to generate code for matching machine instructions.
VCE
Stands for Vector Conditional Expression, a construct used in pattern matching to represent conditional operations on vector data.
VEC_COND
A specific type of pattern or instruction related to conditional operations on vector data.
genmatch
A GCC tool that generates code for instruction matching based on patterns defined in .pd files.
Filed Under: optimizationpattern-matchingcodegen