]> granicus.if.org Git - llvm/commit
Handle non-unique edges in edge-dominance
authorAdam Nemet <anemet@apple.com>
Mon, 5 Jun 2017 16:27:09 +0000 (16:27 +0000)
committerAdam Nemet <anemet@apple.com>
Mon, 5 Jun 2017 16:27:09 +0000 (16:27 +0000)
commit8008a8a9545e2e4585776541d96a5af0a57d12d1
treee5995a6a0102dfc1ce5d195fb17bd13b617c75be
parent908f18379e399dc90661d8faed14a110ec62f4bb
Handle non-unique edges in edge-dominance

This removes a quadratic behavior in assert-enabled builds.

GVN propagates the equivalence from a condition into the blocks guarded by the
condition.  E.g. for 'if (a == 7) { ... }', 'a' will be replaced in the block
with 7.  It does this by replacing all the uses of 'a' that are dominated by
the true edge.

For a switch with N cases and U uses of the value, this will mean N * U calls
to 'dominates'.  Asserting isSingleEdge in 'dominates' make this N^2 * U
because this function checks for the uniqueness of the edge. I.e. traverses
each edge between the SwitchInst's block and the cases.

The change removes the assert and makes 'dominates' works correctly in the
presence of non-unique edges.

This brings build time down by an order of magnitude for an input that has
~10k cases in a switch statement.

Differential Revision: https://reviews.llvm.org/D33584

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@304721 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/IR/Dominators.h
lib/IR/Dominators.cpp
unittests/IR/DominatorTreeTest.cpp