range-ops: Infer operand equality from zero MINUS_EXPR
Improves optimization by deducing operand equality from subtraction-equals-zero expressions.
This commit enhances the range-ops optimization pass by allowing it to infer operand equality from a - b == 0 expressions. Previously, this was only possible for single-use differences, but now it supports a wider range of cases, leading to a slight increase in compile times but improved optimization in passes like VRP and DOM.
In Details
The operator_minus in range-op-mixed.h now exposes op1_op2_relation, enabling register_outgoing_edges in gimple-range-fold.cc to derive relations from any integral export, not just booleans. This allows the inference of a == b from a - b == 0, even when the difference is not single-use, improving VRP and DOM optimizations at the cost of a 36% increase in register_outgoing_edges runtime.
- range-ops
- A GCC optimization pass that reasons about the possible ranges of values for variables.
- MINUS_EXPR
- GCC's internal representation for a subtraction operation in the GIMPLE intermediate language.
- VRP
- Value Range Propagation, an optimization pass that narrows down the possible range of values for variables.
- DOM
- Dominator analysis, a program analysis technique used in optimizations to understand control flow.
- GIMPLE
- GCC's internal three-address intermediate representation, used after parsing and before optimization.