diff options
author | Thomas Lively <7121787+tlively@users.noreply.github.com> | 2020-03-10 18:52:50 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-10 18:52:50 -0700 |
commit | 0abc9ce8e9676c95f7ff572529eebf3018179dad (patch) | |
tree | cfe650786faef0e072ed426d70590a29095031ca /src/passes/RedundantSetElimination.cpp | |
parent | 8f16059d3c29e285d4effed7f0c1f84c1f2f4d9d (diff) | |
download | binaryen-0abc9ce8e9676c95f7ff572529eebf3018179dad.tar.gz binaryen-0abc9ce8e9676c95f7ff572529eebf3018179dad.tar.bz2 binaryen-0abc9ce8e9676c95f7ff572529eebf3018179dad.zip |
Update Precompute to handle tuples (#2687)
This involves replacing `Literal::makeZero` with `Literal::makeZeroes`
and `Literal::makeSingleZero` and updating `isConstantExpression` to
handle constant tuples as well. Also makes `Literals` its own struct
and adds convenience methods on it.
Diffstat (limited to 'src/passes/RedundantSetElimination.cpp')
-rw-r--r-- | src/passes/RedundantSetElimination.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/passes/RedundantSetElimination.cpp b/src/passes/RedundantSetElimination.cpp index d881bd9e2..ab052853c 100644 --- a/src/passes/RedundantSetElimination.cpp +++ b/src/passes/RedundantSetElimination.cpp @@ -92,11 +92,13 @@ struct RedundantSetElimination // numbering Index nextValue = 1; // 0 is reserved for the "unseen value" - std::unordered_map<Literal, Index> literalValues; // each constant has a value - std::unordered_map<Expression*, Index> - expressionValues; // each value can have a value + // each constant has a value + std::unordered_map<Literals, Index> literalValues; + // each value can have a value + std::unordered_map<Expression*, Index> expressionValues; + // each block has values for each merge std::unordered_map<BasicBlock*, std::unordered_map<Index, Index>> - blockMergeValues; // each block has values for each merge + blockMergeValues; Index getUnseenValue() { // we haven't seen this location yet return 0; @@ -108,7 +110,7 @@ struct RedundantSetElimination return nextValue++; } - Index getLiteralValue(Literal lit) { + Index getLiteralValue(Literals lit) { auto iter = literalValues.find(lit); if (iter != literalValues.end()) { return iter->second; @@ -159,7 +161,7 @@ struct RedundantSetElimination Index getValue(Expression* value, LocalValues& currValues) { if (auto* c = value->dynCast<Const>()) { // a constant - return getLiteralValue(c->value); + return getLiteralValue({c->value}); } else if (auto* get = value->dynCast<LocalGet>()) { // a copy of whatever that was return currValues[get->index]; |