diff options
| author | Chris Lattner <sabre@nondot.org> | 2010-12-13 04:15:19 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2010-12-13 04:15:19 +0000 |
| commit | 395252d93eb68e1c3e9bbd8106f1512abd745761 (patch) | |
| tree | e8ffd6b793ca13cc1381f57c6876252a7a75ea30 /llvm/lib/Transforms | |
| parent | 62cc76e9cce68b4ea7b6c3f2b00522d3fa133788 (diff) | |
| download | bcm5719-llvm-395252d93eb68e1c3e9bbd8106f1512abd745761.tar.gz bcm5719-llvm-395252d93eb68e1c3e9bbd8106f1512abd745761.zip | |
inline a function, making the result much simpler.
llvm-svn: 121675
Diffstat (limited to 'llvm/lib/Transforms')
| -rw-r--r-- | llvm/lib/Transforms/Utils/SimplifyCFG.cpp | 38 |
1 files changed, 11 insertions, 27 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp index 68f6905d4b5..d3181b138a7 100644 --- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp @@ -347,31 +347,6 @@ GatherConstantSetNEs(Value *V, std::vector<ConstantInt*> &Values, 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 @@ bool SimplifyCFGOpt::run(BasicBlock *BB) { // '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. |

