diff options
author | Duncan Sands <baldrick@free.fr> | 2012-02-05 15:50:43 +0000 |
---|---|---|
committer | Duncan Sands <baldrick@free.fr> | 2012-02-05 15:50:43 +0000 |
commit | 68e20223a7260b5978dc85af6fea647be4c6a5f9 (patch) | |
tree | ab34df6d4e8668834fa135e79b04ef8ccebb6966 /lib/Transforms | |
parent | 5b8a1db7ea6510a2589f710d50754599da742de9 (diff) | |
download | external_llvm-68e20223a7260b5978dc85af6fea647be4c6a5f9.zip external_llvm-68e20223a7260b5978dc85af6fea647be4c6a5f9.tar.gz external_llvm-68e20223a7260b5978dc85af6fea647be4c6a5f9.tar.bz2 |
Reduce the number of non-trivial domtree queries by about 1% when
compiling sqlite3, by only doing dom queries after the cheap check
rather than interleaved with it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149836 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r-- | lib/Transforms/Scalar/GVN.cpp | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/lib/Transforms/Scalar/GVN.cpp b/lib/Transforms/Scalar/GVN.cpp index bdcbfb0..03ebbb1 100644 --- a/lib/Transforms/Scalar/GVN.cpp +++ b/lib/Transforms/Scalar/GVN.cpp @@ -1996,28 +1996,30 @@ static bool isOnlyReachableViaThisEdge(BasicBlock *Src, BasicBlock *Dst, DominatorTree *DT) { // First off, there must not be more than one edge from Src to Dst, there // should be exactly one. So keep track of the number of times Src occurs - // as a predecessor of Dst and fail if it's more than once. Secondly, any - // other predecessors of Dst should be dominated by Dst (see logic below). + // as a predecessor of Dst and fail if it's more than once. bool SawEdgeFromSrc = false; for (pred_iterator PI = pred_begin(Dst), PE = pred_end(Dst); PI != PE; ++PI) { - BasicBlock *Pred = *PI; - if (Pred == Src) { - // An edge from Src to Dst. - if (SawEdgeFromSrc) - // There are multiple edges from Src to Dst - fail. - return false; - SawEdgeFromSrc = true; + if (*PI != Src) continue; - } - // If the predecessor is not dominated by Dst, then it must be possible to - // reach it either without passing through Src (and thus not via the edge) - // or by passing through Src but taking a different edge out of Src. Either - // way it is possible to reach Dst without passing via the edge, so fail. - if (!DT->dominates(Dst, *PI)) + // An edge from Src to Dst. + if (SawEdgeFromSrc) + // There are multiple edges from Src to Dst - fail. return false; + SawEdgeFromSrc = true; } assert(SawEdgeFromSrc && "No edge between these basic blocks!"); + // Secondly, any other predecessors of Dst should be dominated by Dst. If the + // predecessor is not dominated by Dst, then it must be possible to reach it + // either without passing through Src (thus not via the edge) or by passing + // through Src but taking a different edge out of Src. Either way Dst can be + // reached without passing via the edge, so fail. + for (pred_iterator PI = pred_begin(Dst), PE = pred_end(Dst); PI != PE; ++PI) { + BasicBlock *Pred = *PI; + if (Pred != Src && !DT->dominates(Dst, Pred)) + return false; + } + // Every path from the entry block to Dst must at some point pass to Dst from // a predecessor that is not dominated by Dst. This predecessor can only be // Src, since all others are dominated by Dst. As there is only one edge from |