diff options
| author | Hal Finkel <hfinkel@anl.gov> | 2012-11-14 18:38:11 +0000 | 
|---|---|---|
| committer | Hal Finkel <hfinkel@anl.gov> | 2012-11-14 18:38:11 +0000 | 
| commit | 1b7f0aba48423f6233fad716fdec85c24fb99428 (patch) | |
| tree | 7c91750c8f30e3301bc0eca220b2c17a389b0adf /llvm/lib/Transforms | |
| parent | 0c5a621b87f6a9d8764e252e1ac0b632f46b6559 (diff) | |
| download | bcm5719-llvm-1b7f0aba48423f6233fad716fdec85c24fb99428.tar.gz bcm5719-llvm-1b7f0aba48423f6233fad716fdec85c24fb99428.zip | |
Fix the largest offender of determinism in BBVectorize
Iterating over the children of each node in the potential vectorization
plan must happen in a deterministic order (because it affects which children
are erased when two children conflict). There was no need for this data
structure to be a map in the first place, so replacing it with a vector
is a small change.
I believe that this was the last remaining instance if iterating over the
elements of a Dense* container where the iteration order could matter.
There are some remaining iterations over std::*map containers where the order
might matter, but so long as the Value* for instructions in a block increase
with the order of the instructions in the block (or decrease) monotonically,
then this will appear to be deterministic.
llvm-svn: 167942
Diffstat (limited to 'llvm/lib/Transforms')
| -rw-r--r-- | llvm/lib/Transforms/Vectorize/BBVectorize.cpp | 12 | 
1 files changed, 6 insertions, 6 deletions
| diff --git a/llvm/lib/Transforms/Vectorize/BBVectorize.cpp b/llvm/lib/Transforms/Vectorize/BBVectorize.cpp index df50589eb62..e880acfa873 100644 --- a/llvm/lib/Transforms/Vectorize/BBVectorize.cpp +++ b/llvm/lib/Transforms/Vectorize/BBVectorize.cpp @@ -1485,7 +1485,7 @@ namespace {        PrunedTree.insert(QTop.first);        // Visit each child, pruning as necessary... -      DenseMap<ValuePair, size_t> BestChildren; +      std::vector<ValuePairWithDepth> BestChildren;        VPPIteratorPair QTopRange = ConnectedPairs.equal_range(QTop.first);        for (std::multimap<ValuePair, ValuePair>::iterator K = QTopRange.first;             K != QTopRange.second; ++K) { @@ -1517,7 +1517,7 @@ namespace {          DenseSet<ValuePair> CurrentPairs;          bool CanAdd = true; -        for (DenseMap<ValuePair, size_t>::iterator C2 +        for (std::vector<ValuePairWithDepth>::iterator C2                = BestChildren.begin(), E2 = BestChildren.end();               C2 != E2; ++C2) {            if (C2->first.first == C->first.first || @@ -1602,22 +1602,22 @@ namespace {          // to an already-selected child. Check for this here, and if a          // conflict is found, then remove the previously-selected child          // before adding this one in its place. -        for (DenseMap<ValuePair, size_t>::iterator C2 +        for (std::vector<ValuePairWithDepth>::iterator C2                = BestChildren.begin(); C2 != BestChildren.end();) {            if (C2->first.first == C->first.first ||                C2->first.first == C->first.second ||                C2->first.second == C->first.first ||                C2->first.second == C->first.second ||                pairsConflict(C2->first, C->first, PairableInstUsers)) -            BestChildren.erase(C2++); +            C2 = BestChildren.erase(C2);            else              ++C2;          } -        BestChildren.insert(ValuePairWithDepth(C->first, C->second)); +        BestChildren.push_back(ValuePairWithDepth(C->first, C->second));        } -      for (DenseMap<ValuePair, size_t>::iterator C +      for (std::vector<ValuePairWithDepth>::iterator C              = BestChildren.begin(), E2 = BestChildren.end();             C != E2; ++C) {          size_t DepthF = getDepthFactor(C->first.first); | 

