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

Match: Simplify max/min of ANDed variables.

New match.pd patterns optimize min/max operations on variables ANDed with constants.

New patterns in match.pd recognize opportunities to simplify min/max operations where both operands involve the same variable ANDed with different constants. For signed types, the optimization is enabled when both constants share the same sign bit. New patterns also handle the specific case of min/max(a, a & CST), improving code generation for these common scenarios.

In Details

The commit introduces new patterns to match.pd that aim to simplify MAX<a&CST0, a&CST1> and MIN<a&CST0, a&CST1> expressions. These patterns leverage properties of bitwise AND and constant values to potentially reduce the complexity of the generated code. The changes could interact with other tree-ssa optimizations that rely on the existing patterns in match.pd.

For Context

The GCC compiler uses pattern matching to recognize opportunities for optimization. The match.pd file contains patterns that the compiler uses to simplify expressions during the optimization process. This commit adds new patterns to simplify expressions involving the min and max functions when applied to variables combined with bitwise AND operations. These optimizations can lead to more efficient code generation.

Filed Under: optimizationpattern matchingtree-ssa