commit d54ae54c13276adbfc5b27227a3630ad40002705 Author: Andrew MacLeod Date: Thu Mar 23 10:28:34 2023 -0400 Ranger cache dominator queries should ignore backedges. When querying dominators for cache values, ignore back edges in read-only mode. PR tree-optimization/109238 * gimple-range-cache.cc (ranger_cache::resolve_dom): Ignore predecessors which this block dominates. diff --git a/gcc/gimple-range-cache.cc b/gcc/gimple-range-cache.cc index 7aa6a3698cd..96460ece8f4 100644 --- a/gcc/gimple-range-cache.cc +++ b/gcc/gimple-range-cache.cc @@ -1510,6 +1510,11 @@ ranger_cache::resolve_dom (vrange &r, tree name, basic_block bb) Value_Range er (TREE_TYPE (name)); FOR_EACH_EDGE (e, ei, bb->preds) { + // If the predecessor is dominated by this block, then there is a back + // edge, and won't provide anything useful. We'll actually end up with + // VARYING as we will not resolve this node. + if (dominated_by_p (CDI_DOMINATORS, e->src, bb)) + continue; edge_range (er, e, name, RFD_READ_ONLY); r.union_ (er); }