[llvm-commits] [llvm] r69121 - /llvm/trunk/lib/Transforms/Scalar/CondPropagate.cpp

Chris Lattner clattner at apple.com
Tue Apr 14 20:21:53 PDT 2009


On Apr 14, 2009, at 5:44 PM, Evan Cheng wrote:

> Author: evancheng
> Date: Tue Apr 14 19:43:54 2009
> New Revision: 69121
>
> URL: http://llvm.org/viewvc/llvm-project?rev=69121&view=rev
> Log:
> Avoid making the transformation enabled by my last patch if the new  
> destinations have phi nodes.

Thanks, testcase? :)

-Chris

>
>
> Modified:
>    llvm/trunk/lib/Transforms/Scalar/CondPropagate.cpp
>
> Modified: llvm/trunk/lib/Transforms/Scalar/CondPropagate.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/CondPropagate.cpp?rev=69121&r1=69120&r2=69121&view=diff
>
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- llvm/trunk/lib/Transforms/Scalar/CondPropagate.cpp (original)
> +++ llvm/trunk/lib/Transforms/Scalar/CondPropagate.cpp Tue Apr 14  
> 19:43:54 2009
> @@ -267,11 +267,21 @@
>     // Change FromBr to branch to the new destination.
>     FromBr->setSuccessor(0, ToBB);
>   } else {
> +    BasicBlock *Succ0 = BI->getSuccessor(0);
> +    // Do not perform transform if the new destination has PHI  
> nodes. The
> +    // transform will add new preds to the PHI's.
> +    if (isa<PHINode>(Succ0->begin()))
> +      return false;
> +
> +    BasicBlock *Succ1 = BI->getSuccessor(1);
> +    if (isa<PHINode>(Succ1->begin()))
> +      return false;
> +
>     // Insert the new conditional branch.
> -    BranchInst::Create(BI->getSuccessor(0), BI->getSuccessor(1),  
> Cond, FromBr);
> +    BranchInst::Create(Succ0, Succ1, Cond, FromBr);
>
> -    FoldSingleEntryPHINodes(BI->getSuccessor(0));
> -    FoldSingleEntryPHINodes(BI->getSuccessor(1));
> +    FoldSingleEntryPHINodes(Succ0);
> +    FoldSingleEntryPHINodes(Succ1);
>
>     // Update PHI nodes in OldSucc to know that FromBB no longer  
> branches to it.
>     OldSucc->removePredecessor(FromBB);
>
>
> _______________________________________________
> 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