Value Constraint Based Simplifier.

This commit is contained in:
chriseth
2019-03-25 15:32:54 +01:00
parent cb633c3a0c
commit 061276b28a
12 changed files with 598 additions and 5 deletions
+6
View File
@@ -35,6 +35,7 @@
#include <libyul/optimiser/MainFunction.h>
#include <libyul/optimiser/Rematerialiser.h>
#include <libyul/optimiser/ExpressionSimplifier.h>
#include <libyul/optimiser/ValueConstraintBasedSimplifier.h>
#include <libyul/optimiser/UnusedPruner.h>
#include <libyul/optimiser/ExpressionJoiner.h>
#include <libyul/optimiser/SSAReverser.h>
@@ -182,6 +183,11 @@ bool YulOptimizerTest::run(ostream& _stream, string const& _linePrefix, bool con
disambiguate();
ExpressionSimplifier::run(*m_dialect, *m_ast);
}
else if (m_optimizerStep == "valueConstraintBasedSimplifier")
{
disambiguate();
ValueConstraintBasedSimplifier::run(*m_dialect, *m_ast);
}
else if (m_optimizerStep == "fullSimplify")
{
disambiguate();
@@ -0,0 +1,38 @@
{
let x := 2
if lt(x, 9) { sstore(0, 1) }
if lt(x, 2) { sstore(0, 1) }
if gt(x, 0) { sstore(0, 1) }
if lt(9, x) { sstore(0, 1) }
if lt(2, x) { sstore(0, 1) }
if gt(0, x) { sstore(0, 1) }
}
// ----
// valueConstraintBasedSimplifier
// {
// let x := 2
// if 1
// {
// sstore(0, 1)
// }
// if 0
// {
// sstore(0, 1)
// }
// if 1
// {
// sstore(0, 1)
// }
// if 0
// {
// sstore(0, 1)
// }
// if 0
// {
// sstore(0, 1)
// }
// if 0
// {
// sstore(0, 1)
// }
// }
@@ -0,0 +1,18 @@
{
let x := and(callvalue(), 0xff)
if lt(x, 0x100) { sstore(0, 1) }
if lt(x, 0xff) { sstore(0, 1) }
}
// ----
// valueConstraintBasedSimplifier
// {
// let x := and(callvalue(), 0xff)
// if 1
// {
// sstore(0, 1)
// }
// if lt(x, 0xff)
// {
// sstore(0, 1)
// }
// }
@@ -0,0 +1,6 @@
{
}
// ----
// valueConstraintBasedSimplifier
// {
// }