Re: [PATCH] path solver: only compute ranges at the current path position [PR126876]

Aldy Hernandez <[email protected]>
Newsgroups gmane.comp.gcc.patches
Message-ID <[email protected]>
On Wed, Aug 19, 2026 at 10:00:28AM +0200, Richard Biener wrote:
> On Tue, Aug 18, 2026 at 4:02 PM Andrew MacLeod <[email protected]> wrote:

> That's what the backward threader does as well.  Not sure why DOM
> has a path-ranger instance though.

DOM has a path-ranger to simplify threading paths.  The hybrid
threader first looks at DOM's internal tables (avail_exprs, etc), and
if it can't resolve a conditional with them, it uses the path-ranger.
Once upon a time it used evrp.

The rest of DOM uses a regular ranger: copy prop, folding of
statements, setting global ranges from unreachable edges, etc.  I've
mentioned in the past, that DOM's usage of the ranger (previously
evrp), equates to basically running evrp at -O1.

> > We should se the same results if the path ranger queries simply invoke
> > the root ranger if the request is from outside the block.
> >
> > If its from within the path, i would think you would want the values
> > from within the path..   but thats above my paygrade :-P
> 
> Can the path_range_query really correctly answer for every point in
> the path or just at path exit?  From the issue at hand it seems it
> either assumes it walks the path but does not really need to, or
> it's use is more restrictive than anticipated.  But that's above my
> paygrade as well :-P

Once ranges have been computed for a given path, the path ranger
answers questions for expressions as they would appear at the end of
the path:

// This class is a basic block path solver.  Given a set of BBs
// indicating a path through the CFG, range_of_expr and range_of_stmt
// will calculate the range of an SSA or STMT as if the BBs in the
// path would have been executed in order.

I suppose if we're asking for things for it mid-compute, it would give
ranges on the path so far, but it has certainly not been tested that
way.  And as Andrew said, for anything not defined or implied in the
path (as in an edge between blocks), the path ranger uses the global
ranger on entry to the path.

I don't see why the path ranger couldn't be made more robust, so we
can ask for things anywhere on the path, but the only use case we had
at the time was the backwards threader.

> it's use is more restrictive than anticipated.  But that's above my
> paygrade as well :-P

At this point in my life, pretty much everything is above my paygrade.

Aldy
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.