[LLVMdev] Copy Instructions?
David Greene
dag at cray.com
Wed Jan 28 10:52:58 PST 2009
On Wednesday 28 January 2009 12:07, Owen Anderson wrote:
> On Jan 28, 2009, at 9:50 AM, David Greene wrote:
> > 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?
>
> The "normal" answer would be that they execute atomically only at the
> IR level. Part of the out-of-SSA translation that happens in the
> backend is to insert sufficient copies to to hide the non-atomic
> nature of the execution.
>
> >> 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.
>
> I have no idea if the Verifier actually accepts this, but it is
> semantically valid because of the conditional execution involved in
> the phi. The value of x will never be read before it has been def'd.
So if this is true then it seems that you wouldn't need the extra phi
anyway, since y = phi(y.0, x) would be semantically valid.
Ok, so I can understand how the SSA construction can be considered
valid. All right, I'll have to go and see if out-of-SSA does the right thing
with this.
-Dave
More information about the llvm-dev
mailing list