[tree-ssa/mainline PATCH] fold "test"==0 into constant

Jan Hubicka hubicka@ucw.cz
Thu Nov 6 16:53:00 GMT 2003


> 
> > I do, but that would require testing both nonzero and nonnegative in
> > PLUS case that may be quite expensive in recursion.  I can add it if
> > you think it is usefull.
> 
> The advantage with lower and upper bounds is that you only need to do
> a single recursion.  The second advantage is that the bounds functions
> can contain recursion limiters (a depth or time-to-live counter) such
> that we only recurse atmost four or five levels before returning a
> safe default, TYPE_MIN_VALUE (TREE_TYPE (t)) or TYPE_MAX_VALUE (...).

True.  I am not quite sure whehter I didn't get already overactive in my
predicate by recurzing to nonnegative code...  I think it is usefull
for the simple cases I seen.
> 
> > We will likely get this with VRP soonish.
> 
> This is not quite the same as classical VRP which maintains bounds on
> variables.  Instead this a local VRP within a single expression, for
> the time being DECLs are assumed to hold the full range of their type.
> Instead its the context the expression they are in that provides the
> resticted bounds.  "if ((x ? 2 : 3) == (y ? 6 : 7))" is always false
> without any dataflow analysis or propagation of bounds.  Similarly,
> "(x | 6) != 0" and "(x & 5) < 12".

VRP implementation will have this logic in it and we can probably share
the functionality here (either use the global data or conservative
approximations using DECLs), so implemnting it would be good think.  I
believe Jeff did some work on this already in his dominator based
optimizers, so I will look into it.

> > However nonzero test is not exacly an interval (at least in common
> > implementations you don't allow negative interval mening everything
> > except for zero).
> 
> This is very true, we know that for signed x, "x | 5" is never zero,
> but may still be positive or negative.  However, building the nonzero
> predicate on top of the proposed range bounds, limits the numbers of
> cases like this that have to be considered specially.

Yes, rewriting nonzero predicate would be usefull step.  I will try to
figure out what is done already and perhaps do part of the work once I
get across the low level stuff I am working on right now.

Honza
> 
> Roger
> --



More information about the Gcc-patches mailing list