diff options
| author | Rafael Espindola <rafael.espindola@gmail.com> | 2012-08-16 15:09:43 +0000 | 
|---|---|---|
| committer | Rafael Espindola <rafael.espindola@gmail.com> | 2012-08-16 15:09:43 +0000 | 
| commit | cc80cdebb9f3f835283cf70c5b99b8a7fc1ce9bd (patch) | |
| tree | 2bda0975bc5e462a0615629cf15dd5da9b17d7c2 /llvm/lib/VMCore/Dominators.cpp | |
| parent | 3482ec3bc8bd457bca29299ae1aa1ed16312f757 (diff) | |
| download | bcm5719-llvm-cc80cdebb9f3f835283cf70c5b99b8a7fc1ce9bd.tar.gz bcm5719-llvm-cc80cdebb9f3f835283cf70c5b99b8a7fc1ce9bd.zip | |
Teach GVN to reason about edges dominating uses. This allows it to handle cases
where some fact lake a=b dominates a use in a phi, but doesn't dominate the
basic block itself.
This feature could also be implemented by splitting critical edges, but at least
with the current algorithm reasoning about the dominance directly is faster.
The time for running "opt -O2" in the testcase in pr10584 is 1.003 times slower
and on gcc as a single file it is 1.0007 times faster.
llvm-svn: 162023
Diffstat (limited to 'llvm/lib/VMCore/Dominators.cpp')
| -rw-r--r-- | llvm/lib/VMCore/Dominators.cpp | 25 | 
1 files changed, 11 insertions, 14 deletions
| diff --git a/llvm/lib/VMCore/Dominators.cpp b/llvm/lib/VMCore/Dominators.cpp index 682d928e4da..60bdeac16b3 100644 --- a/llvm/lib/VMCore/Dominators.cpp +++ b/llvm/lib/VMCore/Dominators.cpp @@ -39,20 +39,17 @@ static cl::opt<bool,true>  VerifyDomInfoX("verify-dom-info", cl::location(VerifyDomInfo),                 cl::desc("Verify dominator info (time consuming)")); -namespace llvm { -  class BasicBlockEdge { -    const BasicBlock *Start; -    const BasicBlock *End; -  public: -    BasicBlockEdge(const BasicBlock *Start_, const BasicBlock *End_) : -      Start(Start_), End(End_) { } -    const BasicBlock *getStart() const { -      return Start; -    } -    const BasicBlock *getEnd() const { -      return End; -    } -  }; +bool BasicBlockEdge::isSingleEdge() const { +  const TerminatorInst *TI = Start->getTerminator(); +  unsigned NumEdgesToEnd = 0; +  for (unsigned int i = 0, n = TI->getNumSuccessors(); i < n; ++i) { +    if (TI->getSuccessor(i) == End) +      ++NumEdgesToEnd; +    if (NumEdgesToEnd >= 2) +      return false; +  } +  assert(NumEdgesToEnd == 1); +  return true;  }  //===----------------------------------------------------------------------===// | 

