diff options
Diffstat (limited to 'src/ir/LocalGraph.cpp')
-rw-r--r-- | src/ir/LocalGraph.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/ir/LocalGraph.cpp b/src/ir/LocalGraph.cpp index a5495b5b3..7e877e65e 100644 --- a/src/ir/LocalGraph.cpp +++ b/src/ir/LocalGraph.cpp @@ -624,6 +624,38 @@ void LazyLocalGraph::computeGetInfluences() const { doComputeGetInfluences(*locations, *getInfluences); } +bool LazyLocalGraph::computeSSA(Index index) const { + // We must never repeat work. + assert(!SSAIndexes.count(index)); + + if (!flower) { + makeFlower(); + } + + // Similar logic to LocalGraph::computeSSAIndexes(), but optimized for the + // case of a single index. + + // All the sets for this index that we've seen. We'll add all relevant ones, + // and exit if we see more than one. + SmallUnorderedSet<LocalSet*, 2> sets; + for (auto* set : flower->setsByIndex[index]) { + sets.insert(set); + if (sets.size() > 1) { + return SSAIndexes[index] = false; + } + } + for (auto* get : flower->getsByIndex[index]) { + for (auto* set : getSets(get)) { + sets.insert(set); + if (sets.size() > 1) { + return SSAIndexes[index] = false; + } + } + } + // Finally, check that we have 1 and not 0 sets. + return SSAIndexes[index] = (sets.size() == 1); +} + void LazyLocalGraph::computeLocations() const { // We must never repeat work. assert(!locations); |