[llvm-commits] [llvm] r101075 - in /llvm/trunk: lib/Target/X86/X86InstrInfo.cpp test/CodeGen/X86/brcond.ll

Dan Gohman gohman at apple.com
Mon Apr 12 16:27:52 PDT 2010


On Apr 12, 2010, at 4:22 PM, Dale Johannesen wrote:

> 
> On Apr 12, 2010, at 4:13 PMPDT, Chris Lattner wrote:
> 
>> 
>> On Apr 12, 2010, at 3:19 PM, Bill Wendling wrote:
>> 
>>> Author: void
>>> Date: Mon Apr 12 17:19:57 2010
>>> New Revision: 101075
>> 
>> hi Bill, is it possible for this to go in target independent code, e.g. branch folding?
>> 
>> -Chris
> 
> Branch folding is already trying:
> 
>    // If the prior block branches here on true and somewhere else on false, and
>    // if the branch condition is reversible, reverse the branch to create a
>    // fall-through.
>    if (PriorTBB == MBB) {
>      SmallVector<MachineOperand, 4> NewPriorCond(PriorCond);
>      if (!TII->ReverseBranchCondition(NewPriorCond)) {
>        TII->RemoveBranch(PrevBB);
>        TII->InsertBranch(PrevBB, PriorFBB, 0, NewPriorCond);
>        MadeChange = true;
>        ++NumBranchOpts;
>        goto ReoptimizeBlock;
>      }
>    }
> 
> Why doesn't it work in this case?

I was curious too. CodeGenPrepare has split a critical edge for a PHI
node, however after register allocation it turns out that no copy was
needed, so the jmp is actually in a separate basic block from the
jne, jp.

Would it be possible to get branch folding to merge the empty block
before doing the other reordering that it's doing here? I'm curious if
that would allow the code Dale quoted above to do its job.

Dan





More information about the llvm-commits mailing list