https://gcc.gnu.org/g:699287fd7b3943ac04f78c4897a38b2170d5248e
commit r16-5168-g699287fd7b3943ac04f78c4897a38b2170d5248e Author: Richard Biener <[email protected]> Date: Fri Nov 7 13:52:09 2025 +0100 Use ranger when simplifying conditions during niter analysis The following uses ranger to try to simplify boolean expressions in simplify_using_initial_conditions as used by niter analysis. We also try to simplify niter expressions themselves, but we cannot use ranger directly for this. * tree-ssa-loop-niter.cc (simplify_using_initial_conditions): Use the active ranger to simplify boolean expressions. Diff: --- gcc/tree-ssa-loop-niter.cc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/gcc/tree-ssa-loop-niter.cc b/gcc/tree-ssa-loop-niter.cc index 5e35a59fcd10..f27a9e5cd113 100644 --- a/gcc/tree-ssa-loop-niter.cc +++ b/gcc/tree-ssa-loop-niter.cc @@ -3085,6 +3085,15 @@ simplify_using_initial_conditions (class loop *loop, tree expr) if (TREE_CODE (expr) == INTEGER_CST) return expr; + value_range expr_range (TREE_TYPE (expr)); + if (TREE_TYPE (expr) == boolean_type_node + && get_range_query (cfun)->range_on_edge (expr_range, + loop_preheader_edge (loop), + expr) + && !expr_range.undefined_p () + && !expr_range.varying_p ()) + return expr_range.nonzero_p () ? boolean_true_node : boolean_false_node; + backup = expanded = expand_simple_operations (expr); /* Limit walking the dominators to avoid quadraticness in
