This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [tree-ssa] CCP and non-destructive folding problems
On Tue, 25 Feb 2003, Jeff Law wrote:
> >My recent change to the flowgraph exposed a couple of problems in
> >CCP:
> >
> >(1) ccp_fold() and fold() are not always returning the same
> > value. For instance, strlen("abc") is folded to 3 by
> > fold(), but not folded by ccp_fold().
> This *should* be OK. If it isn't then we've got a design issue in
> CCP.
>
What should be OK? The two versions of fold() returning
different values? How is that OK? I don't follow.
> Err, that's the problem. If none of the operands are undefined, but
> the expression does not fold, then the expression *must* be marked as
> varying.
>
Not necessarily. I agree in cases like 'foo (1, 3)'. But
sometimes the expression does not fold because ccp_fold() didn't
know how to fold it. This also happened to things like '1 && 1'.
If we mark it VARYING due to limitations in the nondestructive
folder, we may end up blocking further propagation of constants.
In the case of '1 && 1', the variable that the expression was
being assigned to was never considered constant.
The bigger problem here is actually the two diverging
implementations of fold(). I think we are making a big mistake.
We should factor more code in the two flavours of fold().
Diego.