GCC Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
gcc/range-op Performance Win

Infer non-zero result for bitwise OR when operands are known to be different.

Compiler now deduces `A | B` is non-zero if `A` is not equal to `B`.

This commit enhances the range analysis optimization pass by introducing a new relation effect for the bitwise OR operation (bit_ior). When the compiler can determine that the two operands of a bitwise OR are not equal (A != B), it can now infer that the result of A | B will always be non-zero. This allows for more aggressive optimizations in subsequent passes by providing tighter range information.

In Details

Adds a VREL_NE relation effect to operator_bitwise_or::op1_op2_relation_effect in range-op.cc. When op1 != op2 is established, the analysis now infers that op1 | op2 is non-zero. This affects range-based analysis, potentially enabling further optimizations like constant propagation or simplification of conditional branches that depend on the result of a bitwise OR.

For Context
Range analysis
A compiler optimization technique that determines the possible range of values a variable can hold during program execution. This information is used to prove properties about the code and enable further optimizations.
Relation effect
In range analysis, this describes how an operation affects the relationship between its operands and their possible values, providing constraints for the analysis.
VREL_NE
A relation indicating that two values are not equal.
bit_ior
The GCC internal representation for the bitwise OR operation.
Filed Under: optimizationrange analysisbitwise operations