This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: CCP propagating conditional expression constants
On Friday 5 January 2007 13:08, Sebastian Pop wrote:
> On 1/5/07, Duncan Sands <baldrick@free.fr> wrote:
> > > here is a patch on which I have worked with Basile Starynkevitch
> > > for propagating constants inferred from conditional expressions.
> > > The basic testcase from which we started was something like
> > >
> > > if (x == 0)
> > > a = b / x;
> > >
> > > and we wanted to issue an error for the division by zero.
> > > In the process we just remarked that x was not replaced by zero
> > > in the then_clause, and that we have support for warnings for
> > > division by zero only in the front ends, ie. we'll later propose a patch
> > > for such warnings also after CCP and other code transforms on GIMPLE.
> >
> > Doesn't tree-ssa-dom.c already do this kind of propagation?
> >
>
> No, I have looked at the last pass dump and x was still present,
> not replaced by zero.
gcc version 4.3.0 20061213 (experimental)
int a, b;
void q (int x)
{
if (x == 0)
a = b / x;
}
gcc -c -O2 -fdump-tree-all q.c
Here x is replaced by VRP, see q.c.039t.vrp1.
gcc -c -O2 -fno-tree-vrp -fdump-tree-all q.c
Here x is replaced by DOM, see q.c.041t.dom1.
gcc -c -O2 -fno-tree-vrp -fno-tree-dominator-opts -fdump-tree-all q.c
With VRP and DOM turned off, x is not replaced.
Ciao,
Duncan.