From 6493b7af37e473a89c67afab474330f931dd8447 Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Thu, 9 Feb 2023 17:50:07 -0500 Subject: [PATCH] Query rangers cache in readonly mode only from within The change for 108356 allowed the cache to scan the dominator trees when it was attempting a lookup rather than using the local value. I inadvertantly changed the externbal interface to also do this, so all the GORI queries via range_on_edge of the cache could also do lookups. This triggered a quadratic, possible expoential time increase when the right conditions were presented. That being a cascading series of recomputaions on outgoing edge calucaltions that at then searched the dom tree instead of being a simple calcualtion using whats easily available. The fix is to use the internal API within the cache rather than the extrenal one that GORI uses. This leaves GORI computations to be resovled in linear time. PR tree-optimization/108687 gcc/ * gimple-range-cache.cc (ranger_cache::range_on_edge): Revert back to RFD_NONE mode for calculations. (ranger_cache::propagate_cache): Call the internal edge range API with RFD_READ_ONLY instead of changing the external routine. --- gcc/gimple-range-cache.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gcc/gimple-range-cache.cc b/gcc/gimple-range-cache.cc index 20c444b..546262c 100644 --- a/gcc/gimple-range-cache.cc +++ b/gcc/gimple-range-cache.cc @@ -998,7 +998,7 @@ bool ranger_cache::range_on_edge (vrange &r, edge e, tree expr) { if (gimple_range_ssa_p (expr)) - return edge_range (r, e, expr, RFD_READ_ONLY); + return edge_range (r, e, expr, RFD_NONE); return get_tree_range (r, expr, NULL); } @@ -1081,7 +1081,7 @@ ranger_cache::propagate_cache (tree name) new_range.set_undefined (); FOR_EACH_EDGE (e, ei, bb->preds) { - range_on_edge (e_range, e, name); + edge_range (e_range, e, name, RFD_READ_ONLY); if (DEBUG_RANGE_CACHE) { fprintf (dump_file, " edge %d->%d :", e->src->index, bb->index); -- 2.7.4