5656//
5757
5858#include < iterator>
59+ #include < unordered_map>
60+ #include < unordered_set>
5961
6062#include " ir/branch-utils.h"
6163#include " ir/effects.h"
@@ -74,9 +76,9 @@ static const Index WORTH_ADDING_BLOCK_TO_REMOVE_THIS_MUCH = 3;
7476struct ExpressionMarker
7577 : public PostWalker<ExpressionMarker,
7678 UnifiedExpressionVisitor<ExpressionMarker>> {
77- std::set <Expression*>& marked;
79+ std::unordered_set <Expression*>& marked;
7880
79- ExpressionMarker (std::set <Expression*>& marked, Expression* expr)
81+ ExpressionMarker (std::unordered_set <Expression*>& marked, Expression* expr)
8082 : marked(marked) {
8183 walk (expr);
8284 }
@@ -122,13 +124,16 @@ struct CodeFolding
122124
123125 // pass state
124126
125- std::map<Name, std::vector<Tail>> breakTails; // break target name => tails
126- // that reach it
127+ std::unordered_map<Name, std::vector<Tail>>
128+ breakTails; // break target name => tails
129+ // that reach it
127130 std::vector<Tail> unreachableTails; // tails leading to (unreachable)
128131 std::vector<Tail> returnTails; // tails leading to (return)
129- std::set<Name> unoptimizables; // break target names that we can't handle
130- std::set<Expression*> modifieds; // modified code should not be processed
131- // again, wait for next pass
132+ std::unordered_set<Name>
133+ unoptimizables; // break target names that we can't handle
134+ std::unordered_set<Expression*>
135+ modifieds; // modified code should not be processed
136+ // again, wait for next pass
132137
133138 // walking
134139
@@ -644,17 +649,18 @@ struct CodeFolding
644649 if (next.size () >= 2 ) {
645650 // now we want to find a mergeable item - any item that is equal among a
646651 // subset
647- std::map<Expression*, size_t > hashes; // expression => hash value
652+ std::unordered_map<Expression*, size_t >
653+ hashes; // expression => hash value
648654 // hash value => expressions with that hash
649- std::map <size_t , std::vector<Expression*>> hashed;
655+ std::unordered_map <size_t , std::vector<Expression*>> hashed;
650656 for (auto & tail : next) {
651657 auto * item = getItem (tail, num);
652658 auto hash = hashes[item] = ExpressionAnalyzer::hash (item);
653659 hashed[hash].push_back (item);
654660 }
655661 // look at each hash value exactly once. we do this in a deterministic
656662 // order by iterating over a vector retaining insertion order.
657- std::set <size_t > seen;
663+ std::unordered_set <size_t > seen;
658664 for (auto & tail : next) {
659665 auto * item = getItem (tail, num);
660666 auto digest = hashes[item];
0 commit comments