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

Match: Restricts signed saturating truncation to uniform precision.

Match pattern for signed saturating truncation now requires uniform precision to prevent internal compiler errors.

This commit refines the signed_integer_sat_trunc pattern in GCC’s matcher to require that the precision of the operand and the result of the conversion are uniform. Previously, cases where the comparison narrowed the precision after a variable shift could lead to an internal compiler error in the vectorizer. The updated pattern ensures that the conversion maintains the precision of the operand and that the result is narrower, preventing mismatches and resolving PR126982.

In Details

The signed_integer_sat_trunc pattern in match-sat-alu.pd previously allowed the operand's precision and the conversion's result precision to differ, especially after a variable shift. This caused wi::eq_p in wide-int.h to fail when GIMPLE was being vectorized. This change imposes a constraint requiring the operand and conversion precision to be the same, and the result to be narrower, ensuring that no valid pattern match is lost since differing precision cases previously hit an assertion.

For Context
Match
Refers to the pattern matching component of GCC, used for recognizing and transforming specific code constructs during optimization passes.
signed integer saturating truncation
An arithmetic operation that truncates a signed integer to a smaller integer type, clamping the result to the maximum or minimum value of the target type if overflow occurs.
PHI node
In SSA (Static Single Assignment) form, a PHI node is an instruction that merges values from different control flow paths. It represents a variable that may have different values depending on which path the program execution took.
GIMPLE
GCC's internal representation for intermediate code, used after parsing and before optimization and code generation. It's a three-address code form.
vectorizer
A compiler component that automatically transforms loops and other code constructs to use SIMD (Single Instruction, Multiple Data) instructions, which can operate on multiple data elements simultaneously for improved performance.
Filed Under: matchoptimizationvectorizationbugfixinteger arithmetic