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

Infer zero result for division when dividend is positive and smaller than positive divisor.

Compiler now deduces `A / B` is zero if `A` and `B` are positive and `A < B`.

This commit enhances the range analysis optimization pass by adding a new relation effect for the division operation. Specifically, when the compiler can determine that both the dividend (A) and the divisor (B) are positive, and that A is strictly less than B, it can now infer that the result of A / B will always be zero. This improves optimization by providing more precise value range information for division operations.

In Details

Adds a VREL_LT relation effect to operator_div::op1_op2_relation_effect in range-op.cc. If op1 and op2 are known to be positive and op1 < op2, the analysis now infers that op1 / op2 is zero. This provides a tighter range bound for division operations, potentially enabling further optimizations such as constant propagation or simplifying conditional logic.

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_LT
A relation indicating that one value is less than another.
div
The GCC internal representation for the division operation.
Filed Under: optimizationrange analysisdivision