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

match.pd: Handle VIEW_CONVERT_EXPR in C[LT]Z zero select folds

Improves vectorizer's ability to optimize count-trailing-zeros operations by looking through expression conversions.

This change enhances GCC’s pattern matching for C[LT]Z zero select folds, allowing it to correctly process VIEW_CONVERT_EXPR operations. Previously, these folds failed when the vectorizer treated signed vectors as unsigned, leaving sel instructions in the code. By adding int_convert to match.pd, the compiler can now look through these conversions, enabling more effective folding and optimizing code for operations like __builtin_ctzll on vectors.

In Details

The match.pd file contains patterns used by the GCC vectorizer to recognize and optimize specific instruction sequences. The C[LT]Z zero select folds aim to simplify select operations where the condition is based on a non-zero count. This patch introduces int_convert to handle VIEW_CONVERT_EXPR for vector types, which is crucial for correctly optimizing operations like __builtin_ctzll when input vectors are subject to type conversions, preventing sel instructions from remaining in optimized code.

For Context
C[LT]Z zero select folds
GCC's pattern matching optimization that simplifies conditional select instructions when the condition is based on a count of zero.
VIEW_CONVERT_EXPR
An internal GCC expression representing a type conversion, particularly used for vectors where the underlying representation might not change.
vectorizer
A compiler component that transforms scalar code into vector instructions for parallel processing on the CPU.
SVE
Scalable Vector Extension, an ARM architecture feature that allows vector registers to be of variable length.
sel instruction
A conditional select instruction that chooses between two operands based on a condition, often optimized away by compilers.
Filed Under: gccoptimizationvectorizationaarch64