[LLVMdev] Critical edges

Chris Lattner sabre at nondot.org
Tue Jul 4 16:34:42 PDT 2006


On Tue, 4 Jul 2006, Fernando Magno Quintao Pereira wrote:
> However, it does not remove all the critical edges. I am getting a very
> weird dataflow graph (even without the Break Critical edges pass). The
> dataflow generated by MachineFunction::dump() for the program below is
> given here:
> http://compilers.cs.ucla.edu/fernando/projects/soc/images/loop_no_crit2.pdf
...
> The problem is the no_exit block. I think it was changed by one of the
> optimization passes, and was split into three basic blocks. But now there
> is a phi function where both the parameters are defined in the same basic
> block. Any of you guys now which pass I should cut off if I want to avoid
> this optimization?

This is due to instruction selection.  The llvm code turns your testcase 
into something like this:

   X += cond ? 1 : -1;

This is a 'select' instruction in LLVM.

Generic PowerPC chips doesn't support integer select instructions, so it 
must be lowered to a conditional branch.  This lowering is what you're 
seeing, there is no way to disable it.

If you don't want critical edges in the machine code CFG, you're going to 
have to write a machine code CFG critical edge splitting pass: LLVM 
doesn't currently have one.

-Chris

-- 
http://nondot.org/sabre/
http://llvm.org/



More information about the llvm-dev mailing list