First simplify switch with known constant expression.

This commit is contained in:
chriseth
2019-03-06 21:32:55 +01:00
parent 0f336f30ca
commit 791fde953d
6 changed files with 23 additions and 14 deletions
+3 -2
View File
@@ -180,6 +180,9 @@ void StructuralSimplifier::simplify(std::vector<yul::Statement>& _statements)
return {};
},
[&](Switch& _switchStmt) -> OptionalStatements {
if (boost::optional<u256> const constExprVal = hasLiteralValue(*_switchStmt.expression))
return replaceConstArgSwitch(_switchStmt, constExprVal.get());
removeEmptyDefaultFromSwitch(_switchStmt);
removeEmptyCasesFromSwitch(_switchStmt);
@@ -187,8 +190,6 @@ void StructuralSimplifier::simplify(std::vector<yul::Statement>& _statements)
return reduceNoCaseSwitch(_switchStmt);
else if (_switchStmt.cases.size() == 1)
return reduceSingleCaseSwitch(_switchStmt);
else if (boost::optional<u256> const constExprVal = hasLiteralValue(*_switchStmt.expression))
return replaceConstArgSwitch(_switchStmt, constExprVal.get());
return {};
},