[LLVMdev] PHI nodes in machine code

Vikram S. Adve vadve at cs.uiuc.edu
Thu Jul 8 11:14:09 PDT 2004


PHI nodes within machine code were originally used by the Sparc 
back-end but they turned out not to be necessary.  Instead, LLVM phis 
are lowered to copy instructions in the machine code (I believe this 
happens just after instruction selection).  As far as I know, the 
machine PHI nodes are not used by the x86 back-end and you shouldn't 
need them if you insert the right copies.

--Vikram
http://www.cs.uiuc.edu/~vadve
http://llvm.cs.uiuc.edu/

On Jul 8, 2004, at 11:06 AM, Vladimir Prus wrote:

>
> Could anybody quickly explain why PHI nodes instructions are necessary 
> in
> machine code? And why the code in LiveVariables.cpp which looks at 
> those PHI
> nodes (line 249 and below) is necessary.
>
> The reason I'm asking is that I try to support 64-bit comparison and I 
> do it
> by generating code like:
>
>           //    if high1 cond high2: goto operand0
>           //    if high1 reverse_cond high2: goto operand1
>           //    if low cond high2: goto operand0
>           //    goto operand1
>
> but this means that operand0 and operand1 (the successor basic blocks)
> suddenly get more predecessor than recorded in phi nodes, and
> LiveVariables.cpp asserts on that.
>
> Of course, I can add another two basic block which will set some 
> register to 0
> or 1 and branch based on the value of that register, but maybe the 
> above
> approach can work as well.
>
> Thanks in advance,
> Volodya
>
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://mail.cs.uiuc.edu/mailman/listinfo/llvmdev




More information about the llvm-dev mailing list