[LLVMdev] Copy Instructions?

Owen Anderson resistor at mac.com
Wed Jan 28 10:07:51 PST 2009


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.

--Owen



More information about the llvm-dev mailing list