GCC Newspaper
JULY 29, 2026
Date
/
Architectures
Components
Topics
News & Policy
match.pd

match.pd: Make vector abs conversion rules float-safe.

Vector abs conversion rules use element precision to prevent compiler crashes.

This commit makes the match.pd optimization rules for vectorized absolute value (abs) conversions safe for floating-point types. Previously, these rules evaluated TYPE_PRECISION on vector types after a conversion, leading to an Internal Compiler Error (ICE) during optimization. By switching to element_precision and adding a check for target support of ABS on the narrow vector type, the compiler can now correctly transform these operations without crashing. This fix ensures that conversions from narrower to wider vector types followed by an abs operation are handled robustly.

In Details

The match.pd optimization rule for (trunc)abs(extend x) is updated to use element_precision for its guard evaluation, resolving an ICE that occurred when optimizing vectorized abs operations on converted types. The previous reliance on TYPE_PRECISION failed for vector types. The updated rule now correctly queries the precision of vector elements and includes a target_supports_op_p check for the narrow vector type's ABS operation, ensuring safety and correctness.

For Context
match.pd
A component within GCC's optimization framework responsible for pattern matching and applying transformations based on defined rules, often within the 'tree-optimization' or 'middle-end' phases.
abs
The absolute value function, which returns the non-negative magnitude of a number.
element_precision
A query that returns the precision (e.g., number of bits) of the individual elements within a vector data type.
TYPE_PRECISION
A GCC internal macro or function used to query the bit precision of a data type. Applying it directly to vector types can lead to errors.
ICE
Internal Compiler Error, a crash within the compiler itself, usually indicating a bug in the compiler's internal logic or an unexpected program construct.
vector type
A data type representing a collection of elements of the same underlying type, processed simultaneously by SIMD or vector instructions.
Filed Under: optimizationmatch.pdvectorfloating-pointbugfix