[LLVMdev] PHI nodes in machine code

Vladimir Prus ghost at cs.msu.su
Thu Jul 8 11:08:04 PDT 2004


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





More information about the llvm-dev mailing list