[llvm] r182385 - Fix PPC branch selection for counter-based branches

Hal Finkel hfinkel at anl.gov
Tue May 21 14:58:53 PDT 2013


Bill,

Please pull this bug fix into the release branch.

Thanks again,
Hal

----- Original Message -----
> Author: hfinkel
> Date: Tue May 21 09:21:09 2013
> New Revision: 182385
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=182385&view=rev
> Log:
> Fix PPC branch selection for counter-based branches
> 
> Although I had added some support for the BDZ/BDNZ branches into the
> selector
> (in r158204), I had not correctly adjusted the condition at the top
> of the
> loop. As a result, these branches were still essentially unsupported.
> 
> This fixes PR16086. Unfortunately, any test case would be very large
> (because
> it would need to force the loop backedge to exceed the range of the
> 16-bit
> immediate).
> 
> Modified:
>     llvm/trunk/lib/Target/PowerPC/PPCBranchSelector.cpp
> 
> Modified: llvm/trunk/lib/Target/PowerPC/PPCBranchSelector.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCBranchSelector.cpp?rev=182385&r1=182384&r2=182385&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/PowerPC/PPCBranchSelector.cpp (original)
> +++ llvm/trunk/lib/Target/PowerPC/PPCBranchSelector.cpp Tue May 21
> 09:21:09 2013
> @@ -112,15 +112,21 @@ bool PPCBSel::runOnMachineFunction(Machi
>        unsigned MBBStartOffset = 0;
>        for (MachineBasicBlock::iterator I = MBB.begin(), E =
>        MBB.end();
>             I != E; ++I) {
> -        if (I->getOpcode() != PPC::BCC || I->getOperand(2).isImm())
> {
> +        MachineBasicBlock *Dest = 0;
> +        if (I->getOpcode() == PPC::BCC && !I->getOperand(2).isImm())
> +          Dest = I->getOperand(2).getMBB();
> +        else if ((I->getOpcode() == PPC::BDNZ8 || I->getOpcode() ==
> PPC::BDNZ ||
> +                  I->getOpcode() == PPC::BDZ8  || I->getOpcode() ==
> PPC::BDZ) &&
> +                 !I->getOperand(0).isImm())
> +          Dest = I->getOperand(0).getMBB();
> +
> +        if (!Dest) {
>            MBBStartOffset += TII->GetInstSizeInBytes(I);
>            continue;
>          }
>          
>          // Determine the offset from the current branch to the
>          destination
>          // block.
> -        MachineBasicBlock *Dest = I->getOperand(2).getMBB();
> -
>          int BranchSize;
>          if (Dest->getNumber() <= MBB.getNumber()) {
>            // If this is a backwards branch, the delta is the offset
>            from the
> 
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
> 



More information about the llvm-commits mailing list