[PATCH]: Improve ability of PRE to detect redundancies

Daniel Berlin dberlin@dberlin.org
Fri Nov 26 06:04:00 GMT 2004


On Thu, 2004-11-25 at 20:12 -0700, Roger Sayle wrote:
> On Thu, 25 Nov 2004, Daniel Berlin wrote:

> Why not just
> 
> static tree
> fully_constant_expression (tree t)
> {
>   tree folded = fold (t);
>   if (folded != t && is_gimple_min_invariant (folded))
>     return folded;
>   return t;
> }

For the same reason ssa-ccp doesn't use fold.
We don't need it's power in this instance :).

> which may also simplify the task of teaching GNV-PRE that "x + 1"
> is equivalent to "1 + x", or that "x + x" is equivalent to "x * 2",
> etc..
It wouldn't actually, because that stuff goes in a different place (the
value number lookup routine, and in recursive folding of value handles
during phi translation and and lookup). 
I once had some stuff to fold value handles in all the right places
(which would make this patch unnecessary), but it required a lot of
memory and time.
Also, it already knows that 1 + x is equivalent to x + 1, because the
hash function knows that :)

This patch is the easy way out for now. It gets some percentage of those
cases without any real time or space usage.

As for SPEC, I just ran the numbers, i never did real analysis of why it
wasn't improving them.  I only did this because there was other real
code out there that this should improve. :)

--Dan



More information about the Gcc-patches mailing list