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

Bill Wendling wendling at apple.com
Mon Dec 13 12:58:47 PST 2010


On Dec 12, 2010, at 8:15 PM, Chris Lattner wrote:

> Author: lattner
> Date: Sun Dec 12 22:15:19 2010
> New Revision: 121675
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=121675&view=rev
> Log:
> inline a function, making the result much simpler.
> 
Chris,

This doesn't have the same semantics as the original non-inlined version. TrueWhenEqual should be "false" if the dyn_cast fails.

-bw

> 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=121675&r1=121674&r2=121675&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp (original)
> +++ llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp Sun Dec 12 22:15:19 2010
> @@ -347,31 +347,6 @@
>   return 0;
> }
> 
> -/// GatherValueComparisons - If the specified Cond is an 'and' or 'or' of a
> -/// bunch of comparisons of one value against constants, return the value and
> -/// the constants being compared.
> -static bool GatherValueComparisons(Value *CondV, Value *&CompVal,
> -                                   std::vector<ConstantInt*> &Values,
> -                                   const TargetData *TD) {
> -  Instruction *Cond = dyn_cast<Instruction>(CondV);
> -  if (Cond == 0) return false;
> -  
> -  if (Cond->getOpcode() == Instruction::Or) {
> -    CompVal = GatherConstantSetEQs(Cond, Values, TD);
> -
> -    // Return true to indicate that the condition is true if the CompVal is
> -    // equal to one of the constants.
> -    return true;
> -  }
> -  if (Cond->getOpcode() == Instruction::And) {
> -    CompVal = GatherConstantSetNEs(Cond, Values, TD);
> -
> -    // Return false to indicate that the condition is false if the CompVal is
> -    // equal to one of the constants.
> -    return false;
> -  }
> -  return false;
> -}
> 
> static void EraseTerminatorInstAndDCECond(TerminatorInst *TI) {
>   Instruction* Cond = 0;
> @@ -2096,8 +2071,17 @@
>       // 'setne's and'ed together, collect them.
>       Value *CompVal = 0;
>       std::vector<ConstantInt*> Values;
> -      bool TrueWhenEqual = GatherValueComparisons(BI->getCondition(), CompVal,
> -                                                  Values, TD);
> +      bool TrueWhenEqual = true;
> +      
> +      if (Instruction *Cond = dyn_cast<Instruction>(BI->getCondition())) {
> +        if (Cond->getOpcode() == Instruction::Or) {
> +          CompVal = GatherConstantSetEQs(Cond, Values, TD);
> +        } else if (Cond->getOpcode() == Instruction::And) {
> +          CompVal = GatherConstantSetNEs(Cond, Values, TD);
> +          TrueWhenEqual = false;
> +        }
> +      }
> +
>       if (CompVal) {
>         // There might be duplicate constants in the list, which the switch
>         // instruction can't handle, remove them now.
> 
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20101213/68062073/attachment.html>


More information about the llvm-commits mailing list