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

Fold umin(a, 1) | umin(b, 1) into umin(a | b, 1)

Simplifies bitwise OR of minimums with 1 into a minimum of a bitwise OR.

This commit optimizes a specific bitwise operation pattern within the match.pd pattern matching system. It folds the expression umin(a, 1) | umin(b, 1) into the more efficient form umin(a | b, 1). This optimization is applied to integer types and is accompanied by new test cases to verify its correctness.

In Details

The match.pd optimization rule is extended to recognize and fold the bitwise OR of two umin(x, 1) operations into a single umin operation with a bitwise OR of the operands. This identity, (a & ~1) | (b & ~1) == (a | b) & ~1, is useful for simplifying code involving bitwise operations and minimums, particularly when dealing with masks or flags.

For Context
match.pd
A file containing pattern matching rules used by GCC's optimization passes to recognize and transform specific code sequences.
umin
An intrinsic function or operation that returns the minimum of two values. In this context, umin(a, 1) likely means the minimum of a and 1.
Filed Under: optimizationbitwisepattern matching