[llvm-commits] [llvm] r53527 - /llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp

Bill Wendling isanbard at gmail.com
Sun Jul 13 15:11:31 PDT 2008


On Jul 13, 2008, at 2:15 PM, Chris Lattner wrote:
> Author: lattner
> Date: Sun Jul 13 16:15:11 2008
> New Revision: 53527
>
> URL: http://llvm.org/viewvc/llvm-project?rev=53527&view=rev
> Log:
> simplify logic a bit
>
> Modified:
>    llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
>
> Modified: llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp?rev=53527&r1=53526&r2=53527&view=diff
>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp (original)
> +++ llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp Sun Jul 13  
> 16:15:11 2008
> @@ -1473,9 +1473,15 @@
>       PBI->setSuccessor(0, OldFalse);
>       PBI->setSuccessor(1, OldTrue);
>     }
> +
> +    Instruction::BinaryOps Opc = Instruction::Shl; // sentinel.
> +
> +    if (PBI->getSuccessor(0) == TrueDest && FalseDest != BB)
> +      Opc = Instruction::Or;
> +    else if (PBI->getSuccessor(1) == FalseDest && TrueDest != BB)
> +      Opc = Instruction::And;
>
> -    if ((PBI->getSuccessor(0) == TrueDest && FalseDest != BB) ||
> -        (PBI->getSuccessor(1) == FalseDest && TrueDest != BB)) {
> +    if (Opc != Instruction::Shl) {
>       // Clone Cond into the predecessor basic block, and or/and the
>       // two conditions together.
>       Instruction *New = Cond->clone();
> @@ -1483,13 +1489,8 @@
>       New->takeName(Cond);
>       Cond->setName(New->getName()+".old");
>
> -      Value *NewCond;
> -      if (PBI->getSuccessor(0) == TrueDest)
> -        NewCond = BinaryOperator::CreateOr(PBI->getCondition(),  
> New, "or.cond",
> -                                           PBI);
> -      else
> -        NewCond = BinaryOperator::CreateOr(PBI->getCondition(),  
> New, "and.cond",
> -                                           PBI);

Did this also fix a bug where both of these were "CreateOr"? :-)

-bw

>
> +      Value *NewCond = BinaryOperator::Create(Opc, PBI- 
> >getCondition(),
> +                                              New, "or.cond", PBI);
>       PBI->setCondition(NewCond);
>       if (PBI->getSuccessor(0) == BB) {
>         AddPredecessorToBlock(TrueDest, PredBlock, BB);
>
>
> _______________________________________________
> 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