[LLVMdev] Copy Instructions?

David Greene dag at cray.com
Wed Jan 28 09:50:17 PST 2009


On Wednesday 28 January 2009 11:32, Chris Lattner wrote:
> On Jan 28, 2009, at 9:06 AM, David Greene wrote:
> > On Tuesday 27 January 2009 18:28, Eli Friedman wrote:
> >> You can use a no-op bitcast for scalars, but there isn't any reliable
> >> way to do it for all first-class values.
> >
> > Guh.
> >
> >> That said, I don't quite follow the issue.  This is SSA, so the
> >> only way a
> >> value can change is if you change the code.
> >
> > This isn't (yet) SSA.  This is mem2reg turning things into SSA.
> >
> >> I'm not really following what the issue is in this testcase, though,
> >> so I could be missing something.  The way you're describing it,
> >> mem2reg appears to be working as intended; the correct completion is
> >> in fact as follows:
> >>         //   x = phi(x.0, expr)
> >>         //   y = phi(y.0, x)
> >
> > Yes, that's what mem2reg ends up with.
>
> Why is this a problem?  All phis execute "atomically".  What problem
> are you seeing in practice?

I'm getting incorrect answers.

How can a set of phis with a dependence execute simultaenously?
There is only one definition of x and it has to happen before the use of
x in the phi defining y, doesn't it?

Owen says:

> In this case, you can resolve it by inserting an extra PHI node:

>  x.0 = 0
>  y.0 = 0
>  do
>        foo = phi(undef, x)
>        x = phi(x.0, y)
>        y = phi(y.0, foo) // CORRECT WITH ORDERED PHIS!
>        ...
> end do

Again, how can simultaenous execution of statements with a dependence have any 
meaning?  For practical reasons, as Owen says, LLVM does not treat phis as 
executing simultaneously.  So in this case wouldn't there be a use-before-def 
error on x?  I should think Verifier would choke on this code.

                                                 -Dave



More information about the llvm-dev mailing list